Skip to content

feat(mobile): Resume in New CLI from a phone chat tab - #29783

Merged
brennanb2025 merged 29 commits into
mainfrom
brennanb2025/mobile-chat-resume-in-cli
Oct 17, 2026
Merged

brennanb2025 merged 29 commits into
mainfrom
brennanb2025/mobile-chat-resume-in-cli

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​369 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​363
Prod 42 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1102 $\color{#cf222e}{\Huge{\mathbf{−}}}$​461 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​641

ELI5

When a phone chat could not load, its tab menu offered no way to reach that conversation in a terminal. Resume in New CLI now opens a separate copy in a new terminal tab and keeps the original chat.

What Changed

A long Claude conversation exposed this gap after the phone showed “Could not load conversation.” The stream overflow was fixed separately in #28203 and desktop 1.4.227; this change provides the requested terminal escape hatch.

Long-press a supported chat tab on the phone and choose Resume in New CLI. A new terminal tab opens, running the agent on a copy of the conversation, and becomes selected on the phone in terminal view, even when the phone's default view for agent tabs is the chat reader. On the desktop the new tab lands right after the chat, and the desktop keeps its current selection and keyboard focus. The original chat stays as it was. The action covers Claude, Codex, Grok, Pi, OpenCode and OMP when the host can prepare a separate conversation.

The phone sends the source chat ID through its existing terminal-create request. The host finds or copies the conversation, reads its own settings, builds the command with the same execution environment that will launch it, and creates one terminal. A desktop window adopts that running terminal in the background. Repeated requests share the existing create admission; navigation away prevents an old response from changing the new phone screen. Known refusals give a recovery step, while an uncertain connection result asks the user to check existing tabs before retrying.

Where the new tab goes never blocks the action. The phone names the selected chat by its phone-side tab id, which differs from the desktop's id for the same chat. The host translates it through the saved desktop layout when the layout already has the chat; otherwise it places the tab the way any new phone terminal is placed. An earlier build of this PR refused with “Select a tab and try again” in that case.

Why

Source identity, settings and execution belong to the host. Keeping preparation and launch together prevents a failed settings read from replacing Manual permissions or custom commands with defaults, and prevents Windows shell settings from disagreeing with the project's actual execution environment. Desktop and host launch paths use the same extracted command builders.

Intentional differences: hosts must advertise the complete session.tabs.chat-fork-cli.v1 contract before the phone offers the action; older phones and ordinary terminal creation retain their existing paths. Native chat sources cannot run on SSH hosts; incompatible native/WSL combinations are refused without launching elsewhere. Folder workspaces use the same path as git worktrees. Desktop Resume in New CLI keeps its existing behavior. The new CLI tab is set to terminal view through the phone's existing per-tab view setting; the global default and ordinary new tabs are unchanged.

Temporary differences:

  • When the desktop has not yet saved a just-opened chat into its layout, the new tab may land at the end of the active tab group instead of beside the chat. Exact placement in that window waits on the layout-owner work that moves tab layout into the main process (PR 6d: Runtime stops asking the window to change layout #27982).
  • Server workspaces reached through the desktop still hide the action until source-chat preparation is relayed to the server that owns the chat.
  • Agent History's separate builder remains a follow-up.

No new saved field or request method was added; the source-chat request field and created-result warning are optional and capability gated.

Linked Issue

N/A — reported in Discord; stream-overflow fix tracked in #28203.

Visual Proof

Phone: iOS Simulator with the Orca dev client built from this branch, paired to a hidden test copy of the desktop on the M4Air. Agents: real OpenCode with no login, and a real signed-in Claude. Final checks ran on the exact final head 85c80e39694.

main: chat tab menu this PR: chat tab menu
main: only Close PR: Resume in New CLI above Close

New tab's first view with the phone's default set to the chat reader:

earlier build: the new CLI tab opened in the chat reader final head: it opens in the terminal final head: still terminal 20 seconds later, no toggle
earlier build: chat reader final: terminal view final: terminal view at +20 s

Resume with the chat itself selected while a terminal tab is open:

earlier build: refused final head: opens beside the chat on the desktop, desktop focus unchanged final head: real Claude chat resumed in a CLI
earlier build: Select a tab and try again desktop tab beside the chat Claude CLI with the copied conversation
refusal for a chat with nothing saved phone against a desktop without this change: item hidden Manual permissions, custom command and arguments used for the check below
one agent-named message older host: only Close settings

Testing

Real QA on the phone and desktop, all passing (driven by Codex; never Claude):

  • With Manual permissions, a custom OpenCode command, extra arguments and an environment variable set on the desktop, the phone's Resume ran exactly that command with those arguments and that variable, and no added permission-bypass flag.
  • With the chat selected and zero, one or two terminal tabs open, Resume opened the CLI and placed it right after the chat on the desktop; the phone's new tab and the desktop's tab are the same terminal process.
  • A real Claude chat resumed as claude --resume <id> --fork-session in a new terminal tab; the original chat was unchanged.
  • The new tab opened in terminal view at first appearance and 20 seconds later with the phone default set to the chat reader, stayed in terminal view after leaving and returning, and its view toggle still works both ways; the original chat and ordinary new terminals still follow the default.
  • The desktop kept its selected tab and keyboard focus while the phone opened the terminal.
  • Tapping while another terminal was being created created both; switching workspaces right after the tap created nothing on the new screen.
  • A desktop without this change hides the item; desktop Resume in New CLI and Session History behave as on main.
  • Windows (real signed-in Codex, phone's host request sent to a hidden test copy): with the global terminal shell set to WSL and a project that runs natively on Windows, the CLI ran in PowerShell with the configured arguments and environment; with Command Prompt selected it ran in Command Prompt; desktop Resume in New CLI unchanged. The phone app itself was not paired there.
  • Not checked: a host refusing a second Resume while a terminal is still being created (both requests completed in QA), and the placement fallback for a chat the desktop has not yet saved (covered by an automated test).
  • Seen during QA, not caused by this PR: the phone draws chat tabs after terminal tabs, so the new terminal shows left of the chat on the phone while the desktop puts it right of the chat (main does the same; tracked in STA-10875).

Automated tests cover the host capability gate, create admission and stale-route ownership, host settings and native-runtime command construction (including a global WSL shell with a native Windows project), source-selected placement with and without a saved desktop layout, and the new tab's terminal view. CI is the full static-analysis gate.

  • Final-head real mobile/Electron behavior checked
  • Automated tests added or updated
  • Full PR workflow passes on the final head

Review

Authored for @BrennanKB5. Review loop evidence is kept outside the repository; the single final status comment will summarize its result.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer material copied.

Checklist

  • One user-facing change: phone chat to a new CLI
  • Problem, behavior and host ownership explained
  • Uploaded before/after screenshots attached
  • Mixed versions, Windows/WSL, SSH and folder workspaces considered
  • Exact-head CI and QA complete

A chat tab on the phone had only Close in its long-press menu, so a chat
that would not load left no way to reach its conversation. The phone now
offers Resume in New CLI, like the desktop tab menu: the chat's host
prepares the conversation and the phone opens a copy in a new terminal tab.

The resume and fork startup builders move to src/shared so the desktop and
the phone build the same command.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 16, 2026 17:52
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c4212fcb-3add-4632-a9e8-def7064c21c7
📥 Commits

Reviewing files that changed from the base of the PR and between b8500c1 and 5fe78de.

📒 Files selected for processing: 9
  • mobile/src/session/mobile-native-chat-cli-fork.test.ts
  • mobile/src/session/mobile-session-quick-command-launch.ts
  • mobile/src/session/use-mobile-session-panel-route-actions.tsx
  • mobile/src/session/use-mobile-session-terminal-create-actions.ts
  • mobile/src/test-support/rpc-recording/adapters/session-terminal-create-mount-adapters.ts
  • mobile/src/test-support/rpc-recording/mutants/operation-mutations.ts
  • src/main/runtime/terminal/launch/mobile-terminal-chat-fork-create.ts
  • src/main/runtime/terminal/launch/mobile-terminal-chat-fork.test.ts
  • src/main/runtime/terminal/launch/mobile-terminal-owned-create.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.

📝 Walkthrough

The change adds a mobile “Resume in New CLI” action for eligible agent sessions. Mobile requests pass the source session to runtime code, which builds a fork startup and creates a terminal. Terminal placement and reveal options now pass through runtime and renderer paths. Shared AI Vault resume and fork startup logic is used by both renderer and runtime code.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 5fe78

The new "Resume in New CLI" action is mostly sound in the reviewed changes. One minor open concern remains: the store check for opencode2 sessions may read the opencode settings instead. Confirm it before merge, though it is unlikely to block the feature.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 45.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 42 functions across 40 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly and concisely identifies the main user-facing change: adding Resume in New CLI from a mobile chat tab.
Description check Passed The description is detailed and covers the required user impact, implementation, rationale, testing, visual proof, limitations, and checklist. The linked issue field is marked N/A and references Disco…
Full details: Description check

Explanation

The description is detailed and covers the required user impact, implementation, rationale, testing, visual proof, limitations, and checklist. The linked issue field is marked N/A and references Discord plus related issue #28203, but the description is otherwise complete.

  • Fix all pre-merge checks with AI
✨ 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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f63d45db-82ab-4ea4-9858-449c85a721d2
📥 Commits

Reviewing files that changed from the base of the PR and between 79b6bad and c8d6856.

📒 Files selected for processing: 10
  • mobile/src/session/MobileSessionSheets.tsx
  • mobile/src/session/mobile-native-chat-cli-fork.test.ts
  • mobile/src/session/mobile-native-chat-cli-fork.ts
  • mobile/src/session/mobile-session-launch-operations.ts
  • mobile/src/session/session-launch-reply-schema.ts
  • mobile/src/session/use-mobile-session-terminal-create-actions.ts
  • src/renderer/src/lib/ai-vault-resume-command.ts
  • src/renderer/src/lib/ai-vault-resume-platform.ts
  • src/renderer/src/lib/ai-vault-session-fork-startup.ts
  • src/shared/ai-vault-resume-startup.ts
💤 Files with no reviewable changes: 1
  • src/renderer/src/lib/ai-vault-resume-platform.ts

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

Comment thread src/shared/ai-vault-resume-startup.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


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 51e99f33-7a7d-42c4-894a-6ee7d877f620
📥 Commits

Reviewing files that changed from the base of the PR and between 0ec8b3c and 66a271b.

📒 Files selected for processing: 27
  • mobile/src/session/mobile-native-chat-cli-fork.test.ts
  • mobile/src/session/mobile-native-chat-cli-fork.ts
  • mobile/src/session/session-write-reply-schema.ts
  • mobile/src/session/use-mobile-session-terminal-create-actions.test.ts
  • mobile/src/session/use-mobile-session-terminal-create-actions.ts
  • src/main/ai-vault/structured-chat-cli-fork.ts
  • src/main/runtime/agent-launch-scope-runtime.test.ts
  • src/main/runtime/rpc/errors.ts
  • src/main/runtime/rpc/methods/session-tabs.ts
  • src/main/runtime/runtime-notifier-contract.ts
  • src/main/runtime/runtime-pane-admission.test.ts
  • src/main/runtime/runtime-pane-admission.ts
  • src/main/runtime/runtime-terminal-contracts.ts
  • src/main/runtime/terminal/launch/mobile-terminal-chat-fork-create.ts
  • src/main/runtime/terminal/launch/mobile-terminal-chat-fork.test.ts
  • src/main/runtime/terminal/launch/mobile-terminal-chat-fork.ts
  • src/main/runtime/terminal/launch/mobile-terminal-create.ts
  • src/main/runtime/terminal/launch/mobile-terminal-owned-create.ts
  • src/main/runtime/terminal/launch/mobile-terminal-renderer-create.ts
  • src/main/runtime/terminal/launch/terminal-create.ts
  • src/main/window/runtime-window-lifecycle.ts
  • src/preload/api/ui-bridge-terminal-and-session-tabs.ts
  • src/preload/api/ui-command-event-api.ts
  • src/renderer/src/hooks/ipc-events/terminal-presentation-ipc-bridge.ts
  • src/shared/rpc-contract/session-tabs-schemas-params.ts
  • src/shared/runtime-session-contracts.ts
  • src/shared/session-tabs-runtime-capabilities.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.

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

♻️ Duplicate comments: 1
mobile/src/session/use-mobile-session-terminal-create-actions.ts: 1

169-177: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Branch on response.ok. The fork branches still read fields that RpcResponse does not have.

requestMobileSessionTerminalCreate returns a plain RpcResponse (RpcSuccess | RpcFailure). Because of this, the Mobile verify typecheck fails with TS2339 at Lines 176, 177, 180 and 194.

Runtime effects:

  • response.kind is always undefined. The chat_fork_* refusal guidance never runs.
  • On success, response.raw.ok throws TypeError after the host has already created the terminal. The catch block then reports a failure and skips terminal selection and subscription.

Fix:

  • Use !response.ok and response.error.code for refusals.
  • Use response.result for the desktop warning.
  • Remove the 'incompatible' branch. RpcIncompatibleReplyError already reaches the catch block.
🐛 Proposed fix
-      if (sourceFork && response.kind === 'outer-refused') {
+      if (sourceFork && !response.ok) {
         reportFork(mobileChatForkRefusalMessage(agentName, response.error.code))
         return 'reported-failure'
       }
-      if (sourceFork && response.kind === 'incompatible') {
-        reportFork(`${agentName} may have opened. Reconnect and check open tabs on the host before retrying.`)
-        return 'reported-failure'
-      }
@@
-      if (sourceFork && response.raw.ok && createdTerminalDesktopWarning(response.raw.result)) {
+      if (sourceFork && response.ok && createdTerminalDesktopWarning(response.result)) {

Source: Pipeline failures


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bd751124-95e4-4577-b615-bc4ef9e6ee87
📥 Commits

Reviewing files that changed from the base of the PR and between 66a271b and b8500c1.

📒 Files selected for processing: 7
  • mobile/src/session/mobile-chat-fork-create-feedback.ts
  • mobile/src/session/mobile-native-chat-cli-fork.ts
  • mobile/src/session/mobile-session-quick-command-launch.ts
  • mobile/src/session/mobile-session-terminal-create-request.ts
  • mobile/src/session/use-mobile-session-terminal-create-actions.ts
  • mobile/src/session/use-mobile-terminal-create-route-owner.ts
  • src/main/runtime/terminal/launch/mobile-terminal-chat-fork-create.ts
🚧 Files skipped from review as they are similar to previous changes: 2
  • mobile/src/session/mobile-native-chat-cli-fork.ts
  • src/main/runtime/terminal/launch/mobile-terminal-chat-fork-create.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.

Resolve the session-tabs capability list (chat fork + main's create-terminal shell) and refuse a shell pick on a chat fork, which uses the host's own launch runtime.
…sages into the fork feedback module

Formatting pushed the create hook past its line limit, so the fork-only reply message, partial-success warning and host capability check now live beside the other fork messages. Same order and copy as before.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

When a saved chat could not load on the phone, there was no way to continue it in a terminal. Resume in New CLI now opens an independent conversation using the host’s agent command, permissions, arguments, environment and actual shell. The original chat stays open. The phone selects terminal view even with Chat as its default, and desktop shows the same running terminal without changing selection or editor focus.

Five review rounds and the final readiness review are complete. Repairs moved preparation and launch under the host’s existing create operation, preserved Manual/custom settings and Windows runtime selection, added truthful busy/refusal/uncertain-outcome feedback, prevented late replies from changing another phone screen, and removed the selected-chat placement refusal. The last repairs only completed test fixtures; no behavior was weakened to pass CI.

Verified: full PR workflow and aggregate gate pass on 85c80e3969471a45939dcdbbcb6c99b2eecb66c4; all checks green, no unresolved threads, non-draft and CLEAN. Codex-driven final-head M4Air/iOS QA used real OpenCode and signed-in Claude: selected-chat forks, copied conversation, terminal view at first observation and about 20 seconds later, matching phone/desktop process identity, desktop tab placement and unchanged editor focus all passed. Earlier corrected-head QA also passed zero/one/two existing-terminal cases, remount and later view toggles, empty-chat refusal, and Manual/custom arguments/environment. Windows real Codex host requests after main integration passed native PowerShell with global WSL, retained arguments/environment, and both anchored and ordinary append placement. Protected config hashes remained unchanged and QA-owned processes were cleaned up.

Retained differences: hiding the action on hosts without its complete capability is intended. Desktop-relayed server workspaces remain hidden temporarily until source preparation reaches their owning server; Agent History’s separate builder remains a follow-up. If the host cannot resolve the selected chat in saved layout, creation still proceeds and desktop may append through ordinary placement instead of beside the chat; exact placement waits on the layout-owner work tracked in #27982. Existing phone terminal-first/chat-last order is tracked in STA-10875. Preparation can leave an unused independent copy after a later refusal; existing failed preference-save recovery can remove the immediate terminal override.

Limits: missing-saved-layout fallback passes the real-admission CI contract but was not reached in rendered QA. Busy-refusal timing, subsecond first paint and a complete remote/folder/provider matrix were not established. Windows evidence exercises the real host handler through desktop IPC, not phone transport. No local app/build/install/lint/typecheck ran in this review worktree.

For Brennan’s review

Main, before the action existed:

Main: phone chat menu

Final head: phone terminal immediately after Resume, then about 20 seconds later (Chat remained the default):

Final head: phone OpenCode fork in terminal view

Final head: terminal still selected about 20 seconds later

Desktop after Resume: the new terminal is beside its source; README remains selected:

Final head: background desktop terminal with README unchanged

The same action with real Claude preserves the copied conversation:

Final head: real Claude fork in phone terminal view

Judgment points:

@brennanb2025
brennanb2025 merged commit 64e544a into main Oct 17, 2026
50 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/mobile-chat-resume-in-cli branch October 17, 2026 01:16
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