Release v6.7.5: chat paste chips for large pasted text - #120
Conversation
There was a problem hiding this comment.
🧪 PR Review is completed: Paste chip feature is well-implemented with good test coverage. One design concern around stale cursor positions when text is edited after pasting, plus a minor redundant state update on send.
⬇️ Low Priority Suggestions (2)
webview-ui/src/components/chat/ChatTextArea.tsx (2 suggestions)
Location:
webview-ui/src/components/chat/ChatTextArea.tsx(Lines 806-807)🟡 Logic / NEEDS_DISCUSSION — Stale insertPosition after text edits before chip position
Issue: Each paste chip records
insertPositionat paste time (line 806) and never updates it. If the user edits text before the chip's recorded position after pasting (e.g. types characters at an earlier cursor location),mergePasteChipswill insert the pasted text at the wrong offset in the currentinputValue, producing garbled message content sent to the backend.Example: input is
"hello", user pastes at position 2 (chip pos=2), then types"XX"at position 0. Input becomes"XXhello"but chip still says position 2. On send, merge inserts at position 2 → `"XXllo"
instead of between"he"and"llo"`.Fix: This is a design-level concern. Options include: (a) adjusting chip positions on every
inputValuechange by diffing the text before each chip position, (b) storing a text anchor/snippet at paste time and searching for it on merge, or (c) accepting the limitation and documenting it. At minimum, consider clamping or re-validating positions against the current text on send.Impact: Prevents incorrect message content from being sent to the AI when users edit text before a paste chip's position.
- { id: pasteId, text: pastedText, insertPosition: selectionStart }, - ]) +Location:
webview-ui/src/components/chat/ChatTextArea.tsx(Lines 292-298)🔵 Code Quality — Redundant setInputValue before onSend
Issue:
setInputValue(expandedValue)on line 293 updates the input state to the fully merged/expanded text, butonSend(expandedValue)on line 298 already passes the final value directly to the parent. The parent'shandleSendMessagewill typically clearinputValueafter sending, making thissetInputValuecall redundant. At best it causes a brief flash of the expanded text; at worst it competes with the parent's clear in the same render batch.Fix: Since
onSendnow receives the value directly, thesetInputValueis only needed to keep the displayed text in sync if the parent does NOT clear it. If the parent clears it (which is the standard pattern), this line can be removed. If keeping it for safety, wrap it so it doesn't fight the parent's clear.Impact: Cleaner state flow and avoids potential UI flicker of expanded paste content.
- if (expandedValue !== inputValue) { - setInputValue(expandedValue) - } - - // Pass the final text through onSend directly so the parent never - // reads a stale inputValue from an earlier render. - onSend(expandedValue) + const expandedValue = expandMentions(mergedValue) + // Parent receives the final value via onSend directly; only sync + // inputValue if the parent is not expected to clear it. + onSend(expandedValue)
Release v6.7.5
Collapse large pastes (500+ chars) in the chat composer into a removable chip, then merge the full text back at the exact cursor position on send.
What changed
PasteChipscomponent (webview-ui/src/components/common/PasteChips.tsx): chip pill rendered in the attachment strip next to image/document chips, with theFileTypeIcon, the first few words of the pasted text as the name, and a remove button.ChatTextArea: pastes >= 500 characters are captured as a chip (caret position recorded at paste time) instead of flooding the textarea. On send, chips merge back into the message at their recorded positions, separated from surrounding text by two blank lines, then the strip clears.ChatRow);onSend/edit handlers updated to accept the merged text.FileTypeIconadded tocustomIcons.tsx.Version
src/package.jsonto 6.7.5.Compatibility
No API or config changes. Behavior triggers only for pastes >= 500 characters.