Repository navigation
Prevent mobile worktree selection from focusing desktop - #6461
Conversation
Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughThis change adds an optional client-notification flag to 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/worktree/mobile-worktree-activation-source.test.ts (1)
4-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument why this test inspects source text.
Reading the TSX file and asserting on string slices is a non-obvious constraint for a test. Add a short
Why:comment so future refactors do not replace it with a behavior-only test and lose this payload-shape guard.Suggested change
-const source = readFileSync(new URL('../../app/h/[hostId]/index.tsx', import.meta.url), 'utf8') +// Why: this locks the mobile activation call shape so regressions do not +// reintroduce paired-client notifications during session opens. +const source = readFileSync(new URL('../../app/h/[hostId]/index.tsx', import.meta.url), 'utf8')As per coding guidelines, when TS/TSX code is driven by a non-obvious constraint, add a short comment explaining why.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8138bd27-1940-414f-aa61-22bd995bf840
📒 Files selected for processing (12)
mobile/app/h/[hostId]/index.tsxmobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/session/mobile-session-startup-source.test.tsmobile/src/worktree/mobile-worktree-activation-source.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/worktree-schemas.tssrc/main/runtime/rpc/methods/worktree.test.tssrc/main/runtime/rpc/methods/worktree.tssrc/renderer/src/lib/worktree-activation-created-agent.test.tssrc/renderer/src/lib/worktree-activation.tssrc/renderer/src/runtime/web-runtime-session.test.tssrc/renderer/src/runtime/web-runtime-session.ts
Co-authored-by: Orca <[email protected]>
|
Updated this PR with a second fix from physical-device repro. What changed:
Why: the first fix kept Verification:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mobile/app/h/[hostId]/session/[worktreeId].tsx (1)
2773-2808: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winAvoid bypassing
notifyClients: falsewithterminal.focus.Line 2802 still sends
terminal.focusbefore the silencedsession.tabs.activate; the adjacent comment says this makes desktop follow the mobile active terminal. That can still move paired desktop focus when switching terminal tabs, defeating the phone-local activation path.Proposed fix
- // Why: unsubscribe the old terminal so the server restores its desktop dims - // (clearing the phone-fit banner), then subscribe the new terminal with the - // measured viewport so the server phone-fits it. Also call terminal.focus - // so the desktop renderer follows the mobile user's active terminal. + // Why: unsubscribe the old terminal so the server restores its desktop dims + // (clearing the phone-fit banner), then subscribe the new terminal with the + // measured viewport so the server phone-fits it. const switchTab = useCallback( @@ subscribeToTerminal(handle) if (client) { - void client.sendRequest('terminal.focus', { terminal: handle }).catch(() => {}) if (matchingTab) { void client .sendRequest('session.tabs.activate', {
🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/session-tabs.ts (1)
31-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument why mobile activation can suppress client notifications.
This
notifyClients !== falsebranch is a non-obvious mobile-only exception. Please add a short comment thatfalseis used to hydrate phone-local session state without stealing focus on paired desktop clients.Suggested diff
handler: async (params, { runtime }) => + // Mobile-only activation hydrates phone state without switching focus on paired desktops. runtime.activateMobileSessionTab(params.worktree, params.tabId, params.leafId, { notifyClients: params.notifyClients !== false })Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8e9302c0-6a67-4a12-9f60-c7d3d23e41e4
📒 Files selected for processing (7)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/session/mobile-session-startup-source.test.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/session-tabs-schemas.tssrc/main/runtime/rpc/methods/session-tabs.test.tssrc/main/runtime/rpc/methods/session-tabs.ts
Co-authored-by: Orca <[email protected]>
Summary
notifyClientsoption toworktree.activateso paired clients can hydrate session surfaces without broadcasting a desktop worktree switch.notifyClients: falsefrom mobile worktree/session activation and paired-web activation paths.Linear
STA-894: https://linear.app/stably/issue/STA-894/prevent-mobile-worktree-selection-from-switching-desktop-workspace
Verification
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/runtime/web-runtime-session.test.ts src/renderer/src/lib/worktree-activation-created-agent.test.ts src/main/runtime/rpc/methods/worktree.test.tspnpm exec vitest run src/session/mobile-session-startup-source.test.ts src/worktree/mobile-worktree-activation-source.test.tsfrommobile/pnpm exec oxlint src/main/runtime/rpc/methods/worktree-schemas.ts src/main/runtime/rpc/methods/worktree.ts src/main/runtime/orca-runtime.ts src/renderer/src/runtime/web-runtime-session.ts src/renderer/src/lib/worktree-activation.ts src/main/runtime/rpc/methods/worktree.test.ts src/renderer/src/runtime/web-runtime-session.test.ts src/renderer/src/lib/worktree-activation-created-agent.test.ts 'mobile/app/h/[hostId]/index.tsx' 'mobile/app/h/[hostId]/session/[worktreeId].tsx' mobile/src/session/mobile-session-startup-source.test.ts mobile/src/worktree/mobile-worktree-activation-source.test.tspnpm exec tsgo --noEmit -p config/tsconfig.node.jsonpnpm exec tsgo --noEmit -p config/tsconfig.tc.web.jsonpnpm exec tsc --noEmitfrommobile/git diff --checkPhysical phone check
Made with Orca 🐋