Skip to content

fix(terminal): frame CLI prompts for every recognized agent, not just Claude and Codex - #33571

Merged
nwparker merged 2 commits into
mainfrom
nwparker/agint-pty-submit-hookless
Oct 25, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/agint-pty-submit-hookless

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17

ELI5

When you run orca terminal send --text "…" --enter at a Claude or Codex pane, Orca pastes the text as one block and then presses Enter. For every other agent (Pi, Grok, Cursor, Gemini, …) it typed the text one key at a time instead. Agents react to typed keys. Pi opened a file-completion menu on #, so the Enter picked a file instead of sending the message. Grok's "trust this folder?" menu read the typed letters as an answer and quit. Now every recognized agent gets the paste-then-Enter path that orchestration dispatch already uses for all agents.

Root cause

isTerminalRunningSettledPromptAgent decides whether a CLI terminal send --text … --enter goes through sendTerminalAgentPrompt (bracketed paste, permission and trust guard, then Enter) or through the legacy sendTerminal path (raw keystrokes, then Enter). It only returned true for claude and codex. #14608 scoped it that way while the render gate was being validated per agent. The render gate is now limited to Claude/Codex inside createAgentPromptRenderGate, so other agents on the prompt path get the same pre-Enter delay as the raw path (resolveAgentPromptSubmitDelayForAgent). The only real difference is framing, plus the permission guard.

Upstream behavior that makes raw keystrokes unsafe:

  • Pi (@earendil-works/pi-tui 1.4.0, dist/components/editor.js:170): @ and # are autocomplete triggers. If typed text ends with #1542 the async completion runs, and the trailing Enter accepts the first entry (.git/). Bracketed paste is buffered whole into handlePaste (editor.js:571-583), so the trigger never fires. This is the variant @m11y described in [Bug]: worker-start --agent cursor reports ready while the brief sits unsubmitted in the composer #20695.
  • Grok Build 1.0.62 (xai-grok-pager/src/views/welcome/mod.rs:1018, xai-grok-permission-rules/src/folder_trust.rs:145): in a folder with repo config (e.g. CLAUDE.md), the welcome screen asks "Do you trust the contents of this directory?" with y/n hotkeys. Typed prompt text answers it. With the prompt path, Orca sees the menu and refuses with agent_prompt_blocked.
  • Cursor Agent 2026.10.22 (8116.index.js): the composer counts keys that arrive less than 35 ms apart and treats Return as a newline during such a burst. Raw typing goes through that heuristic, and a bracketed paste avoids it. This is the terminal send half of [Bug]: worker-start --agent cursor reports ready while the brief sits unsubmitted in the composer #20695. I did not run it live because there's no Cursor login on the test machine.

What changed

  • terminal-pane-mail-routing.ts: any agent that recognizeAgentProcess recognizes takes the prompt path. Unrecognized foregrounds, shells, and stale launch identity after the shell returns stay on direct input.
  • Agents whose process name also belongs to ordinary tools (orca/orca-dev → claude-agent-teams, acli → rovo, cn → continue, vibe → mistral-vibe; GENERIC_PROCESS_NAME_AGENTS in agent-process-recognition.ts) need a title or hook status before taking the prompt path. The foreground name alone keeps main's direct input. This reuses the existing title/hook presence check.
  • The new agent_prompt_blocked refusal tells the caller how to answer the menu ("send --text and --enter as separate commands", in terminal-prompt-mutation-recovery.ts). The shipped orca-cli guide (skill-guides/orca-cli.md, regenerated into bundled-skill-guides.ts) says the same.
  • The test for "recognized non-target agent stays legacy" is flipped. Pi, Grok and Gemini are now in the positive-identity cases, which fail on main.

How verified

Real CLIs, isolated HOME/GROK_HOME/PI_CODING_AGENT_DIR, and a local fake OpenAI-compatible model server (no spend). Driven through a background E2E Electron build (ORCA_BACKGROUND_LAUNCH=1) with the public CLI (orca-dev terminal send / orchestration dispatch --inject / worker-start):

Scenario main this PR
Pi 1.4.0 terminal send --text <prompt ending "#9838 for details. "> --enter composer becomes … details. .git/, 0 model requests, receipt accepted (1/1 Orca, 2/2 direct PTY) submitted 3/3
Grok 1.0.62 terminal send while the folder-trust menu is up typed text answers the menu and Grok quits to the shell refused agent_prompt_blocked … to answer it, send --text and --enter as separate commands, Grok still on the trust menu
Grok terminal send (ready composer) submitted 3/3 submitted 3/3
Pi / Grok orchestration dispatch --inject submitted 3/3 each submitted 3/3 each
Pi worker-start --agent pi submitted 3/3 submitted 3/3
  • pnpm tc ✅, pnpm run check:code-quality:changed ✅
  • pnpm test src/main/runtime/rpc src/main/runtime/terminal src/main/runtime/orchestration src/main/runtime/orca-runtime.test.ts: all passed (5982 + 1511 tests)

Risk / trade-offs

  • For non-Claude/Codex agents, terminal send --text … --enter now sanitizes ESC to a visible <ESC>, the same as Claude/Codex and Dispatch. Callers that used --text --enter to inject escape sequences into those agents must send them without --enter (raw channel, unchanged).
  • A send into an agent showing a trust/permission menu now fails with agent_prompt_blocked (with the hint above) instead of typing into the menu.
  • Rovo, Continue, Mistral Vibe and Claude agent teams take the prompt path only when Orca has a title or hook status for them. Without one, they keep direct input as on main.
  • Pre-Enter timing is unchanged for these agents (no render gate). Text-only, bare Enter, interrupt, mobile, and query-reply sends are unchanged.
  • Remote/mixed versions: the decision runs on the host runtime, so older hosts keep direct input. No protocol change.

