-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Summary
Composer @ completion can misbehave when it is started inside existing whitespace.
If the cursor is positioned so there is a space immediately before it and also a space at the cursor position, typing @ opens the completion menu correctly, but follow-up typing and selection can behave incorrectly.
Repro steps
- In the composer, insert a file mention so there is already at least one mention pill in the prompt, for example
@AGENTS.md. - Continue typing normal text and leave two spaces somewhere later in the prompt.
- Move the cursor into that double-space gap so there is one space before the cursor and one space at the cursor position.
- Type
@. - Type one or two more characters so the menu filters to matching results.
- Select a completion.
Expected
- The completion menu stays open while the typed query still matches results.
- Selecting a completion replaces the query cleanly.
- The inserted mention ends with exactly one trailing space.
- The caret lands immediately after the inserted mention.
Actual
- In this whitespace-started case, the menu can dismiss while typing even though there is still a valid match.
- If selection succeeds, the inserted completion can leave an extra trailing space.
- In related cursor positions, the caret can land farther right than expected after insertion.
Sample setup prompt
Use this to create the setup quickly, then move the cursor back into the double space after then:
Please inspect @AGENTS.md and then summarize how the composer mention picker behaves.
Sample agent prompt
Investigate and fix composer
@-completion behavior in the web app.Problem summary:
- The composer has mention pills for completed
@pathreferences.- Cursor handling currently mixes collapsed mention-aware offsets and expanded text offsets.
- A remaining bug shows up when the user starts an
@completion inside existing whitespace.Repro target:
- In the composer, create at least one existing mention pill, for example
@AGENTS.md.- Leave two spaces somewhere later in the prompt.
- Put the cursor between those two spaces so there is a space immediately before the cursor and also a space at the cursor position.
- Type
@, then type a few characters so the completion menu stays filtered.- Select a completion.
Expected behavior:
- The completion menu should remain open while the typed query still matches results.
- Selecting a completion should replace the query cleanly.
- The inserted mention should end with exactly one trailing space.
- The caret should land immediately after that trailing space.
Known implementation context:
- Mention parsing/cursor logic lives in
apps/web/src/composer-logic.ts.- Lexical editor integration lives in
apps/web/src/components/ComposerPromptEditor.tsx.- Trigger detection and replacement flow live in
apps/web/src/components/ChatView.tsx.- The bug is likely another edge case where live trigger detection or replacement range calculation is using the wrong cursor coordinate system, or is not consuming an existing space under the cursor when inserting a completion.
Constraints:
- Preserve existing mention pill behavior.
- Do not regress cases where completion starts next to non-whitespace text.
- Add focused tests for the whitespace-started completion case and any cursor/spacing regression you fix.
- Finish by running
bun typecheck.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels