webui: Fix cursor jumping during image uploads
When pasting an image and continuing to type while it's uploading,
the cursor position would jump when upload completed, disrupting typing.
This fix simply removes the explicit cursor positioning code after
image upload, allowing the browser to maintain the user's current cursor
position naturally. This provides a more intuitive experience, especially
when typing while an image is uploading.
The approach is simpler and more robust than trying to track cursor
position changes and calculate offsets manually.
diff --git a/webui/src/web-components/sketch-chat-input.ts b/webui/src/web-components/sketch-chat-input.ts
index ca6afbf..355c9fc 100644
--- a/webui/src/web-components/sketch-chat-input.ts
+++ b/webui/src/web-components/sketch-chat-input.ts
@@ -173,15 +173,6 @@
// Replace the loading placeholder with the actual file path
this.content = this.content.replace(loadingText, `[${data.path}]`);
- // Adjust the cursor position after the inserted text
- requestAnimationFrame(() => {
- this.adjustChatSpacing();
- this.chatInput.focus();
- const newPos = textBefore.length + data.path.length + 2; // +2 for the brackets
- this.chatInput.selectionStart = newPos;
- this.chatInput.selectionEnd = newPos;
- });
-
return data.path;
} catch (error) {
console.error("Failed to upload file:", error);