Not in this PR (still open, needs a login we don't have)

Refs #20695, #18399

… Claude and Codex

orca terminal send --text ... --enter typed the prompt as raw keystrokes into
Pi, Grok, Cursor and other agents. Pi's composer opened a # completion menu and
the Enter accepted it, and Grok's folder-trust menu took the typed letters as
its answer and quit. Recognized agents now take the same bracketed-paste prompt
path orchestration dispatch already uses, which also refuses a prompt while a
trust/permission menu is up.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The settled-prompt authorization check now allows any foreground process recognized by recognizeAgentProcess to proceed through the existing presence check. For agents with generic process names, the foreground process does not serve as presence proof. Tests cover Pi, Grok, and Gemini as positive identities, and check that bare Orca, ACLI, CN, and Vibe names do not authorize delivery. Terminal-send recovery and CLI guidance describe the separate --text and --enter commands required when a prompt is blocked by a permission or trust menu.

Priority: Normal

Merge Risk: Moderate · up to c1e16

A prompt could be delivered to an ordinary process when a different agent’s title remains on its terminal. Match the presence evidence to the foreground agent before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: routing CLI prompts for every recognized agent instead of only Claude and Codex.
Description check Passed The description is detailed and covers the user impact, root cause, implementation, testing, risks, trade-offs, and out-of-scope work. It does not provide a formal issue link in the required "Fixes #"…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the user impact, root cause, implementation, testing, risks, trade-offs, and out-of-scope work. It does not provide a formal issue link in the required "Fixes #" section, and several checklist items remain unchecked, but the description is otherwise mostly complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…nd keep generic process names on direct input

agent_prompt_blocked from terminal send now says to answer the menu with
separate --text and --enter sends, and the orca-cli guide says the same.
Foregrounds named orca, acli, cn or vibe also belong to ordinary tools, so they
take the prompt path only when a title or hook status proves the agent.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 20b354c6-f52a-4a69-bd02-ae1f1b5acafe
Commits

Reviewing files that changed from the base of the PR and between 70c3005 and c1e163b.

Files selected for processing: 6
  • skill-guides/orca-cli.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/runtime/terminal-prompt-mutation-recovery.ts
  • src/main/runtime/orca-runtime-tests/terminal-handles-and-agent-status-part-02.spec.ts
  • src/main/runtime/orchestration/terminal-pane-mail-routing.ts
  • src/shared/agent-process-recognition.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment on lines +143 to +145
const proof = agent && GENERIC_PROCESS_NAME_AGENTS.has(agent) ? null : foregroundProcess
const presence = { retryForegroundWrappers: false, foregroundProcess: proof }
if (agent === undefined || !(await this.isTerminalRunningAgent(handle, presence))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Heavy lift

🔎 Supported by static analysis

Script executed:

#!/bin/bash
# Inspect recognition and the presence check without running repository code.
ast-grep outline src/shared/agent-process-recognition.ts --match 'recognizeAgentProcess|GENERIC_PROCESS_NAME_AGENTS'
rg -n -C 5 'terminalAgentPresence|class .*AgentPresence|isRunning\(' src/main/runtime
rg -n -C 5 'foregroundProcess|paneTitle|hook' src/main/runtime/orca-runtime-tests/terminal-handles-and-agent-status-part-02.spec.ts

Repository: stablyai/orca

Length of output: 24480


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- terminal-pane-mail-routing ---'
nl -ba src/main/runtime/orchestration/terminal-pane-mail-routing.ts | sed -n '105,160p'
printf '%s\n' '--- runtime-terminal-agent-presence ---'
nl -ba src/main/runtime/runtime-terminal-agent-presence.ts | sed -n '1,260p'
printf '%s\n' '--- recognition definitions ---'
nl -ba src/shared/agent-process-recognition.ts | sed -n '1,230p'
printf '%s\n' '--- targeted presence tests ---'
nl -ba src/main/runtime/orca-runtime-tests/terminal-handles-and-agent-status-part-02.spec.ts | sed -n '285,350p'

Repository: stablyai/orca

Length of output: 26727


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- generic process mappings ---'
rg -n -C 8 -F -e "'orca'" -e "'acli'" -e "'cn'" -e "'vibe'" -e "claude-agent-teams" -e "rovo" -e "continue" -e "mistral-vibe" src/shared/tui-agent-config.ts src/shared/agent-process-recognition.ts
printf '%s\n' '--- title proof declarations and implementations ---'
rg -n -C 12 -F -e 'function ptyTitleProvesAgentPresence' -e 'function agentTitleProvesAgentPresence' -e 'export function ptyTitleProvesAgentPresence' -e 'export function agentTitleProvesAgentPresence' src/main/runtime/runtime-worktree-status-projection.ts
printf '%s\n' '--- title classification declarations ---'
rg -n -C 8 -F -e 'export function classifyAgentTitle' -e 'export function classifyLatestAgentTitle' src/main/runtime/runtime-worktree-status-projection.ts

Repository: stablyai/orca

Length of output: 14638


Require presence evidence to match the recognized agent.

orca, acli, cn, and vibe map to generic agent IDs. The settled-prompt path removes foreground proof for these agents. RuntimeTerminalAgentPresence.isRunning can then return true from any recognized pane or PTY title without matching that title to the recognized foreground agent. A different agent title can therefore authorize settled-prompt delivery for an ordinary generic process. Require title or hook evidence to match the recognized agent, and add a regression test for mismatched evidence.

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