Skip to content

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

Merged
mbektas merged 1 commit into
plmbr:mainfrom
herikwebb:fix/slash-command-context-drop
Jul 14, 2026
Merged

fix(claude): preserve attachment context when the prompt is a slash command#388
mbektas merged 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!

@mbektas
mbektas merged commit 44cadad into plmbr:main Jul 14, 2026
4 of 5 checks passed
pjdoland added a commit to pjdoland/notebook-intelligence that referenced this pull request Jul 21, 2026
Main's plmbr#388 changed the Claude-mode join so that only control-only
commands (/clear, /compact, ...) drop the turn's context lines, while
every other command is hoisted to the front with the context preserved
as its arguments; the old drop-on-any-slash behavior silently discarded
what the user had just attached. The ACP join still mirrored the old
behavior. Adopt the same rule using the shared CONTROL_SLASH_COMMANDS
set (claude_sessions is SDK-free, so the lazy-import posture of this
module is unchanged), keeping the two agent modes' prompt assembly in
parity.
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