fix(composer): detect slash-command trigger mid-prompt, not just at line start - #5206
fix(composer): detect slash-command trigger mid-prompt, not just at line start#5206matdac12 wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved 8dab2ca This is a self-contained bug fix extending slash-command detection to work mid-prompt. The change reuses existing token extraction logic, is well-tested with edge case coverage, and only affects UI autocomplete behavior. You can customize Macroscope's approvability policy. Learn more. |
…ine start detectComposerTrigger only recognized "/" when it was the first character of the current line, while "$skill" and "@path" use whitespace-delimited token detection that works anywhere in the text. Typing "/command" in the middle of a prompt therefore never opened the command/skill menu. Add a "/" branch to the same token scanner in both copies of the logic (web composer-logic.ts and shared composerTrigger.ts, the latter keeping its slash-model special case). Line-start behavior, /model with arguments, and non-triggers like "src/components" or URLs are unchanged.
8dab2ca to
0648af7
Compare
What changed
detectComposerTriggeronly recognized/when it was the very first character of the current line (linePrefix.startsWith("/")), while$skilland@pathuse whitespace-delimited token detection that works anywhere in the text. Typing/commandin the middle of a prompt therefore never opened the command/skill menu — only starting the message with it did.This adds a
/branch to the same token scanner the$trigger uses, in both copies of the logic:apps/web/src/composer-logic.ts(web)packages/shared/src/composerTrigger.ts(mobile — keeps itsslash-modelspecial case, so a mid-prompt/modelopens the model picker just like at line start)Why
Slash commands behave inconsistently with the other two composer triggers:
fix the tests $my-skillautocompletes, whilefix the tests /reviewsilently does nothing.Behavior preserved
/model <args>on mobile still works via the existing line-prefix branch."/model spark"still yields no trigger (existing test unchanged).src/components,https://…) do not trigger, since the token must start with/.Tests
Added unit tests for mid-prompt
/command, bare/, mid-prompt/model(shared), and the non-trigger cases above, incomposer-logic.test.tsandcomposerTrigger.test.ts(the latter previously had nodetectComposerTriggercoverage). Full unit suites of@t3tools/web(1769 tests) and@t3tools/shared(323 tests) pass.