Skip to content

Release v6.7.5: chat paste chips for large pasted text - #120

Merged
code-crusher merged 2 commits into
mainfrom
release/v6.7.5
Aug 4, 2026
Merged

Release v6.7.5: chat paste chips for large pasted text#120
code-crusher merged 2 commits into
mainfrom
release/v6.7.5

Conversation

@code-crusher

Copy link
Copy Markdown
Member

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

  • New PasteChips component (webview-ui/src/components/common/PasteChips.tsx): chip pill rendered in the attachment strip next to image/document chips, with the FileTypeIcon, 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.
  • Same behavior in edit mode (ChatRow); onSend/edit handlers updated to accept the merged text.
  • FileTypeIcon added to customIcons.tsx.
  • Unit tests for the threshold, merge ordering, position clamping, and chip removal.

Version

  • Bumped src/package.json to 6.7.5.

Compatibility

No API or config changes. Behavior triggers only for pastes >= 500 characters.

@matterai-app matterai-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 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 insertPosition at 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), mergePasteChips will insert the pasted text at the wrong offset in the current inputValue, 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 → `"XX

llo"instead of between"he"and"llo"`.

Fix: This is a design-level concern. Options include: (a) adjusting chip positions on every inputValue change 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, but onSend(expandedValue) on line 298 already passes the final value directly to the parent. The parent's handleSendMessage will typically clear inputValue after sending, making this setInputValue call 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 onSend now receives the value directly, the setInputValue is 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)

@code-crusher
code-crusher merged commit cc32a21 into main Aug 4, 2026
3 of 9 checks passed
@code-crusher
code-crusher deleted the release/v6.7.5 branch August 4, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant