Repository navigation
#750 Run shell commands (!cmd) from the composer - #769
Merged
Merged
Conversation
A draft whose first character is ! enters shell mode: the ! is highlighted,
a selected Shell badge replaces the model and agent chips (tap to leave),
and Send runs the command through POST /session/{id}/shell (v1, with agent
and model) or POST /api/session/{id}/shell (v2, command only) instead of
sending a prompt. Output arrives through the existing shell rendering.
Failures restore the draft and show the error like a failed prompt; shell
commands are never queued.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Real v2 servers send session.shell.started/ended as {shell: Info}; the
adapters only understood a flat shape no server sends, so a v2 shell never
appeared live and left a synthetic busy status behind. Project the nested
shape like the REST shell item (user command + Shell row keyed by the
started envelope id), with output and exit code on end, and leave the
session status alone. A synthetic inbox item (the server's shell-result
notification) no longer shows as a waiting steer prompt.
Shell mode turns off autocorrect, smart dashes/quotes and capitalization,
and typed text no longer inherits the highlight of the ! before it (iOS).
Both protocols hold the shell request until the command ends, so v2 also
uses the long request path on iOS.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ivanfenenko
marked this pull request as ready for review
October 20, 2026 18:17
Collaborator
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c571b21. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
!is a shell command: the!is highlighted, a selected Shell badge replaces the model/agent chips (tap it to drop the!), attachments are disabled, and Send (labelled "Run shell command") runs the command instead of sending a prompt. Leading whitespace (!ls) or a!later in the text stays a prompt; a bare!sends nothing; multi-line drafts run as one script. In shell mode the text field turns off autocorrect, auto-capitalization and smart quotes/dashes, so--onelineis not turned into—oneline.POST /session/{id}/shell {agent, command, model}. v2:POST /api/session/{id}/shell {command}, without switching the session agent or model first (as the TUI does). Both servers hold the request open until the command ends, so both use the long prompt-send timeout. The composer doesn't wait for the response, so you can keep typing while a long command runs.409 SessionBusyErrorand shows "Session is busy". On v2 the server runs shell commands alongside the agent, so there is no busy error. If you've set Queue as the follow-up mode and the session is busy, the app refuses the command with a message, because shell commands can't be queued (same rule as the web app and TUI).session.shell.*shape that no server sends. Real v2 events (beta and dev) carry{shell: Info}and no message id. So a v2 shell run never appeared live, and it left behind a fakebusystatus that nothing cleared.shell.startednow produces the same items as the RESTshellmessage (the command, then a Shell row under<id>:assistant, keyed by the started envelope id).shell.endedadds the output and exit code, and the session status is left alone. The REST projection now also includes the command as tool input and the exit code, so a failed command shows "Exited with code N" on both paths.syntheticinbox item with the output in the queue (it's delivered with your next prompt). That item showed up as an empty pending steer prompt. Synthetic inbox items are no longer marked as waiting or queued.!(or right after a mention) turned the highlight color.!command does not commit a staged revert. This matches the TUI (prompt/index.tsxcommits only on the prompt path) and the web app (composer/submit.tssendsshellwithoutrevert.commit). The shell branch returns before #751 Commit staged revert before sending a prompt on v2 #757'sbeforePrompthook, and a test on each platform pins this. On v1 the server cleans up the revert itself when a shell runs.Checks
./gradlew :app:testDebugUnitTestpasses on the merged tree (2,315 tests, 0 failures, 1 skipped as before).:app:assembleDebugand:app:assembleDebugAndroidTestbuild.ktlintCheck: no violations on lines this PR adds (existing violations elsewhere are unchanged).OpenCode MobileTeststarget on a dedicated iPhone 17 / iOS 26.5 simulator passes on the merged tree (2,225 Swift Testing tests in 220 suites + 76 XCTest, 0 failures).!parsing (bare!, whitespace-only, leading whitespace,!later in the text, multi-line,!!, leaving shell mode)!, prompt with leading space, busy error restores the draft and shows the snackbar, leaving shell mode, staged revert left aloneshell.started/endedprojection, ended without a started event, synthetic inbox item not waitingdevbc5ebf00a4), on the iOS simulator and the Android emulator. All four combinations: shell mode, run + live output, output sheet, v1 busy 409 → snackbar + restored draft, v2 non-zero exit, leaving shell mode, v2 reopen from history.Evidence
iOS · v1
iOS · v2
Android · v1
Android · v2
Issue
Risks / Follow-ups
devbc5ebf00a4. Beta uses the same{shell: Info}event schema (checked in the source), but I didn't run it live./api/shell*commands are out of scope, as the issue says.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmithwith what you need.Note
Medium Risk
Touches composer submit paths, protocol-specific HTTP, and event projection for session timelines on both platforms; incorrect shell or inbox handling could mis-render live chat or run commands unexpectedly, though behavior is heavily unit-tested.
Overview
Adds shell mode to the session composer on iOS and Android: a draft that starts with
!runs the remainder as a session shell command instead of a prompt. The UI highlights the prefix, shows a Shell badge (tap to exit shell mode), disables attachments, uses literal keyboard input, and labels Send as Run shell command. Submit routing calls newrunShellCommandAPIs—v1POST …/shellwith agent/command/model and v2 with command only (no agent/model switch)—using long-lived request handling like prompt send; failures restore the draft like a failed prompt, and queued follow-up while busy is blocked for shell.Live timeline and history are updated for real v2
{shell: Info}events:shell.started/endedproject user command + bash tool rows (with output and exit code) without spurious session busy; REST shell items gain command input and exit metadata. Synthetic inbox items from shell output no longer show as waiting steer prompts.iOS also fixes mention/shell highlight bleed when typing after a highlighted character.
Reviewed by Cursor Bugbot for commit c571b21. Bugbot is set up for automated code reviews on this repo. Configure here.