Repository navigation
Description
Operating system: macOS
Orca version: 1.4.188
Summary
orca terminal read|show --terminal "" returns exit 0 and operates on a live pane instead of failing. The empty string is treated the same as omitting --terminal. Garbage / whitespace handles correctly fail with terminal_handle_stale (exit 1).
Documented behavior (live orca terminal read --help, 2026-08-27):
Omit
--terminalto target the active terminal in the current worktree.
That sentence is about omission. An explicit empty string is not omission. Scripts that do --terminal "$HANDLE" when HANDLE is empty therefore succeed against whichever pane Orca currently considers active in the worktree — which may be a different tab/pane than the calling process.
Environment
- Orca desktop 1.4.188 (from
orca status --json→runtime.appVersion) - macOS 26.5.1
- Worktree with at least two live panes (a leftover shell tab and an agent tab). Commands below were issued from the agent pane.
Repro
Use any Orca-managed worktree that has two live panes (different handles). Placeholders: term_A = the pane running the commands, term_B = the other live pane.
orca terminal list --worktree current --json
# note two handles, here called term_A (caller) and term_B (other pane / other tab)
# 1) omitted flag (documented)
orca terminal show --json
# exit 0; JSON handle == term_B in this run (worktree-active, not necessarily the caller)
# 2) explicit empty string (the bug)
orca terminal show --terminal "" --json
orca terminal read --terminal "" --limit 2 --json
# exit 0; ok=true; same handle as omitted (term_B), not an error
# 3) invalid handles (control — already fail closed)
orca terminal show --terminal "term_deadbeef" --json
orca terminal show --terminal " " --json
# exit 1; error.code == "terminal_handle_stale"
# 4) wait
orca terminal wait --terminal "" --for tui-idle --timeout-ms 800 --json
# exit 1; error.code == "timeout" (bound to a live pane, then timed out)
orca terminal wait --terminal "term_deadbeef" --for tui-idle --timeout-ms 800 --json
# exit 1; error.code == "terminal_handle_stale"Actual
| argv | exit | result |
|---|---|---|
show / read with --terminal omitted |
0 | live pane (here: not the caller) |
show / read --terminal "" |
0 | same pane as omitted |
show / read --terminal " " |
1 | terminal_handle_stale |
show / read --terminal term_deadbeef |
1 | terminal_handle_stale |
show / read --terminal <caller handle> |
0 | caller pane |
wait --terminal "" --for tui-idle --timeout-ms 800 |
1 | timeout (same class as omitted) |
wait --terminal term_deadbeef --for tui-idle --timeout-ms 800 |
1 | terminal_handle_stale |
In this measurement, empty/omitted resolved to a pane in a different tab than the process that issued the CLI command.
Expected
- Omitting
--terminalmay keep targeting the worktree-active pane (documented). --terminal ""and other empty/invalid values should fail closed (nonzero), same family asterminal_handle_stale.- A script must not be able to silently read or wait on the wrong pane because a variable expanded to empty.
Harm
Orchestration scripts commonly pass --terminal "$HANDLE". If the variable is empty, the CLI currently reports success and returns some other pane in the worktree. The caller can then treat that screen as the intended target (wrong agent, wrong tab). This is a diagnostic footgun: the failure mode looks like a successful read.
Workaround
- Treat empty handle as a script error before calling Orca (
[ -n "$HANDLE" ]). - Never omit
--terminalin multi-pane worktrees unless the worktree-active pane is truly intended. - Do not infer identity from “the command ran in this pane”; compare the returned
handleto the expected one.
Caveat (not probed)
terminal send / close / split / rename were not called with an empty handle, to avoid mutating another pane. Unknown whether the same fallback applies to those verbs.
Notes for Orca
Related-but-different public work: CLI already fails some missing-handle cases (e.g. create-without-handle). Empty string on read/show/wait still aliases to “omit”.
Activity
Cunninger commentedon Aug 27, 2026
Opened a fix in #16745 — empty
--terminalnow fails closed instead of silently targeting the worktree-active pane.Tauri-EPO commentedon Aug 31, 2026
Same flaw in
terminal send— and there it is a write, not a read (Windows, 1.4.193)This issue documents
terminal read|show.orca terminal send --terminal ""behaves identically, but the consequence is different in kind: instead of reading the wrong pane, it injects input into the wrong agent's terminal.Repro (Orca 1.4.193, Windows 11)
Exit 0,
accepted: true, and the response even reports the handle it silently chose — a pane the caller never named. Note that the returnedhandleis the only signal that anything went wrong;ok/accepted/bytesWrittenall look like success.What it cost in practice
An orchestration script of mine resolved a terminal handle from
orca orchestration worker-show --dispatch <id>, where the dispatch had already settled — in that stateterminalResource.terminalHandlecomes back absent, and the empty string propagated into--terminal "$HANDLE".Three payloads went to a pane I never addressed, which turned out to be another Claude Code session (a different orchestrator, working on different PRs in the same worktree):
testeSONDAaboveThat session replied to me out of band. It refused to execute and explained why, which is what prevented actual damage: it would have written a fix for the wrong PR into a worktree that already held its own uncommitted work, and in our setup the merge gate locates a lane by branch — two lanes sharing a worktree breaks that resolution. Its checks before refusing: the briefing file did not exist in its worktree, and the task id did not belong to its run.
So the failure mode for
sendis not "reads the wrong pane": it is cross-agent prompt injection that reports success. With autonomous agents on both ends, whether it causes damage depends on the receiver being suspicious enough to refuse.Suggested handling
Same as this issue asks for
read/show— reject an explicit empty string with the existingterminal_handle_stale-style error instead of treating it as omission. Forsendspecifically, I would argue an explicit empty handle should never fall back to an active pane at all, even if omission continues to: writing into an unnamed terminal has no safe default.Workaround on the caller side (in case it helps others): validate
^term_[0-9a-f-]{8,}$before sending, and compareresult.send.handlein the response against the handle you asked for — the response does carry enough information to detect the misdelivery after the fact.fix(cli): reject empty --terminal/--from handles instead of falling b…