Skip to content

feat(threads): add shell input to thread composers - #194

Merged
nixuuu merged 1 commit into
devfrom
feat/composer-shell
Nov 5, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/composer-shell

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 5, 2026

Copy link
Copy Markdown
Member

Typing ! at the start of a message turns the thread composer into shell mode. The command runs on the thread's worker, and the agent gets its output.

Composer

  • A leading ! gives the composer a rose border and the hint "Runs as a shell command when delivered.". Removing the ! leaves shell mode.
  • Sending works as for a normal message: send, steer or queue.

When the command runs: at delivery, not when it is typed.

  • On an idle thread it runs immediately and starts the turn.
  • A queued shell message runs when it leaves the queue.
  • A steer runs at the moment it is delivered into the running turn.

Where it runs: on the thread's worker, in the thread's workspace or worktree directory, through the user's login shell. stdin is closed, so interactive commands get EOF.

Limits

  • Timeout of 120 s.
  • 64 KiB of output: the head and the tail are kept, with a marker for the omitted middle.
  • Stop and the timeout kill the whole process group.

What the agent receives: a marked block, not the raw !command:

  • the command and the working directory;
  • the status and the exit code;
  • stdout and stderr in the order they were read.

The block states that the output is untrusted data.

Timeline: a distinct "Shell command" card, with:

  • the command in a monospaced font and an exit-code badge;
  • the first lines of output, plus "Show output";
  • "Full text the agent received".

Safety and durability

  • Only the thread's owner can run a command, and threads on linked computers are routed to their home gateway.
  • The agent's approval policy does not apply, because the command is the owner's explicit action.
  • Results are stored with the turn input.
  • After a gateway or worker restart, a command that was running ends as interrupted and is never re-run.
  • An older worker without the capability returns a readable error.

Contracts: additive fields in proto/canopy/ui/v1/gateway.proto and proto/canopy/worker/v1/worker_link.proto, plus capability negotiation.

Tests

  • tests/integration/composer-shell.test.ts (17 tests):
    • idle sends, queue order and steer timing;
    • the timeout, Stop and the output cap;
    • restart recovery without a re-run;
    • owner scoping and older workers;
    • Claude, Codex and Grok adapters.
  • composer-shell-linked.test.ts and shell-recovery.test.ts.
  • check:tmp: 1294 passed, 0 failed.

Copy audit (§8):

  • Sentence case and explicit timing ("when delivered").
  • Errors that say what to do.
  • Exit status shown as text, not colour alone.

Screenshots were checked in light and dark mode, at desktop and phone width, with long commands and with failing commands.

Not verified: live providers, and runs on macOS or Windows.

@nixuuu
nixuuu merged commit 7974d09 into dev Nov 5, 2026
9 checks passed
@nixuuu
nixuuu deleted the feat/composer-shell branch November 5, 2026 15:50
nixuuu added a commit that referenced this pull request Nov 5, 2026
A message sent to an idle thread no longer flashes in the queue panel
before it starts. It goes straight to the timeline as "Starting".

**Cause:** `SendMessage` published the new turn as `queued` before it
was dispatched, and the web listed every queued turn in the queue panel
until the worker reported `running`. Dispatch itself sent no update.

**Fix**
- **Gateway:** an idle message and its worker command are saved and
published together (`coreEnqueueTurn`), and dispatch now sends an
update. New fields (additive): `Turn.dispatched` and
`Thread.turn_starting`, both filled from the same dispatched condition.
- **Web:** a queued turn that is already dispatched counts as starting.
It shows "Starting" in the timeline, and the queue panel, its counters
and its edit, reorder and remove actions leave it out.
- **Steer:** a dispatched, starting turn is a valid steer target. The
worker still decides whether to accept the steer; if it refuses, the
message falls back to a real queued message. Without this, a shell steer
(#194) sent during that window was queued instead of steered.

**Tests:** `tests/integration/queue-dispatch.test.ts` covers:
- an idle send that is dispatched from its first visible state;
- a busy send that stays queued until its turn comes;
- queue conflicts on a dispatched turn;
- steer fallback;
- older clients.

The composer shell suite passes unchanged (17/17). `check:tmp`: 1321
passed, 0 failed.

Checked in a browser (recording and screenshots) for an idle send, a
send while a turn runs, and the hand-off to the next queued message.

Copy audit: "Starting" is an existing status label.

The flash has been there since the queue panel was added, so there is no
fix link.
nixuuu added a commit that referenced this pull request Nov 5, 2026
…231)

Stage 5 of 5, mobile UX: catch up with recent web features in the thread
view.

**Done**
- Full access with confirmation.
- The work group is open while the agent works and collapsed after the
turn (the default fold behaviour from #195).
- Tighter work rows in the `work` scale; commands in monospace.
- The shell command card and `!` mode in the composer (#194).
- "Starting" for a dispatched queued turn (#197).
- File badges in the message bubble.
- Finished subagents collapse into one count that opens the lineage
panel (#182).
- The type scale for overlays, chrome, work rows and the context row
(#174/#193).
- Rejected messages show their reason, instead of a generic retry note.

**Deferred**
- The work fold settings (per device on the web).
- Badges placed inline in the text and queue editing (#200/#201); files
stay as chips.
- Linked computers in pickers (needs `LinkedComputerSnapshot` merging).
- Worktree and ref in a new thread.
- Approval countdown and expiry cards.
- Connector errors.
- Mentions, side threads and goal editing.

**Checked** on the Android emulator, light and dark. `check:tmp`: 1425
passed, 0 failed. `expo lint` and `tsc` are clean.

**Copy audit (§8):**
- "Runs as a shell command when delivered."
- "Starting"
- "N finished subagents"
- "Set and manage goals in Canopy on the web."
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.

1 participant