Skip to content

Keep automation sends working during phone terminal control - #34675

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/phone-control-programmatic-input
Oct 28, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/phone-control-programmatic-input

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​298 $\color{#cf222e}{\Huge{\mathbf{−}}}$​77 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​221
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​121 $\color{#cf222e}{\Huge{\mathbf{−}}}$​61 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​60

The problem

When your phone controlled a terminal, a script using orca terminal send could be refused with “0 bytes written,” while an orchestration message could still type into the same terminal. These different rules made automation unpredictable.

What this PR changes

  • Scripts and orchestration messages can send while your phone controls the terminal, including scripts connected through --environment or --pairing-code.
  • Direct desktop typing stays paused while the phone controls the terminal. Orca checks immediately before new input starts, including after a wait.
  • Orca finishes text it has already accepted and preserves an accepted prompt’s Enter. The next separate desktop input is still paused.

One shared decision on the machine running the terminal uses where the input came from. The terminal’s agent does not change the rule.

What stays the same

Intended: Your phone keeps control of typing and terminal size; automation does not take that control away. Direct desktop typing remains paused until control changes.

Older phones and clients keep their request formats and existing permitted paths. Permission, stopped-terminal and stale-target checks still apply. Prompt delivery and retry protections remain in place. There is no new setting or saved state.

Temporary: Separate simultaneous writes retain their existing ordering; further work is tracked in #26676.

How it was tested

  • Integration tests ran real CLI commands through authenticated pairing and orchestration dispatch during phone control.
  • A table checked desktop typing, local and paired scripts, orchestration, phone input and older callers.
  • Regression tests covered late takeover, dropped typing without replay, and an accepted prompt’s Enter after its sender disconnects.
  • Targeted tests and normal commit hooks passed after the test fixture corrections.
  • CI passed on the final head. These flows require integration tests under the review QA table; no app, live-agent or screenshot run was required because no screen appearance changed.

AI assistance: implementation and review used Codex, with an independent Claude plan review.

Tracked in

Tracked in STA-12083 and STA-12096.

Supersedes #33455. Thanks to @thefrikidude for the original diagnosis and diagnostic fix. The chosen behavior removes the CLI refusal their patch explained, so this replacement starts from main without retaining that diagnostic code.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 28, 2026 03:17
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent 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: da63034b-9ba1-4314-9250-ab0129d1be37
Commits

Reviewing files that changed from the base of the PR and between 38901c0 and b1484dc.

Files selected for processing: 1
  • src/main/runtime/terminal-restore-record-seed.test.ts

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

Walkthrough

Terminal writes now carry input-source metadata and use shared admission checks. RPC handlers classify input sources and pass them to terminal writes. Paused input maps to refused or unavailable results, and multiplexed delivery records paused sequenced input as applied. Tests cover source classification, write admission, CLI dispatch modes, and replay behavior.

Priority: Normal

Merge Risk: Minimal · up to b1484

The reported typecheck issue is fixed. No actionable merge blocker was found.

Pre-merge checks: Passed 4 · Failed 1

Failed 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 with cyclomatic complexity of at least 2. Documentat… 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 states the main change: automation sends (orca terminal send and orchestration messages) keep working while a phone controls the terminal. The raw summary shows the changeset adds shared inp…
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.
Description check Passed The description is detailed and relevant. It explains the problem, behavior changes, preserved behavior, testing, AI assistance, and tracking references. It does not follow the template headings exact…
Full details: Title check

Explanation

The title states the main change: automation sends (orca terminal send and orchestration messages) keep working while a phone controls the terminal. The raw summary shows the changeset adds shared input-source admission so scripts and orchestration can write while desktop typing stays paused during phone control, which matches the title's scope.

Full details: Description check

Explanation

The description is detailed and relevant. It explains the problem, behavior changes, preserved behavior, testing, AI assistance, and tracking references. It does not follow the template headings exactly, and it does not provide an explicit linked issue under “Linked Issue” or the required N/A wording under “Visual Proof.” These omissions do not prevent review because the required intent and test information are present.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 26 files.

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.

@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: 7729b7fd-c355-4fe0-b044-3a391d9d7ce2
Commits

Reviewing files that changed from the base of the PR and between 6bb0c14 and f112230.

Files selected for processing: 25
  • src/main/ipc/pty/ipc/write-input-user-input.test.ts
  • src/main/ipc/pty/ipc/write-input.ts
  • src/main/runtime/mobile-presence-lock.test.ts
  • src/main/runtime/rpc/methods/terminal/terminal-claude-agent-view-method.ts
  • src/main/runtime/rpc/methods/terminal/terminal-input-delivery.ts
  • src/main/runtime/rpc/methods/terminal/terminal-multiplex-input-frame.ts
  • src/main/runtime/rpc/methods/terminal/terminal-send-method.ts
  • src/main/runtime/rpc/terminal-agent-prompt-send.test.ts
  • src/main/runtime/rpc/terminal-agent-prompt-socket.test.ts
  • src/main/runtime/rpc/terminal-claude-agent-view.test.ts
  • src/main/runtime/rpc/terminal-multiplex-ack-output-budget.test.ts
  • src/main/runtime/rpc/terminal-multiplex-ack-overflow-recovery.test.ts
  • src/main/runtime/rpc/terminal-multiplex-desktop-resize-routing.test.ts
  • src/main/runtime/rpc/terminal-multiplex-input-sequence-replay.test.ts
  • src/main/runtime/rpc/terminal-multiplex-input-write-rejection.test.ts
  • src/main/runtime/rpc/terminal-multiplex-output-pause-and-viewport.test.ts
  • src/main/runtime/rpc/terminal-output-batching.test.ts
  • src/main/runtime/rpc/terminal-send.test.ts
  • src/main/runtime/runtime-terminal-writer.test.ts
  • src/main/runtime/runtime-terminal-writer.ts
  • src/main/runtime/terminal-input-admission.ts
  • src/main/runtime/terminal/input/terminal-agent-prompt.ts
  • src/main/runtime/terminal/input/terminal-input-dispatch.ts
  • src/main/runtime/terminal/layout/terminal-view-presence.ts
  • src/main/runtime/terminal/wait/terminal-wait-permission.ts

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

The full review loop completed two rounds. When a phone controlled a terminal, script sends could return “0 bytes written” while orchestration messages still typed. This replacement allows both forms of automation and pauses only direct desktop typing. The check runs before new input starts; text and Enter already accepted finish normally.

Fixed: one shared input decision, paired CLI recognition using its existing request information, late phone takeover before the first write, and dropped desktop typing that must not replay. Older callers retain their formats and permission checks. No setting or saved state was added. The unused refusal explanation from #33455 is omitted because scripts are now allowed; thanks to @thefrikidude for the original diagnosis.

Verified: real paired CLI and orchestration commands, desktop/script/phone/older-caller combinations, late takeover, accepted Enter after disconnect, and dropped typing without replay. At the reviewed source commit, 14 changed test files passed 206 tests. Later test-only corrections passed 13 tests in the IPC suite and 23 tests in the preview suite, with normal hooks passing. Nine unchanged suites and the retained original fenced-input test carry from the earlier 24-file/303-test run; these are separate candidate runs, not additive totals. CI is green on b1484dc, including static analysis/typecheck, unit tests and packaging.

QA classification: qa=tests for CLI/orchestration, with real-command integration tests. The two subsequent fixture corrections are test-only changes. No screen appearance, lifecycle, process handling or login flow changed, so the table requires no screenshot, app or live-agent run. Earlier evidence carries across the main merges and test-only commits under the staleness rule.

Final correctness and independent reference/readiness reviews found no open P0/P1. Intended: phone control, mixed client versions, permission/target checks and accepted prompt completion remain supported. Temporary: separate simultaneous-write ordering is unchanged, tracked in #26676. No implementation fixes remain deferred.

For Brennan’s review:

Evidence carry from b37fd90 to the current head:

  • Main merge f112230 changed none of the original 25 PR source/test files.
  • Test-only fd3838f supplied the IPC fixture’s required input kind; its 13 tests passed.
  • Main merge 38901c0 included the upstream Fix broken Claude rewind test import #34721 test-import fix and changed none of those PR files.
  • Test-only b1484dc made the preview test delegate to the real shared writer. Its 23 tests passed, and the continued reviewer agreed that all required assertions remain effective.

@brennanb2025
brennanb2025 merged commit 471330c into main Oct 28, 2026
52 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/phone-control-programmatic-input branch October 28, 2026 09:21
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