Skip to content

[Feature]: Run ! shell commands in structured Claude chats, as the TUI does #32165

Open

Description

@jun-planfit

Problem or use case

In a Claude Code chat that runs as a structured chat (Claude launched with --input-format stream-json --output-format stream-json), a !-prefixed line does not run as a shell command. The composer sends !pwd as an ordinary prompt, and the model answers it in prose. Running the command takes a full model turn, and the result depends on the model choosing to call its Bash tool.

The same line does run in a terminal-backed chat, because the composer types it into the Claude TUI and the TUI's bash mode runs it (see #25956, fixed by #31204). So ! works or silently doesn't depending on which kind of chat the user opened, and the composer gives no hint which one it is.

Reproduction outside Orca (Claude Code 2.1.304):

printf '%s\n' '{"type":"user","message":{"role":"user","content":"!pwd"}}' \
  | claude -p --input-format stream-json --output-format stream-json --verbose --max-turns 1

No <bash-input> turn is recorded. The assistant replies with the working directory it read from its system context and says it did not run a shell.

On main (77f1523), classifyNativeChatSend in src/shared/native-chat-slash-commands.ts special-cases only / (and $ for Codex), and the structured send path has no ! handling either. src/shared/claude-bash-input.ts only displays <bash-input> turns that already exist in a transcript.

Orca 1.4.237, macOS.

Proposed solution

Support ! in structured Claude chats the way the TUI does:

  1. When a structured Claude chat's draft starts with !, Orca runs the rest of the line itself in the chat's cwd, using the shell environment structured chats already use (feat(native-chat): one shell-environment setting for every structured chat #22387), instead of sending it to the agent.
  2. The chat shows the command and its stdout/stderr as a command row.
  3. Orca passes the command and its output to the agent with the next message, in the same shape the TUI records (<bash-input> plus <bash-stdout>/<bash-stderr>), so the agent sees it as context without spending a turn on it.

If this is out of scope, a smaller step would help: when a structured chat's draft starts with !, show a hint that bash mode is only available in terminal-backed chats.

Alternatives or additional context

Workarounds today: open the conversation in a terminal tab and use the TUI's !, or ask the agent to run the command and wait for a turn.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions