Uh oh!
There was an error while loading. Please reload this page.
fix(claude): expand slash commands when a message has attachments - #8271
fix(claude): expand slash commands when a message has attachments#8271lnieuwenhuis wants to merge 3 commits into
Conversation
The Claude CLI only treats a streamed user message as a slash-command invocation when the final content block is text; earlier blocks ride along as preceding input blocks and survive the expansion. The adapter appended image blocks after the text, so any turn carrying an attachment lost the command silently. Send the text block last so an image never displaces it.
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 at Macroscope's review found this PR approvable — This is a focused Claude adapter bug fix that places image blocks before the final text block so existing slash commands continue to expand when attachments are present. The production impact is limited to Claude message ordering, with targeted regression coverage and no broader API, infrastructure, or default-setting changes. You can add or adjust custom eligibility rules. Learn more. |
…ith-attachments # Conflicts: # apps/server/src/provider/Layers/ClaudeAdapter.ts
Dismissing prior approval to re-evaluate a1b9f67
t3dotgg
commented
Sep 3, 2026
Note 🤖 Claude Fable 5.1 responding on behalf of Theo Closing in favor of #9122, which just merged. It is this same fix rebased onto main, with your commit and authorship kept. The rebase needed a one-line test fix because |
With the Claude provider, sending
/skill-name argsexpands the command normally, but the identical message with any image attached silently does not expand: the agent receives the literal string plus the image, with no<command-name>, no skill body, and no error anywhere in the UI.Root cause
It is on our side, not in the
claudeCLI.The CLI accepts slash commands alongside images, but only when the last content block of the streamed user message is text. Reading the CLI bundle (verified in both 2.1.234 and 2.1.246), the stream-json input handler does:
precedingInputBlocksis then carried through the expansion, so the image is preserved in both the command message and the expanded skill content.buildUserMessageEffectin the Claude adapter pushed the text block first and appended image blocks after it. With no attachment the single text block is last and expansion works; with any attachment the last block is an image,inputStringstaysnull, and the turn falls through to the plain-prompt path. That is exactly the reporter’s isolation table: only the attachment variable matters.Fix
Emit the image blocks first and the text block last. This also matches Anthropic’s recommended image-before-text ordering, so it is a single code path with no special case for command-looking text.
Other providers
Unchanged, and not affected by this defect. Codex passes prompt text and attachments as separate fields to the codex app-server. Cursor and Grok go over ACP
session/prompt, and OpenCode over its own parts API; none of them route prompt text through the Claude CLI’s slash expander, so block ordering has no equivalent meaning there.Verification
vp test run apps/server/src/provider/Layers/ClaudeAdapter.test.ts— 79 passed. The new regression test asserts the adapter produces the same trailing/flow-patterns hellotext block with and without an image attachment; it fails on the pre-fix adapter and passes after.vp test run apps/server/src/provider/Layers/ProviderService.test.ts— passed.vp run --filter t3 typecheck— 0 errors.vp lintandvp fmt --checkon the two touched files — clean (one pre-existing unrelated warning elsewhere in the file).Fixes#8013
Implemented with Claude Opus via the Claude Code harness.
Note
Low Risk
Narrow change to Claude user-message block ordering with targeted tests; fixes incorrect behavior without touching auth or other providers.
Overview
Fixes a silent failure where Claude slash commands (e.g.
/flow-patterns hello) stopped expanding when an image was attached—the agent got literal text plus the image with no error.buildUserMessageEffectnow emits image blocks before the final text block. The Claude CLI only treats streamed input as a slash command when the last content block is text; putting text first meant any attachment made the last block an image and skipped expansion.Skill-dispatch behavior is unchanged in intent: optional leading prose, images in the middle, then trailing command or plain text. Tests add
readPromptMessages, expect image-then-text for image turns, and regress on command + attachment ordering.Reviewed by Cursor Bugbot for commit a1b9f67. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix Claude slash command expansion when message has image attachments
buildUserMessageEffectin ClaudeAdapter.ts, image attachment blocks are now emitted before the command or prompt text block, so the dispatched slash command is the final content block.readPromptMessageshelper to inspect multiple queued prompt messages.Macroscope summarized a1b9f67.