Skip to content

fix(claude): preserve attachment context when the prompt is a slash command#388

Open
herikwebb wants to merge 1 commit into
plmbr:mainfrom
herikwebb:fix/slash-command-context-drop
Open

fix(claude): preserve attachment context when the prompt is a slash command#388
herikwebb wants to merge 1 commit into
plmbr:mainfrom
herikwebb:fix/slash-command-context-drop

Conversation

@herikwebb

Copy link
Copy Markdown
Contributor

Problem

The CLI query assembly kept only the last user line whenever it started with /, silently discarding the context lines NBI had just appended for the same turn (attachment @-mentions, cell pointers, output context) — the footgun previously documented in extension.py's on_message.

Change

  • Extracted the join into assemble_client_query:
    • control-only commands (/clear, /cost, ...) still drop the context — it is meaningless to them;
    • any other command is moved to the front of the query (the CLI only recognizes a command at the start) with the context lines preserved after it, so custom skill/plugin commands receive the user's attachments.
  • Promoted claude_sessions' control-command set to a public name (CONTROL_SLASH_COMMANDS, adding /context) and reuse it as the single source of truth; the private alias remains for compatibility.
  • 7 unit tests, including a guard that the hidden plan-mode aliases still lead the query.

Testing

  • Full Python suite passes (1300 tests).
  • Manually verified in JupyterLab with a custom /nbi-echo command: an NBI-appended context line (current-directory pointer) that main drops for a slash-command turn now rides through into the command's $ARGUMENTS, confirming the context is preserved.

…ommand

The CLI query assembly kept only the last user line whenever it started
with '/', silently discarding the context lines NBI had just appended
for the same turn (attachment @-mentions, cell pointers, output
context) — the footgun previously documented in extension.py's
on_message.

Extract the join into assemble_client_query: control-only commands
(/clear, /cost, ...) still drop the context since it is meaningless to
them, while any other command is moved to the front of the query (the
CLI only recognizes a command at the start) with the context lines
preserved after it, so custom skill and plugin commands receive the
user's attachments. Promote claude_sessions' control-command set to a
public name (adding /context) and reuse it as the single source of
truth.
@pjdoland pjdoland added the bug Something isn't working label Jul 9, 2026

@pjdoland pjdoland left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice fix for the context-dropping footgun. The control-command allowlist plus front-hoisting is a clean approach, and I appreciate the documented rationale and the manual verification that the context now rides through into the command arguments.

@mbektas mbektas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants