Skip to content

fix(cli): infer launchAgent when terminal create runs an interactive agent command - #18020

Open
Tauri-EPO wants to merge 2 commits into
stablyai:mainfrom
Tauri-EPO:Tauri-EPO/terminal-create-launch-agent
Open

Tauri-EPO wants to merge 2 commits into
stablyai:mainfrom
Tauri-EPO:Tauri-EPO/terminal-create-launch-agent

Conversation

@Tauri-EPO

Copy link
Copy Markdown
Contributor

ELI5

orca terminal create --command "codex" starts Codex in a new pane but never tells the pane "this is Codex". Orca only figures that out later, when Codex changes the terminal title. If a script runs worker-start right after create, the paste arrives before that happens, gets the generic "wait a fixed delay, then press Enter" treatment, and stalls. Now create recognizes the agent from the command line and labels the pane immediately.

What Changed

  • src/cli/handlers/terminal.ts: terminal create runs the command through recognizeAgentProcessFromCommandLine and passes launchAgent to terminal.create when an interactive agent is recognized. Headless one-shots stay unlabeled: the shared recognizer already drops claude -p, and the existing Codex classifier (shouldUseRendererBackedCodexTerminal) rules out codex exec and the other non-interactive subcommands.
  • src/cli/handlers/terminal.test.ts: codex, codex --yolo, claude --model … set launchAgent; codex exec …, claude -p …, npm run dev and no command leave it unset.

Why

#17291 traced it against source: pty.launchAgent starts null, pty.foregroundAgent is populated only after an OSC title observation, and createAgentPromptRenderGate returns the real echo gate only for a recognized agent. A worker-start --terminal <handle> chained immediately after terminal create --command "claude …" therefore takes the open-loop delay and reports agent_prompt_stalled; any pause of a couple of seconds between the two commands makes it pass. The terminal.create RPC already accepts launchAgent (the e2e fixtures use it); the CLI just never sent it. This is the fix the issue proposed, gated on the Codex classifier instead of the renderer-backed flag so remote clients get it too.

Linked Issue

Closes #17291

Visual Proof

N/A — CLI-only; the pane created by terminal create --command codex now carries launchAgent: codex from the start.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Ran on Windows 11:

pnpm test src/cli/handlers/terminal.test.ts   # 15 passed
pnpm tc:cli
oxlint + oxfmt on the changed files

AI Disclosure

Written with Claude Code (Claude Fable 5.1) under direction of @Tauri-EPO.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Sends an already-supported optional RPC field, so old hosts ignore it. No platform-specific behavior; the recognizer handles .exe/.cmd basenames.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — tc:cli, the handler tests and oxlint on changed files pass locally; full lint/build left to CI

🤖 Generated with Claude Code

…agent command

