Skip to content

fix(composer): detect slash-command trigger mid-prompt, not just at line start - #5206

Open
matdac12 wants to merge 1 commit into
pingdotgg:mainfrom
matdac12:fix/mid-prompt-slash-command-trigger
Open

fix(composer): detect slash-command trigger mid-prompt, not just at line start#5206
matdac12 wants to merge 1 commit into
pingdotgg:mainfrom
matdac12:fix/mid-prompt-slash-command-trigger

Conversation

@matdac12

@matdac12 matdac12 commented Aug 1, 2026

Copy link
Copy Markdown

What changed

detectComposerTrigger only recognized / when it was the very first character of the current line (linePrefix.startsWith("/")), 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 — 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 its slash-model special case, so a mid-prompt /model opens the model picker just like at line start)

Why

Slash commands behave inconsistently with the other two composer triggers: fix the tests $my-skill autocompletes, while fix the tests /review silently does nothing.

Behavior preserved

  • Line-start detection is untouched (the existing line-prefix branch still runs first).
  • /model <args> on mobile still works via the existing line-prefix branch.
  • "/model spark" still yields no trigger (existing test unchanged).
  • Tokens merely containing slashes (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, in composer-logic.test.ts and composerTrigger.test.ts (the latter previously had no detectComposerTrigger coverage). Full unit suites of @t3tools/web (1769 tests) and @t3tools/shared (323 tests) pass.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 06acfdd9-f750-4d77-96e3-b5b2b213c9fe

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Aug 1, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.
@matdac12
matdac12 force-pushed the fix/mid-prompt-slash-command-trigger branch from 8dab2ca to 0648af7 Compare August 1, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant