Fix composer @ completion started in whitespace#1
Closed
Conversation
36f72eb to
ba598aa
Compare
Requirements and issue report: pingdotgg#291
ba598aa to
8f7ca4f
Compare
4 tasks
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
This fixes the remaining composer
@-completion bug described inpingdotgg/t3code#291.When
@completion is started inside existing whitespace, especially in prompts that already contain mention pills, the composer could mix collapsed mention-aware offsets with expanded text offsets. That caused three visible failures:Repro
@AGENTS.md.@.Root Cause
The composer still had a few paths that were not consistent about cursor coordinate systems:
1@path/to/filecounts by its full text lengthThat mismatch showed up in trigger detection, cursor restoration, prompt replacement, and a few state resets. In the whitespace-started case, it made the active trigger drift out of sync with what the user was actually editing.
Fix
composer-logic.ts, includingclampCollapsedComposerCursorandcollapseExpandedComposerCursorComposerPromptEditorsnapshots in both coordinate systems so callers can use the right cursor form for the right jobChatViewstate updates, trigger detection, and cursor restoration around collapsed cursor state plus expanded trigger positionsResult
After this change:
Testing
bun lintbun typecheckapps/web/src/composer-logic.test.ts