You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): take back phone-driven browser tabs with Take back all - #42785
When your phone is using a terminal and a browser tab, clicking "Take back all" on the desktop now takes back the browser tab too. Before, it only took back the terminals, and the browser tab stayed locked and phone-sized.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$106
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$106
Prod
4
$\color{#1a7f37}{\Huge{\mathbf{+}}}$28
$\color{#cf222e}{\Huge{\mathbf{−}}}$6
$\color{#1a7f37}{\Huge{\mathbf{+}}}$22
What Changed
"Take back all" on a terminal's "Your phone is in control" overlay now also reclaims every browser tab the phone is driving, through the same per-tab reclaim the browser overlay's "Take back" already uses. The tab unlocks and returns to its desktop size right away (17 ms in the local run), without a reload.
"Restore all" on a terminal that is only held at phone size (phone session over) still only resizes terminals. It does not cut off a phone that has moved on to browsing.
Carries the reclaim part of #40954 by @casualuser: making "Take back all" cover phone-driven browser tabs was their idea. The rest of #40954 (a post-suppression PTY resize pass, restoring Emulation.setVisibleSize, a webview bounds resync) isn't needed on current main: split terminals already restore correctly, and the stuck browser size was fixed for non-drawing tabs in #41501. A paired-phone run on main confirmed both (details under Testing).
Why
restoreAllTerminalFits only collected the PTY ids the phone held, so it never touched the browser driver map. The renderer already keeps that map for every page in every workspace, and main already owns a per-page reclaim, so the change only adds a loop over the driven pages next to the terminal loop. No new IPC, no main-side changes.
Whether the browser overlay should also get a "Take back all" button is a separate UI question and isn't in this PR.
Browser tab right after clicking "Take back all" on the terminal overlay, with a fake phone driving both the terminal and the tab:
Before (main)
After
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Tested on macOS with a hidden Electron e2e build and a paired fake phone: the same terminal.subscribe and browser.screencast (390x844, mobile view) requests the Orca Mobile app sends, against a local http page.
Main, two split terminals plus a browser tab held by the phone: "Take back all" brought both PTYs back from 40x30 to 54x80, and stty size matched each pane. The browser tab stayed locked at 390x844.
Main, the browser overlay's own "Take back": the tab was back at desktop size on the first poll, with no reload.
This branch, same setup: "Take back all" cleared the browser overlay in 15 ms and the tab was back at 914x1254 in 17 ms. Terminals were restored as before.
New tests/e2e/phone-take-back-all-browser.spec.ts drives that flow. It fails on main (the browser overlay stays) and passes here. tests/e2e/mobile-banner.spec.ts still passes.
Risk
Level: Low
The riskiest part: "Take back all" now ends the phone's browser stream as well. That is the intended behaviour, but a phone user browsing will see their stream stop when the desktop clicks it, as they already do for terminals. Renderer-only. Remote-runtime browser tabs are untouched, since their driver state never reaches this map. Older phones and hosts are unaffected, because main's reclaim path is unchanged. A plain revert backs it out.
AI Disclosure
Review
Two reviewers (Codex and a Claude subagent), one round. Fixed: held-fit "Restore all" no longer stops a live phone browser stream; the spec checks only the phone width, because main clamps the emulated height to the desktop guest; the spec now closes its server if pairing fails.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
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)
Take back all only restored the PTYs the phone held, so a browser tab
the phone was driving stayed locked at phone size. Reclaim every
mobile-driven browser page alongside the terminals.
Co-authored-by: Aleksei Tcelishchev <[email protected]>
No actionable comments were generated in the recent review.
Walkthrough
The “Take back all” action now indicates whether a mobile driver is active when it restores terminal fits. When a phone is driving, the action also requests desktop reclamation for all mobile-driven browser pages. The end-to-end test checks that the terminal and browser driver banners disappear and that the browser viewport returns to its desktop dimensions.
Severity of issue fixed: Medium
Merge Risk: Low · up to f03fc
Take back all now reclaims phone-driven browser tabs. In a narrow case, a tab the phone began driving while a remote runtime was active may be missed until its driver state changes again. The change is mergeable, with this edge case as a follow-up.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the "Take back all" action now also reclaims phone-driven browser tabs. It uses the conventional fix(mobile) prefix and is specific. The changeset adds browser-page re…
Linked Issues check
Directly linked issue #40859 is open and is the only active linked target. Its coding objective for this PR is that "Take back all" reclaims mobile-driven browser tabs, and that the reclaimed tab retu…
Out of Scope Changes check
Every changed file serves the Take back all browser-reclaim objective. TerminalPaneMobileDriverPortals.tsx passes the phone-driving flag. use-mobile-terminal-fit-actions.ts adds the browser reclaim ca…
Description check
The description covers the ELI5, what changed, the mechanism and rationale, a linked issue (Fixes #40859), before/after visual proof, detailed manual and automated testing on macOS, a risk section wit…
Full details: Title check
Explanation
The title names the main change: the "Take back all" action now also reclaims phone-driven browser tabs. It uses the conventional fix(mobile) prefix and is specific. The changeset adds browser-page reclaim to restoreAllTerminalFits, which matches the title.
Full details: Linked Issues check
Explanation
Directly linked issue #40859 is open and is the only active linked target. Its coding objective for this PR is that "Take back all" reclaims mobile-driven browser tabs, and that the reclaimed tab returns to desktop size without a reload. The whole-PR diff (base to head) implements the browser part. In use-mobile-terminal-fit-actions.ts, restoreAllTerminalFits(focusPane, phoneIsDriving) runs reclaimMobileDrivenBrowserPagesForDesktop() when phoneIsDriving is true. That helper (browser-desktop-reclaim.ts) calls the existing per-page reclaim for each ID from getAllMobileDrivenBrowserPageIds() (browser-mobile-driver-state.ts, filters driver.kind === 'mobile'). The terminal path (restoreTerminalFitsToDesktop over getMobileOwnedTerminalPtyIds) is unchanged. The tests/e2e/phone-take-back-all-browser.spec.ts test asserts that the guest returns to desktop size. The PR also reports a manual run on this branch (tab at 914x1254 in 17 ms). The remaining issue requests (Emulation.setVisibleSize, viewportPresetId, live webview bounds, split-terminal PTY convergence) are not changed in this diff. The PR states that main already handles them: split terminals restore, and the non-drawing tab size was fixed in #41501. I did not read the main-process setVisibleSize path. That part rests on the author's reported run and the e2e spec, so this PASS depends on that evidence.
Full details: Out of Scope Changes check
Explanation
Every changed file serves the Take back all browser-reclaim objective. TerminalPaneMobileDriverPortals.tsx passes the phone-driving flag. use-mobile-terminal-fit-actions.ts adds the browser reclaim call, and its Restore-all path for held fits skips browser reclaim when phoneIsDriving is false. browser-desktop-reclaim.ts adds the per-page reclaim helper. browser-mobile-driver-state.ts adds a read-only selector over the existing driver map. tests/e2e/phone-take-back-all-browser.spec.ts covers the new behavior. The PR adds no main-process or IPC changes. The PR's stated non-goals (browser overlay Take back all button, remote-runtime tabs) are not implemented. No unrelated change was found in the reviewed diff.
Full details: Description check
Explanation
The description covers the ELI5, what changed, the mechanism and rationale, a linked issue (Fixes #40859), before/after visual proof, detailed manual and automated testing on macOS, a risk section with level and revert path, the review notes, and a checklist. The AI Disclosure section is empty, which the template allows for internal team members. The Visual Proof section uses before/after images, as the template requires. Its items are complete. The description is mostly complete and meets the template, so this check passes.
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 6cebc190-f39c-46e2-993d-ebfd55c560ac
Commits
Reviewing files that changed from the base of the PR and between a4ed629 and f03fc82.
Files selected for processing: 1
tests/e2e/phone-take-back-all-browser.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When your phone is using a terminal and a browser tab, clicking "Take back all" on the desktop now takes back the browser tab too. Before, it only took back the terminals, and the browser tab stayed locked and phone-sized.
What Changed
Carries the reclaim part of #40954 by @casualuser: making "Take back all" cover phone-driven browser tabs was their idea. The rest of #40954 (a post-suppression PTY resize pass, restoring
Emulation.setVisibleSize, a webview bounds resync) isn't needed on current main: split terminals already restore correctly, and the stuck browser size was fixed for non-drawing tabs in #41501. A paired-phone run on main confirmed both (details under Testing).Why
restoreAllTerminalFitsonly collected the PTY ids the phone held, so it never touched the browser driver map. The renderer already keeps that map for every page in every workspace, and main already owns a per-page reclaim, so the change only adds a loop over the driven pages next to the terminal loop. No new IPC, no main-side changes.Whether the browser overlay should also get a "Take back all" button is a separate UI question and isn't in this PR.
Linked Issue
Fixes #40859
Visual Proof
Browser tab right after clicking "Take back all" on the terminal overlay, with a fake phone driving both the terminal and the tab:
Testing
Tested on macOS with a hidden Electron e2e build and a paired fake phone: the same
terminal.subscribeandbrowser.screencast(390x844, mobile view) requests the Orca Mobile app sends, against a local http page.stty sizematched each pane. The browser tab stayed locked at 390x844.tests/e2e/phone-take-back-all-browser.spec.tsdrives that flow. It fails on main (the browser overlay stays) and passes here.tests/e2e/mobile-banner.spec.tsstill passes.Risk
Level: Low
The riskiest part: "Take back all" now ends the phone's browser stream as well. That is the intended behaviour, but a phone user browsing will see their stream stop when the desktop clicks it, as they already do for terminals. Renderer-only. Remote-runtime browser tabs are untouched, since their driver state never reaches this map. Older phones and hosts are unaffected, because main's reclaim path is unchanged. A plain revert backs it out.
AI Disclosure
Review
Two reviewers (Codex and a Claude subagent), one round. Fixed: held-fit "Restore all" no longer stops a live phone browser stream; the spec checks only the phone width, because main clamps the emulated height to the desktop guest; the spec now closes its server if pairing fails.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)