fix(desktop): snap caret out of agent mention chips#2712
Open
marcoleejr wants to merge 2 commits into
Open
Conversation
Agent mentions in the composer are decorations over plain text, not atom nodes, and the leading @ is width:0. With persistent auto-tag, clicks that look like the start of a chip often land inside the display name; typing then mutates the name and drops the decoration so the agent stops being tagged. Snap an empty caret out of the interior of agent mentions (after the trailing space hydration inserts), and rewrite text input that would land inside a chip so it inserts after the chip instead. Fixes block#2707 Signed-off-by: Marco Lee <mv.lee18@gmail.com>
marcoleejr
force-pushed
the
fix/agent-mention-caret-snap
branch
from
July 25, 2026 06:07
d87653c to
0b51196
Compare
Backspace/Delete inside (or at the edges of) a persistent agent chip no longer nibbles the display name character-by-character — that killed the decoration and broke auto-tag the same way mid-chip typing did. - Interior caret: either key removes `@Name` + trailing space - Backspace at end of name or just after the trailing space: whole chip - Delete at the start of the chip (before `@`): whole chip Follow-up to the caret-snap work for block#2707. Signed-off-by: Marco Lee <mv.lee18@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2707.
With Keep addressed agents active (persistent auto-tag), the composer re-inserts
@AgentNameafter each send. Agent mentions are decorations on plain text, not atom nodes, and the leading@is rendered atwidth: 0. A click that looks like the start of the chip often lands inside the display name; the next keystrokes (or Backspace/Delete) mutate that name, the decoration dies, and the agent is no longer tagged.This PR treats agent chips as non-editable caret space and atomic units:
snapCaretOutOfAgentMention— if the empty caret is strictly inside@Name, move it just after the mention (consuming the trailing space hydration always inserts).appendTransaction— apply that snap after selection changes (clicks, arrows).handleTextInput— if input would land inside a chip, insert after the chip instead of corrupting the name.handleKeyDown(Backspace/Delete) — remove the whole chip (@Name+ trailing space) instead of nibbling letters:@) → chipEdge positions for typing stay put (
before @for normal Backspace into prior text when not using atomic delete rules above; after-name typing still works). Human-only mentions are unchanged.How it was implemented
mentionHighlightExtension.ts(findAgentMentionRanges,snapCaretOutOfAgentMention,withTrailingSpace,agentMentionChipDeleteRange) so the policy is unit-testable without the full editor.Test plan
node --test src/features/messages/lib/mentionHighlightExtension.test.mjs— 35/35 passNotes
Out of scope: turning mentions into real atom nodes (larger rewrite). This is the minimal fix for the auto-tag breakage path reported in #2707.