`orca terminal create --command "codex …"` (or `claude …`) never set
launchAgent on the pane; it was only inferred later, reactively, from the
agent's OSC title. A worker-start chained right after create therefore hit
dispatch_input before any agent identity existed, took the open-loop submit
delay instead of the agent-aware render gate, and stalled at
agent_prompt_stalled (stablyai#17291).

The CLI now reuses recognizeAgentProcessFromCommandLine to set launchAgent
at creation time. Headless one-shots stay unrecognized: the shared
recognizer already drops `claude -p`, and the Codex classifier rules out
`codex exec` and its other non-interactive subcommands.

Closes stablyai#17291

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: c2c5f33d-e101-4c68-87dd-eec0af33d6ca

📥 Commits

Reviewing files that changed from the base of the PR and between 7c56d16 and c42dc01.

📒 Files selected for processing (2)
  • src/cli/handlers/terminal.test.ts
  • src/cli/handlers/terminal.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/cli/handlers/terminal.test.ts
  • src/cli/handlers/terminal.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The terminal create handler now includes launchAgent only for interactive claude and codex commands. Other commands leave the field undefined. Tests cover version, additional agent, and one-shot commands.

Merge Risk: ⚪ Minimal · up to c42dc

This localized CLI change labels recognized interactive agents when terminals are created, improving immediate command handling without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: inferring launchAgent for interactive agent commands during terminal creation.
Description check ✅ Passed The description covers the required sections, explains the problem and solution, links issue #17291, documents CLI-only behavior, and records testing. The unchecked manual and full-suite checks are ac…
Linked Issues check ✅ Passed The implementation meets issue #17291 by recognizing interactive Claude and Codex commands during terminal creation and passing launchAgent immediately. Tests also verify that headless and unrelated c…
Out of Scope Changes check ✅ Passed The changes are limited to terminal creation launchAgent inference and related test coverage. They directly support the linked issue and PR objectives.
Full details: Description check

Explanation

The description covers the required sections, explains the problem and solution, links issue #17291, documents CLI-only behavior, and records testing. The unchecked manual and full-suite checks are acceptable because automated tests and CI coverage are documented.

Full details: Linked Issues check

Explanation

The implementation meets issue #17291 by recognizing interactive Claude and Codex commands during terminal creation and passing launchAgent immediately. Tests also verify that headless and unrelated commands remain unlabeled.

  • Fix all pre-merge checks with AI

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.

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: c7175775-a997-40a5-bac9-e54aa30db327

📥 Commits

Reviewing files that changed from the base of the PR and between 7314ada and 7c56d16.

📒 Files selected for processing (2)
  • src/cli/handlers/terminal.test.ts
  • src/cli/handlers/terminal.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment thread src/cli/handlers/terminal.ts Resolved

@pullfrog pullfrog 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.

ℹ️ No critical issues — the fix is correct for its stated goal and the tests actually fail without it. One rough edge worth a look before merge.

Reviewed changes

  • terminal create infers launchAgent — src/cli/handlers/terminal.ts runs the --command through recognizeAgentProcessFromCommandLine and forwards launchAgent to terminal.create, with an interactivity gate only for codex (via shouldUseRendererBackedCodexTerminal).
  • Handler tests — new describe('terminal create CLI') asserts launchAgent is set for codex, codex --yolo, claude --model … and unset for codex exec …, claude -p …, npm run dev, and no command. Exact toMatchObject / not.toHaveProperty assertions, so they genuinely fail without the behavior.

ℹ️ Nitpicks

  • The codex interactivity gate also drops a genuinely interactive codex launch when it arrives via a node entrypoint (node node_modules/@openai/codex/…): the shared recognizer resolves that to codex via recognizeNodeScriptEntrypoint, but shouldUseRendererBackedCodexTerminal returns false for a node first token, so launchAgent is left unset. Edge-case only (CLI users type codex, not the packaged entrypoint), so this is informational rather than blocking.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Comment thread src/cli/handlers/terminal.ts Resolved
…hAgent

Review follow-up: the inference labeled every agent the shared recognizer
returned, but only codex had its one-shot subcommands filtered, so
`opencode run …`, `gemini -p …` or `aider --message …` would have been
labeled and, through launchAgent, marked unattended. The gate is now the
interactive claude/codex classification the renderer-backed path already
uses; other agents stay unlabeled until the runtime infers them, exactly as
before this change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@pullfrog pullfrog 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.

✅ No new issues found. The previous asymmetric-gating concern is resolved: launchAgent is now restricted to claude/codex and requires shouldUseRendererBackedInteractiveTerminal(command), so non-interactive agent commands (gemini, opencode run, aider --message) and claude --version stay unlabeled. The added test cases genuinely fail without this gate.

Reviewed changes

  • Tightened the interactivity gate — src/cli/handlers/terminal.ts now requires both (recognizedAgent === 'claude' || recognizedAgent === 'codex') and shouldUseRendererBackedInteractiveTerminal(command) before inferring launchAgent, replacing the codex-only gate.
  • Expanded negative tests — src/cli/handlers/terminal.test.ts adds claude --version, gemini, opencode run "summarize", and aider --message "fix" to the "leaves launchAgent unset" cases.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

This branch has not been deployed

No deployments
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.

[Bug]: terminal create --command never infers launchAgent, so a chained worker-start races the fixed prompt-submit delay and stalls at dispatch_input

1 participant