Skip to content

fix(web): composer chips convert at the same boundaries on paste and typing - #276

Merged
adampeterhiggins merged 1 commit into
mainfrom
ah/composer-paste-chip-triggers
Oct 12, 2026
Merged

adampeterhiggins merged 1 commit into
mainfrom
ah/composer-paste-chip-triggers

Conversation

@adampeterhiggins

Copy link
Copy Markdown
Owner

Problem

Text in the composer became a chip at inconsistent moments, depending on the chip kind and how the text arrived:

  • Typed @mention, $skill and file links never became chips in the Tiptap editor. They stayed text until something unrelated rewrote the draft through the store (for example, a link elsewhere in the prompt turning into a chip). That rebuilt the whole document, and the earlier tokens suddenly chipped. The token regexes say a typed token becomes a chip "once a delimiter follows it", but the Tiptap editor never acted on that.
  • Pasting while the composer was unfocused (paste-to-focus) skipped issue, pull request, repository, Notion and Slack link conversion. The link only converted later, when you typed a space after it. That path also ignored Cmd+Shift+V, so file paths still became chips.

Fix

  • chipTokenEndingAt in composer-rich-text-doc.ts turns the token ending at the caret into its chip. It reads tokens with the same function as paste and draft rebuilds. The editor calls it when whitespace is typed, and before Enter splits the line, so typed tokens chip on a space, tab or new line, like typed links do. It skips code, styled text, literal answers, and tokens not preceded by whitespace.
  • insertTextAtEnd with clipboard data now runs the same object-link conversion as a focused paste, at the insertion point. ChatView passes the paste-as-text flag through, so links and file paths stay text with Cmd+Shift+V.

Typed links still wait for whitespace, not for ?, . or ): those characters can continue a URL (? starts a query string), so converting on them would cut links short. url? followed by a space still converts.

Testing

  • New unit tests for chipTokenEndingAt: mention, skill, file link, tab, new line, caret placement, and the cases that must stay text ($20, emails, @a.ts?, bold, inline code, a token glued to a chip).
  • vp test run apps/web/src/composer-rich-text-doc.test.ts apps/web/src/components/chat: all pass except OpenInPicker.test.tsx and ChatMarkdown.permissions.test.tsx, which fail the same way on main.
  • tsc --noEmit in apps/web is clean.
  • Not yet checked in a real client.

Surfaces: web and desktop share this editor. Mobile has its own composer and is not changed.

🤖 Generated with Claude Code (Claude Opus 5.5)

…typing

Typing whitespace or a new line after an @mention, $skill or file link
turns it into a chip again, as the token regexes intend. Before, typed
tokens stayed text until an unrelated store rewrite rebuilt the document.

A paste redirected from a blurred composer now converts issue, pull
request and Slack links like a focused paste, and honours the
paste-as-text shortcut for links and file paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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