Skip to content

fix(terminal): submit Quick Commands in agent TUIs - #16562

Open
Jinwoo-H wants to merge 25 commits into
mainfrom
aug26-quick-command-enter-submit
Open

Jinwoo-H wants to merge 25 commits into
mainfrom
aug26-quick-command-enter-submit

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1537 $\color{#cf222e}{\Huge{\mathbf{−}}}$​36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1501
Prod 29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1343 $\color{#cf222e}{\Huge{\mathbf{−}}}$​204 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1139

Summary

Quick Commands configured with “press Enter after” now submit text correctly when the exact foreground pane is a Claude/Codex TUI, while preserving raw shell and other terminal-application semantics.

The fix:

  • adds typed quickCommand intent to terminal.send;
  • reuses the settled agent-prompt protocol (bracketed paste + one CR) only for Claude/Codex;
  • preserves raw command + CR for shells and unrecognized applications;
  • orders trailing input and repeated Quick Commands through a bounded local/paired transport lane;
  • rechecks exact PTY binding and mobile-input ownership immediately before writing;
  • safely falls back on mixed client/old-host versions.

Reproduction

A deterministic fake PTY/TUI oracle on latest origin/main and with the dispatch path disabled receives one raw prompt + CR, reports prematureEnters=1, and does not submit.

The candidate receives the exact PTY stream: bracketed paste (ESC [200~prompt ESC [201~) followed by CR.

The fake TUI reports prematureEnters=0, receivedEnters=1, and submitted=true, and the rendered Electron terminal shows ORCA_TERMINAL_SEND_REPORT ok.

Validation

  • pnpm tc:web
  • pnpm tc:node
  • changed-file code-quality checks
  • reliability manifest: 98 gates
  • focused Vitest matrix: 80 tests passed
  • Electron E2E: tests/e2e/terminal-quick-command-agent-submit.spec.ts
  • git diff --check

No sleeps, retries, global key synthesis, or unrelated prompt-delivery changes are used. Known evidence gap: no live SSH or physical Windows/Linux journey; shared contracts and deterministic tests cover those paths.

Related but distinct reports reviewed: #14525, #14347, #14608, and #14962.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Quick Commands now support validated desktop agent submission through local and remote PTY transports. Raw shell, non-target, insert-only, and multiline input behavior remains unchanged. An ordering lane serializes typed input, accepted writes, and Quick Commands. Runtime routing validates pane, worktree, tab, leaf, PTY, connection, and lifecycle identity. Negotiated Kitty CSI-u submission uses bracketed paste for eligible agents and falls back when confirmation or protocol support is unavailable. Tests cover unit, integration, and Electron E2E behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides a clear summary, reproduction details, implementation scope, validation results, and a known testing gap. However, it omits several required template sections, including the E… Update the description to include all required template sections. Add the linked issue using Fixes #..., provide visual proof or state N/A with a reason, complete the Testing checklist and platform coverage, complete the Agent skill ups…
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 31 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: fixing Quick Command submission in agent TUIs.
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 provides a clear summary, reproduction details, implementation scope, validation results, and a known testing gap. However, it omits several required template sections, including the ELI5, What Changed, Why, Linked Issue with a Fixes # reference, Visual Proof or N/A, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Update the description to include all required template sections. Add the linked issue using Fixes #..., provide visual proof or state N/A with a reason, complete the Testing checklist and platform coverage, complete the Agent skill upstream boundary section, document security, compatibility, SSH, mobile, and performance considerations, and complete the remaining checklist items.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 31 files. (2 skipped: 2 too large.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts (1)

1244-1260: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Bound the viewport-claim wait before flushing an empty input.

sendQuickCommandToRuntime runs in the single-flight ordering lane and calls sendInputAcceptedToRuntime(''). If pendingViewportClaim remains set while no multiplexed stream exists, sendInputAcceptedToRuntime waits indefinitely on viewportClaimReadyWaiters, which blocks subsequent typed input in the lane. Add a bounded wait for this claim, or skip the claim wait when data is empty.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 49915e40-156f-429b-a1b4-e088efabb27e

📥 Commits

Reviewing files that changed from the base of the PR and between f72dcb9 and 4a9c3c62428dba2018f1cde33376ccfe0bbc5fd0.

📒 Files selected for processing (18)
  • config/reliability-gates.jsonc
  • src/main/runtime/rpc/methods/terminal/terminal-send-method.ts
  • src/main/runtime/rpc/methods/terminal/unary-schemas.ts
  • src/main/runtime/rpc/terminal-agent-prompt-send.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport-input-write.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-input-coalescing.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • src/renderer/src/components/terminal-pane/terminal-input-ordering-lane.test.ts
  • src/renderer/src/components/terminal-pane/terminal-input-ordering-lane.ts
  • src/renderer/src/components/terminal-pane/terminal-quick-command-dispatch.test.ts
  • src/renderer/src/components/terminal-pane/terminal-quick-command-dispatch.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts
  • src/renderer/src/runtime/runtime-terminal-quick-command.test.ts
  • src/renderer/src/runtime/runtime-terminal-quick-command.ts
  • tests/e2e/terminal-quick-command-agent-submit.spec.ts
  • tests/tools/repro-terminal-send-submit.mjs

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

@Jinwoo-H
Jinwoo-H force-pushed the aug26-quick-command-enter-submit branch from 4a9c3c6 to 7885322 Compare August 26, 2026 06:03

@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: 3

🧹 Nitpick comments (2)
src/main/runtime/orca-runtime.test.ts (1)

17415-17749: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the repeated negotiated-agent PTY scaffold into one local factory.

Six of the new tests repeat the same block: setPtyController with a recording write, kill, getForegroundProcess, and confirmForegroundProcess, then createTerminal with launchAgent, then an optional \x1b[>Nu negotiation frame. Only the pty id, agent, flags, and confirmation behavior vary.

A single factory in this file (for example createNegotiatedAgentTerminal) that returns { runtime, handle, writes } would remove about 120 duplicated lines and keep the per-test assertions as the only visible difference. Name it after the domain concept, not a generic role.

As per coding guidelines: "check whether an existing implementation already does the job (or nearly does). Extend or generalize it instead of building a parallel version".

Source: Coding guidelines

src/main/runtime/rpc/methods/terminal/terminal-send-method.ts (1)

25-38: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a regression test for omitted client.type.

TerminalSend applies 'desktop' when client.type is omitted under Zod 4.4.3. Test quickCommand: true, text: 'echo x\r', and client: { id: 'desktop-1' }; assert the parsed type is 'desktop' and the Quick Command guard accepts the request.

Source: MCP tools


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 553d3276-7d66-4980-9f49-e799fae0ee52

📥 Commits

Reviewing files that changed from the base of the PR and between c3701e4 and 0c0eb6d.

📒 Files selected for processing (23)
  • config/reliability-gates.jsonc
  • src/main/daemon/headless-emulator.test.ts
  • src/main/daemon/headless-emulator.ts
  • src/main/providers/ssh-pty-provider.test.ts
  • src/main/providers/ssh-pty-provider.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/terminal/terminal-send-method.ts
  • src/main/runtime/rpc/terminal-agent-prompt-send.test.ts
  • src/relay/pty-handler-spawn-admission.test.ts
  • src/relay/pty-handler.ts
  • src/relay/pty-shell-utils.test.ts
  • src/relay/pty-shell-utils.ts
  • src/relay/shell-profile-list.ts
  • src/renderer/src/components/terminal-pane/pty-transport-input-write.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-input-coalescing.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • src/shared/agent-prompt-injection.test.ts
  • src/shared/agent-prompt-injection.ts
  • src/shared/terminal-kitty-keyboard-flags.ts
  • tests/e2e/terminal-quick-command-agent-submit.spec.ts
  • tests/tools/repro-terminal-send-submit.mjs

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

Comment thread src/main/runtime/orca-runtime.ts Resolved
Comment thread src/relay/pty-shell-utils.ts Resolved

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/tools/repro-terminal-send-submit.mjs (1)

289-298: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Gate CSI-U parsing on negotiateCsiU.

When --negotiate-csi-u is absent, fakeAgentMain still accepts CSI_U_ENTER and completes submission. A fallback test can therefore pass after the runtime sends CSI-U to an unnegotiated agent. Skip this parser unless negotiateCsiU is true; otherwise accept only \r.

This protects the mixed-version fallback path described in the PR objectives.

Also applies to: 359-378


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aced2029-a276-4d48-9d5a-992be49b1de1

📥 Commits

Reviewing files that changed from the base of the PR and between 0c0eb6d and abf83c1.

📒 Files selected for processing (9)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/terminal-agent-prompt-send.test.ts
  • src/relay/pty-shell-utils.test.ts
  • src/relay/pty-shell-utils.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-batching.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-stream-reconnect.test.ts
  • src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
  • tests/tools/repro-terminal-send-submit.mjs

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

Comment on lines +1251 to +1255
if (
pendingViewportClaim &&
!getCurrentMultiplexedStream(targetHandle) &&
(data.length > 0 || inputBatcher.hasPending())
) {

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Wait when pendingClaimInput contains earlier input. If regular input has moved into pendingClaimInput, inputBatcher.hasPending() is false. An empty Quick Command then bypasses this wait and can submit before that earlier input flushes after stream installation. Include pendingClaimInput.length > 0 in the condition.

Proposed fix
-      (data.length > 0 || inputBatcher.hasPending())
+      (data.length > 0 || inputBatcher.hasPending() || pendingClaimInput.length > 0)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (
pendingViewportClaim &&
!getCurrentMultiplexedStream(targetHandle) &&
(data.length > 0 || inputBatcher.hasPending())
) {
if (
pendingViewportClaim &&
!getCurrentMultiplexedStream(targetHandle) &&
(data.length > 0 || inputBatcher.hasPending() || pendingClaimInput.length > 0)
) {

@Jinwoo-H
Jinwoo-H requested a review from brennanb2025 as a code owner August 27, 2026 03:20

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.

1 participant