orca icon indicating copy to clipboard operation
orca copied to clipboard

fix(agents): keep Windows Cursor startup prompts out of argv (#8793)

Open rodboev opened this issue 4 months ago β€’ 4 comments

Summary

  • Keep Windows Cursor startup prompts out of argv by switching only Windows Cursor launches onto the existing post-start delivery path.
  • Route the startup-plan builder and the current renderer launch consumers through one shared prompt-mode resolver so Windows Cursor behavior stays consistent everywhere that launches it.

Closes #8793.

Screenshots

No visual change.

Testing

  • [ ] pnpm lint
  • [ ] pnpm typecheck
  • [ ] pnpm test
  • [ ] pnpm build
  • [x] Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused validation:

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.test.ts - passed; 1 file and 8 tests passed.
  • pnpm exec vitest run --config config/vitest.config.ts src/shared/tui-agent-startup.test.ts src/renderer/src/lib/launch-agent-in-new-tab.test.ts src/renderer/src/lib/launch-agent-background-session.test.ts src/renderer/src/lib/source-control-agent-action-plan.test.ts src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.test.ts src/shared/terminal-quick-commands.test.ts - passed; 6 files and 156 tests passed.
  • pnpm run typecheck:node - passed.
  • pnpm exec oxlint src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.ts src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.test.ts - passed.

AI Review Report

The final diff keeps the owner in shared TUI config, adds a Windows-only Cursor prompt-mode override, routes the startup-plan builder plus the new-tab, background, source-control preview, and source-control live-launch handoff through the shared resolver, and leaves quick-command support on the default static mode. The live source-control handoff resolves omitted platform context with the same CLIENT_PLATFORM fallback as the preview before mapping auto-submit to submit-after-ready. Focused proofs cover the Windows Cursor startup regression, empty Windows Cursor startup preservation, non-Windows Cursor preservation, Windows non-Cursor negative space, each renderer launch path, the live source-control handoff, and quick-command preservation.

Security Audit

The change adds no subprocesses, no auth surface, and no new path parsing. It narrows Windows Cursor startup prompt delivery away from argv and reuses Orca's existing post-ready prompt delivery path instead of introducing a platform-specific launcher workaround or command discovery branch.

Notes

This target is intentionally about TUI startup, worktree launch, and related renderer launch surfaces. It does not change commit-message generation or generic Windows batch-safety policy.

rodboev avatar Jul 16 '26 04:07 rodboev

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: Pro Plus

Run ID: 1667ea68-d620-4c35-9133-52d6eb08223f

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 5e900b10b31f12db885e4448c3e1f6300e066efb and 5275ea2e78565a31ee137258bc4218c9d1e6813e.

πŸ“’ Files selected for processing (12)
  • src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.test.ts
  • src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/lib/source-control-agent-action-plan.test.ts
  • src/renderer/src/lib/source-control-agent-action-plan.ts
  • src/shared/terminal-quick-commands.test.ts
  • src/shared/tui-agent-config.ts
  • src/shared/tui-agent-startup.test.ts
  • src/shared/tui-agent-startup.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/shared/terminal-quick-commands.test.ts
  • src/renderer/src/lib/source-control-agent-action-plan.test.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.ts
  • src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.test.ts
  • src/shared/tui-agent-startup.test.ts
  • src/shared/tui-agent-config.ts
  • src/renderer/src/lib/source-control-agent-action-plan.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.test.ts

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


πŸ“ Walkthrough

Walkthrough

Added platform-specific prompt injection mode resolution, including a Windows cursor-agent override. Startup planning and renderer launch paths now use the resolved mode, route Windows Cursor prompts after readiness, and map auto-submit to the corresponding delivery behavior. Tests cover startup plans, source-control actions, new-tab launches, background sessions, and terminal quick-command support.

Merge Risk: βšͺ Minimal Β· up to 5275e

The change keeps Windows Cursor startup prompts out of command-line arguments while preserving existing behavior for other launch paths; no actionable merge-blocking risk remains.

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 12 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 identifies the main fix: preventing Windows Cursor startup prompts from being passed through argv.
Description check βœ… Passed The description explains the problem, solution, linked issue, testing, security impact, and lack of visual changes. It omits several template headings and checklist items, but the core required inform…
Linked Issues check βœ… Passed The changes satisfy issue [#8793] by resolving Windows Cursor prompt injection to stdin-after-start and applying the shared resolver across the startup-plan and relevant renderer launch paths. Non-Win…
Out of Scope Changes check βœ… Passed The changes remain within scope. Configuration, launch-path updates, regression tests, and quick-command coverage directly support the Windows Cursor prompt-delivery fix without adding unrelated behav…
Full details: Description check

Explanation

The description explains the problem, solution, linked issue, testing, security impact, and lack of visual changes. It omits several template headings and checklist items, but the core required information is present.

Full details: Linked Issues check

Explanation

The changes satisfy issue [#8793] by resolving Windows Cursor prompt injection to stdin-after-start and applying the shared resolver across the startup-plan and relevant renderer launch paths. Non-Windows Cursor behavior remains unchanged.

Full details: Out of Scope Changes check

Explanation

The changes remain within scope. Configuration, launch-path updates, regression tests, and quick-command coverage directly support the Windows Cursor prompt-delivery fix without adding unrelated behavior.

  • [ ] 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[bot] avatar Jul 16 '26 04:07 coderabbitai[bot]

Taking a look!

OrcaWin avatar Jul 20 '26 19:07 OrcaWin

Did a deep takeover review of this fix (keeping Windows Cursor startup prompts out of argv via a shared prompt-mode resolver, #8793). The core mechanism is correct and I'm confident it resolves the user's issue:

  • getTuiAgentPromptInjectionMode(agent, platform) centralizes the override and buildAgentStartupPlan resolves the mode from platform, so Windows Cursor lands in stdin-after-start and the prompt is never folded into argv regardless of caller β€” the .cmd shim rejection can't be triggered.
  • Verified all four launch surfaces (new-tab, background, source-control preview-plan, source-control live start) build a clean prompt:'' launch and deliver post-start; other agents/platforms (Cursor on linux/darwin, codex/claude/etc.) are untouched; SSH is target-platform-derived both directions.
  • Confirmed the Cursor trust preflight runs platform-independently, so the post-start paste isn't swallowed on Windows. The auto-submit β†’ submit-after-ready/paste-submit mapping (incl. the omitted-launchPlatform fallback commit) means submission still happens, matching prior argv UX β€” no dropped/unsubmitted prompt.

The only nits I found were rebase collateral, which I fixed in a small follow-up commit: restored three why-comments AGENTS.md wants kept (SSH orca-ide shim, background-spawn workspace-privacy, Hermes readiness) and de-inlined the argv prompt separator back to a readable local. No behavior change. Typecheck (node + web), oxlint, and the 159 focused tests are green.

These changes are on our rebased branch OrcaWin/pr-8949-rebase (the original PR was conflicting) β€” intended for a superseding PR, not a merge here. Nice fix! πŸ™Œ

OrcaWin avatar Jul 21 '26 18:07 OrcaWin

Hey! We rebased this onto the latest main and pushed the review fixes here to help get it landed β€” CI should be green now (typecheck node + web, oxlint, and the Windows Cursor startup-prompt tests all pass locally). Thanks so much for the fix! πŸ™

OrcaWin avatar Jul 21 '26 21:07 OrcaWin

Rebased this onto the latest main and pushed the review fixes here to help get it landed β€” the branch had drifted a fair way behind, so launch-agent-background-session.ts needed reconciling against the newer resolveAgentBackgroundLaunchHost / reserveAgentBackgroundSessionIdentity refactor. Your actual fix is unchanged: promptInjectionModeByPlatform still routes Windows Cursor prompts after start instead of through argv.

Local checks are green β€” pnpm typecheck (node/cli/web), oxlint, and all 155 tests across the six touched test files. Thanks so much for the contribution, and for the extra coverage on the non-Windows and other-argv-agent cases!

OrcaWin avatar Jul 28 '26 03:07 OrcaWin

[!NOTE] The previously reviewed commits are no longer reachable (likely due to a force-push or rebase), so CodeRabbit is performing a full review instead of an incremental one. This review may take a little longer.

coderabbitai[bot] avatar Aug 26 '26 07:08 coderabbitai[bot]