Skip to content

fix(mobile): open a worktree on the tab the desktop is showing - #31215

Merged
AmoabaKelvin merged 1 commit into
mainfrom
open-worktree-on-desktop-tab
Oct 20, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
open-worktree-on-desktop-tab

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

ELI5

Opening a workspace on the phone always showed its terminal, even when you were in a chat on the desktop. Now the phone opens on whatever the desktop is showing.

What Changed

Before: you open a worktree or folder workspace on the phone and land on its first tab, which is nearly always the terminal it started with, whatever the desktop has open.

After: the phone lands on the tab the desktop is showing. If you have already picked a tab in that workspace on the phone, you land on that tab, as before.

How it works: the desktop host keeps a separate tab selection per paired phone, per workspace, and that selection decides which tab the phone opens. A phone that hadn't picked a tab yet started from an empty selection, which falls back to the first tab. ClientSessionTabSelectionStore.project() now uses the host's current tab for a phone that hasn't picked one in that workspace. It checks again on every open, so leaving, switching tabs on the desktop and reopening follows the desktop.

Why

The phone always opens on the tab the host marks as active. The empty starting selection came from #9664, which stopped devices from moving each other's tabs. That protection holds: once you're inside a workspace the phone keeps its own tab, and paired desktop clients ignore active-tab changes they didn't request (#5435). So the desktop switching tabs still never moves a phone that's already open.

I considered seeding the selection once, the first time the host builds the phone's view. That froze on whatever the desktop showed at that moment, which is often when the phone first connects, so a later open could still land on a stale tab.

The change lives on the desktop host, so it ships with the desktop release. The phone (over-the-air page included) needs no update. A phone paired to a desktop that hasn't updated keeps the old behaviour.

Linked Issue

None.

Visual Proof

N/A: no visual change. The phone opens on a different, already-existing tab. The unit tests cover this.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

The old unit test required a new phone to ignore the desktop's tab. It's replaced by two tests: a phone with no pick follows the desktop, including after the desktop moves, and a phone's own pick survives the desktop moving. The multi-client navigation integration test passes unchanged apart from a comment. Not yet tried on a real phone.

AI Disclosure

Review

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

Host-side only. The same path serves local, SSH and orca serve hosts, and git worktrees and folder workspaces alike. No wire change, so older phones get the fix as soon as their host updates.

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)
  • 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)

A phone with no pick in a worktree fell back to the first tab, nearly always
the starting terminal. It now follows the host's tab until the phone picks one.
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The selection store now derives an uninitialized device’s tab from the host’s focused tab. It continues to follow host focus changes until the device makes an explicit selection. The store uses persisted selection after it is marked for persistence and retains an explicit selection when its active tab is absent from a transient snapshot. Tests cover these behaviors. An integration-test comment was also updated; its logic is unchanged.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to e8d8e

An open phone can unexpectedly switch tabs when the desktop changes tabs. Keep the phone’s tab stable during its visit while still using the desktop’s current tab on the next open before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the user impact, implementation, rationale, testing, and compatibility scope. It does not provide the required linked issue and leaves the AI Disclosure and Review sections em… Add a valid linked issue under “Linked Issue,” unless the author is a maintainer covered by the template exception. Complete the AI Disclosure and Review sections, or state why they are not applicable.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: opening a mobile worktree on the desktop's active tab.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
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: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files.

Full details: Description check

Explanation

The description explains the user impact, implementation, rationale, testing, and compatibility scope. It does not provide the required linked issue and leaves the AI Disclosure and Review sections empty.

Resolution

Add a valid linked issue under “Linked Issue,” unless the author is a maintainer covered by the template exception. Complete the AI Disclosure and Review sections, or state why they are not applicable.

✨ Finishing Touches
📝 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
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 07258c0e-1a62-479c-b8e0-1e045b08e37d
📥 Commits

Reviewing files that changed from the base of the PR and between 0a5a7b1 and e8d8e1b.

📒 Files selected for processing: 3
  • src/main/runtime/client-session-tab-selection.test.ts
  • src/main/runtime/client-session-tab-selection.ts
  • src/main/runtime/multi-client-navigation-isolation.integration.test.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.

@AmoabaKelvin
AmoabaKelvin merged commit be29644 into main Oct 20, 2026
40 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the open-worktree-on-desktop-tab branch October 20, 2026 23:12
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