Skip to content

Composer ! shell mode: run a command in the worktree without a model turn (#470) - #1668

Merged
currentbits merged 2 commits into
mainfrom
coder/composer-shell-mode-run-a-command-in-the-069a4b
Oct 18, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/composer-shell-mode-run-a-command-in-the-069a4b

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Typing !npm test (or !gh pr checks, !git status) in the composer now runs the line with sh -c in the thread's checkout. There's no model turn. Output streams into a card on the thread that ends with the exit code. This matches the ! habit from Claude Code, Grok and Kimi, so one-off commands no longer cost a turn or a trip to a terminal. Closes #470.

Changes

  • Composer ! mode: a leading ! gives the box a green edge, a monospace font and a hint line. Enter, Cmd+Enter and Alt+Enter run the command and never send, steer or queue a prompt, even while the thread is busy. Context chips and attachments stay for the next prompt. If a command can't start, the line goes back into the box with the error. Ask threads don't get !.
  • Live card: one transcript event per command, updated every 250ms while it runs, then finished with the result, e.g. $ npm test · exit 1 · 0.8s. Shell cards open by default. Copy and Add to prompt (the existing P2: Make quick-action output inspectable and reusable in the composer #1216 path) give the next prompt the output.
  • Runner: threads.runCommand takes a new command field and reuses the quick-action runner. That brings the existing guards: one command at a time per thread, refused while the agent runs, and web access already gated under terminal:type. Hard 60s cap. Commands over 500 characters are refused instead of silently cut short.

Verification

  • New electron test: a real /bin/sh run (printf first; sleep 1; printf second; exit 3) shows partial output reaching the card before exit, start and end sharing one event, and the exit code. A fake-runner test checks the 60s cap and the refusals for empty, over-long and mid-run commands.
  • New composer tests: ! while busy on a steer-capable provider calls the shell path only (no send, no steer); a failed start restores the line; !text without the shell hook stays a normal prompt.
  • After rebasing on 39356293:
    • typecheck and vite build pass;
    • composer 122/122, threadView 116/116 and project-commands 18/18 pass;
    • the full electron suite (CI-like env) is 4892 pass, 1 fail. The failure is a teardown ENOTEMPTY rmdir in worktrees-searchfiles.test.js, which this PR doesn't touch, and it passes 5/5 alone.
  • Not tested: clicking through it in the packaged app.

Notes for reviewers


claude-opus-5-5 via Claude Code

🤖 Generated with Claude Code

…turn (#470)

A leading ! turns the draft into a shell line. Enter runs it with sh -c in
the thread's checkout through the quick-action runner (60s cap, one command
per thread, refused during a run). Output streams into a single transcript
card that ends with the exit code, with Copy and Add to prompt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T20:26:05.802701Z dbd85d2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@currentbits
currentbits enabled auto-merge (squash) October 18, 2026 20:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbd85d2a60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1122 to +1124
writeDraft("");
try {
await onShell(command);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prevent model turns while a shell command is running

While onShell is awaiting a potentially 60-second command, sending remains false and the cleared composer accepts and submits a normal prompt. The command path only checks whether an agent was active when the shell command started, while electron/runner.js waits only for pendingSetup, so the new model turn can run concurrently in the same checkout. For example, sending a prompt during !npm test lets the agent edit files underneath the test and makes its result unreliable; keep shell execution in a pending state that blocks or queues model turns until it settles.

Useful? React with 👍 / 👎.

Comment on lines +1930 to +1931
Shell: Enter runs this in the thread&apos;s checkout, no model
turn. 60s limit.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make bare Enter execute shell lines

With the default coder.enterSends preference set to false, the existing keyboard handler only submits on modified Enter or Shift+Enter, so pressing the bare Enter advertised here merely inserts a newline into !command. This breaks the primary shell-style interaction for default installations; special-case shellMode in the Enter handler so bare Enter runs the command while still respecting IME composition.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit b3ca41a into main Oct 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Composer ! shell mode: run a command in the worktree without a model turn

1 participant