Repository navigation
fix(terminal): require agent identity for guarded sends (STA-4028) - #14092
Conversation
Quarter-circle spinner glyphs (U+25D0-U+25D3) started classifying a title as "working" in #13925, and that status alone authorized guarded agent sends — which auto-submit with Enter — into any pane whose TUI animates those generic progress frames. Keep the glyphs as an activity signal, but stop treating a title whose only agent evidence is a quarter circle as proof an agent owns the pane: send authorization now falls through to recognized-agent identity in the title or a recognized foreground process. Braille-spinner behavior is unchanged.
📝 WalkthroughWalkthroughThe change adds quarter-circle spinner-only title detection and re-exports it through the shared agent-detection module. Runtime checks now track PTY launch incarnations and require title, foreground-process, or verified launch evidence. Regression tests cover authorization, refusal cases, replacement PTY incarnations, braille spinners, and working-status classification. Reliability-gate records document the updated behavior and test evidence. Mergeability Score: 🟠 High · up to The change tightens guarded terminal sends, but the current code can still authorize spinner-only titles when process identity is missing or stale launch authority survives a provider replacement. That could send and auto-submit a prompt to the wrong process, so the PR is not merge-ready until these identity checks are fixed. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🔇 Additional comments (7)
src/main/runtime/orca-runtime.ts (3)
10-10: 🗄️ Data Integrity & Integration
⚠️ Unverified finding
Sandbox verification was unavailable.Verify the new import resolves from the compatibility barrel.
isQuarterCircleSpinnerOnlyAgentTitleis imported from../../shared/agent-detection. Confirm thatagent-detection.tsre-exports this symbol from the module that defines spinner-only title detection (per the PR stack's dependency on "Define spinner-only title detection").
16799-16814: LGTM!Also applies to: 37583-37608
31549-31566: LGTM!Also applies to: 31615-31623
src/main/runtime/quarter-circle-title-send-authorization.test.ts (3)
21-90: LGTM!
137-143: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
⚠️ Unverified finding
Sandbox verification was unavailable.Remove the duplicated
ptysByIdproperty in the type cast.The cast at lines 139-141 declares
ptysById: Map<string, { launchAgent: string | null; launchToken: string | null }>three times in a row inside the same object type literal. One declaration is enough. This looks like a copy-paste artifact rather than intended code.Keep one
ptysByIdline in the cast.♻️ Proposed cleanup
expect( ( runtime as unknown as { ptysById: Map<string, { launchAgent: string | null; launchToken: string | null }> - ptysById: Map<string, { launchAgent: string | null; launchToken: string | null }> - ptysById: Map<string, { launchAgent: string | null; launchToken: string | null }> } ).ptysById.get(PTY_ID) ).toMatchObject({ launchAgent: 'claude', launchToken: expect.any(String) })Run the following to confirm the actual file content at these lines:
131-136: LGTM!Also applies to: 144-162
config/reliability-gates.jsonc (1)
7536-7539: LGTM!Also applies to: 7544-7556, 7558-7565, 7633-7641, 7662-7666, 7679-7679
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bb655101-54d0-4f1f-a9a0-a567859868d7
📒 Files selected for processing (3)
config/reliability-gates.jsoncsrc/main/runtime/orca-runtime.tssrc/main/runtime/quarter-circle-title-send-authorization.test.ts
Electron QA (STA-4028) — both directionsIsolated dev instance from the QA canvas ( (A) DENY — spinner-only shell does not authorizeBefore (looks busy, no agent owner): a plain shell emitted OSC title After (send refused): (B) ALLOW — real managed Claude 2.1.228 still accepts while showing
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/main/runtime/orca-runtime.ts (2)
25784-25789: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy liftRequire a non-null incarnation before spinner-only title proof.
Legacy SSH
pty.spawnreplies can omitincarnationId. In that case,createTerminalstoreslaunchIncarnationIdasnull, andptyTitleProvesAgentPresenceacceptsnull === null. Set launch authority only whenpty.incarnationIdis non-null, and require that value in the predicate.
10465-10493: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy liftInvalidate launch authority on provider reset
When replacement output arrives before spawn reconciliation,
postSpawnSequence > 0skipsresetTrackedTerminalStateForProviderGeneration. The old launch fields andpty.incarnationIdthen remain active, so a spinner-only title can pass for the replacement process. Providers may also omitincarnationId, makingnull === nullpass. Require non-null matching incarnations and rebind launch authority only after the replacement identity is established.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ef141ea4-0f1f-41f3-9d69-5915b2645725
📒 Files selected for processing (3)
config/reliability-gates.jsoncsrc/main/runtime/orca-runtime.tssrc/main/runtime/quarter-circle-title-send-authorization.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/runtime/quarter-circle-title-send-authorization.test.ts
- config/reliability-gates.jsonc
…14092) * fix(terminal): require agent identity for guarded sends (STA-4028) Quarter-circle spinner glyphs (U+25D0-U+25D3) started classifying a title as "working" in #13925, and that status alone authorized guarded agent sends — which auto-submit with Enter — into any pane whose TUI animates those generic progress frames. Keep the glyphs as an activity signal, but stop treating a title whose only agent evidence is a quarter circle as proof an agent owns the pane: send authorization now falls through to recognized-agent identity in the title or a recognized foreground process. Braille-spinner behavior is unchanged. * fix(terminal): preserve verified managed busy identity * fix(terminal): bind busy identity to process incarnation * chore(test): avoid duplicate terminal gate suite (cherry picked from commit cb41f3c)
…tablyai#14092) * fix(terminal): require agent identity for guarded sends (STA-4028) Quarter-circle spinner glyphs (U+25D0-U+25D3) started classifying a title as "working" in stablyai#13925, and that status alone authorized guarded agent sends — which auto-submit with Enter — into any pane whose TUI animates those generic progress frames. Keep the glyphs as an activity signal, but stop treating a title whose only agent evidence is a quarter circle as proof an agent owns the pane: send authorization now falls through to recognized-agent identity in the title or a recognized foreground process. Braille-spinner behavior is unchanged. * fix(terminal): preserve verified managed busy identity * fix(terminal): bind busy identity to process incarnation * chore(test): avoid duplicate terminal gate suite (cherry picked from commit cb41f3c)
…tablyai#14092) * fix(terminal): require agent identity for guarded sends (STA-4028) Quarter-circle spinner glyphs (U+25D0-U+25D3) started classifying a title as "working" in stablyai#13925, and that status alone authorized guarded agent sends — which auto-submit with Enter — into any pane whose TUI animates those generic progress frames. Keep the glyphs as an activity signal, but stop treating a title whose only agent evidence is a quarter circle as proof an agent owns the pane: send authorization now falls through to recognized-agent identity in the title or a recognized foreground process. Braille-spinner behavior is unchanged. * fix(terminal): preserve verified managed busy identity * fix(terminal): bind busy identity to process incarnation * chore(test): avoid duplicate terminal gate suite (cherry picked from commit cb41f3c)
…tablyai#14092) * fix(terminal): require agent identity for guarded sends (STA-4028) Quarter-circle spinner glyphs (U+25D0-U+25D3) started classifying a title as "working" in stablyai#13925, and that status alone authorized guarded agent sends — which auto-submit with Enter — into any pane whose TUI animates those generic progress frames. Keep the glyphs as an activity signal, but stop treating a title whose only agent evidence is a quarter circle as proof an agent owns the pane: send authorization now falls through to recognized-agent identity in the title or a recognized foreground process. Braille-spinner behavior is unchanged. * fix(terminal): preserve verified managed busy identity * fix(terminal): bind busy identity to process incarnation * chore(test): avoid duplicate terminal gate suite









ELI5
Some agents draw a little spinning circle (
◐ ◑ ◒ ◓) in their terminal title while they think. We started reading that spinner as "an agent is running here," and that alone was enough to let Orca type a prompt into the pane and press Enter. But any program can draw those circles — an installer, a build script, a release tool. This PR keeps the spinner as a "something is happening" hint, but requires real proof of which program owns the pane before Orca is allowed to type into it.What Changed
isQuarterCircleSpinnerOnlyAgentTitle(title): true when stripping the quarter circles leaves a title with no agent evidence at all.OrcaRuntimeService.getTerminalAgentStatusno longer short-circuits toisRunningAgent: truefor such a title; it resolves through the same identity/foreground path already used for OpenCode markers.isTerminalRunningAgent/isPtyRunningAgentno longer accept a quarter-circle-only title as agent-presence evidence (via the newagentTitleProvesAgentPresencehelper, which also folds in the existing OpenCode check the four call sites duplicated).Unchanged on purpose:
detectAgentStatusFromTitlestill returnsworkingfor quarter circles, so the [Bug]: Chat UI falls back to CLI view on every message with Claude Code 2.1.228 (new busy title glyphs read as agent exit) #13889 status/UI fix stands.◐ Claude Code) still authorizes on its own; a task-text title (◑ Say hi in one word) authorizes once the foreground process is a recognized agent.Why
#13925 taught the title parser that
U+25D0–U+25D3mean "working" (Claude Code 2.1.228 swapped its busy spinner to quarter circles). That was correct as a status signal, butgetTerminalAgentStatustreats any non-null title status as proof an agent owns the pane, andassertTerminalAgentSendableauthorizes a guarded send onisRunningAgent. Guarded sends auto-submit with Enter, so a title like◑ Deploying release 4.2— from a release script,ora, or any TUI that animates those glyphs — was enough to inject a prompt and press Enter into a non-agent process.Quarter circles are ordinary progress glyphs in a way braille dots largely are not, so the safe rule is: glyph proves activity, identity must come from the title's agent token or the foreground process. That is exactly what the pre-#13925 code did for these titles (they classified as neutral and fell through to the foreground check), so this restores the prior authorization contract without reverting the status fix.
Linked Issue
STA-4028 — https://linear.app/stably/issue/STA-4028
Fixes the regression introduced by #13925.
Visual Proof
N/A— no UI change. The rendered agent status for a quarter-circle busy title is unchanged (stillworking, asserted in the new test); only the main-process send-authorization decision changed.Testing
New focused regression test:
src/main/runtime/quarter-circle-title-send-authorization.test.ts, driving the realOrcaRuntimeService+assertTerminalAgentSendable:◑ Deploying release 4.2with foregroundnode→isRunningAgent: false, guard throwsterminal_guard_no_agent(failed before this fix)terminal_guard_no_agent(failed before this fix)claude→ authorized,status: working(no false-negative for a real agent)◐ Claude Codewith no foreground read → authorized⠂ Deploying release 4.2→ authorized (braille behavior unchanged)detectAgentStatusFromTitlestill returnsworkingfor both quarter-circle titles ([Bug]: Chat UI falls back to CLI view on every message with Claude Code 2.1.228 (new busy title glyphs read as agent exit) #13889 intact)Commands actually run on macOS (Darwin 25.5.0):
Platforms: automated tests run on macOS. The change is pure title/string classification plus an existing foreground-process lookup, with no platform-conditional code paths, so Linux/Windows behave identically; the SSH / unreadable-foreground case is covered explicitly by a test rather than a live host.
AI Disclosure
N/A (internal).
Review
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm testpass locally (pnpm buildleft to CI)