Skip to content

fix(session-tabs): apply a paired client's tab pin and color when a window is open - #29346

Closed
Jinwoo-H wants to merge 2 commits into
mainfrom
fix/phone-tab-props-with-window
Closed

Jinwoo-H wants to merge 2 commits into
mainfrom
fix/phone-tab-props-with-window

Conversation

@Jinwoo-H

Copy link
Copy Markdown
Contributor

ELI5

When you pin or recolor a tab from a paired client (the web client on your phone, or another computer paired to this one), the change now shows up on the desktop and comes back to the client. Before, nothing happened whenever the Orca window was open.

What Changed

Before: with the desktop window open, a paired client's pin or color request returned success, but the desktop tab did not change and the client's tab list never showed it. With no window open (a headless server), it already worked.

After: the desktop tab gets the pin and color immediately, and the tab list sent back to paired clients carries them, so the client shows them too.

Mechanism:

  • The host process used to return early when a window was open, because the window owns tab state and would overwrite a write made behind its back. It now hands the change to the window, the same way moving a tab from a paired client already works (moveSessionTab). The window applies it with the same store actions as the desktop's own pin and color controls.
  • The tab list the window publishes to paired clients now includes each terminal tab's color and pin. A headless host already sends these fields, so older clients already understand them.
  • Only color and pin are passed to the window. A client's chat/terminal view toggle is still not applied to the desktop, so a client cannot flip the pane someone is looking at on the desktop. That behavior is unchanged.

Why

The window is the source of truth for tab state while it is open, so the change has to go through it. Writing to the saved session in the host process would be overwritten on the window's next publish. The alternative of letting the host process own pin and color while a window is open would create two owners for the same state. Handing the change to the window reuses the existing path for moving tabs and needs no protocol change. The RPC is unchanged, and older clients and hosts behave as before.

Linked Issue

Fixes #

Visual Proof

Hidden dev app (ORCA_BACKGROUND_LAUNCH=1) with a window open, plus a runtime-paired client calling session.tabs.setTabProps with an orange color and pin on the same terminal tab.

Before: the call returns {updated: true}, but the tab is unchanged on the desktop and the client sees no color or pin.
before

After: the desktop tab shows the pin icon and the orange dot, and the client's next session.tabs.list returns color: "#ff8800", isPinned: true.
after

Testing

  • I manually tested these changes locally (macOS, hidden window, paired client; before and after on the same profile)

  • Automated tests added/updated, or explained why not below

  • New: mobile-session-tab-appearance-window.spec.ts. It fails before the fix (the window is never told) and passes after. It also checks that a view-mode-only change is not forwarded.

  • New: session-tab-appearance-ipc-bridge.test.ts. The window applies pin and color, and the published client tab list carries them. It fails without the projection change.

  • The existing headless (no window) tests are unchanged and pass. src/main/runtime, src/main/window, src/renderer/src/hooks, src/renderer/src/runtime, and the tabs and terminal store tests all pass (16.8k tests). pnpm tc and check:code-quality:changed are clean.

  • SSH workspaces on a host with a window take the same window path. Their tabs are local to the host window, so no extra request is sent.

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

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

The native phone app cannot call this RPC (it is not on the phone allowlist). The callers are the web client and paired desktops. A paired desktop that already has the tab keeps its own color and pin until it reloads. That limit predates this change.

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)

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The runtime now forwards mobile session-tab color and pin changes to an authoritative window through a new appearance event. The preload API exposes the event subscription, and the renderer updates matching tabs. Mobile terminal snapshots now include color and pin state. Tests cover runtime forwarding, renderer updates, and the new IPC subscription.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to b2a83

Some paired clients may continue to see the old pin state after changing a terminal tab’s pin. The issue is bounded, but should be fixed or explicitly accepted before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 22 files. 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 clearly and concisely describes the main change: applying paired-client tab pin and color updates when a window is open.
Description check Passed The description directly explains the reported behavior, implementation, testing, compatibility considerations, and user-visible result.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch fix/phone-tab-props-with-window
  • 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: 08738354-f402-4364-a6e7-3dca7cdda77a
📥 Commits

Reviewing files that changed from the base of the PR and between 9be9d11 and b2a83d2.

📒 Files selected for processing: 22
  • src/main/runtime/orca-runtime-tests/mobile-session-tab-appearance-window.spec.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/runtime-notifier-contract.ts
  • src/main/runtime/session-tabs/headless-terminal-tab-close.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-agent-status-window-test-fixtures.ts
  • src/renderer/src/hooks/ipc-events-close-routing-test-harness.ts
  • src/renderer/src/hooks/ipc-events-terminal-create-window-test-fixtures.ts
  • src/renderer/src/hooks/ipc-events/session-tab-appearance-ipc-bridge.test.ts
  • src/renderer/src/hooks/ipc-events/session-tab-ipc-bridge.ts
  • src/renderer/src/hooks/useIpcEvents-browser-tab-create.test.ts
  • src/renderer/src/hooks/useIpcEvents-cli-worktree-activation.test.ts
  • src/renderer/src/hooks/useIpcEvents-close-routing-browser-pages.test.ts
  • src/renderer/src/hooks/useIpcEvents-lifecycle.test.ts
  • src/renderer/src/hooks/useIpcEvents-ssh-disconnect-cleanup.test.ts
  • src/renderer/src/hooks/useIpcEvents-updater-status.test.ts
  • src/renderer/src/runtime/sync-runtime-graph/mobile-session-terminal-tabs.ts
  • src/renderer/src/web/preload-api/web-ui-api.ts
  • src/shared/runtime-session-contracts.ts
  • src/shared/runtime-types.ts

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

Comment on lines +127 to +155

unsubs.push(
window.api.ui.onSetSessionTabAppearance(({ worktreeId, tabId, color, isPinned }) => {
const localTabId = resolveWindowTabIdForHostTab(worktreeId, tabId)
const store = useAppStore.getState()
const tabs = store.unifiedTabsByWorktree[worktreeId] ?? []
// Browser and editor rows may be keyed by their entity (workspace or file) id.
const tab =
tabs.find((candidate) => candidate.id === localTabId) ??
tabs.find((candidate) => candidate.entityId === localTabId)
if (!tab) {
return
}
if (color !== undefined && color !== tab.color) {
if (tab.contentType === 'terminal') {
store.setTabColor(tab.entityId, color)
} else {
store.setUnifiedTabColor(tab.id, color)
}
}
if (isPinned !== undefined && isPinned !== Boolean(tab.isPinned)) {
if (isPinned) {
store.pinTab(tab.id)
} else {
store.unpinTab(tab.id)
}
}
})
)

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '110,165p' src/renderer/src/hooks/ipc-events/session-tab-ipc-bridge.ts
sed -n '105,140p' src/renderer/src/runtime/sync-runtime-graph/mobile-session-terminal-tabs.ts
rg -n 'setTabColor:|setUnifiedTabColor:|pinTab:|unpinTab:' src/renderer/src

Repository: stablyai/orca

Length of output: 7038


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- resolver and handler references ---'
rg -n -F -- 'resolveWindowTabIdForHostTab' src/renderer/src
rg -n -F -- 'onSetSessionTabAppearance' src/renderer/src
printf '%s\n' '--- action implementations ---'
sed -n '1,230p' src/renderer/src/store/terminals/terminal-tab-appearance.ts
sed -n '100,210p' src/renderer/src/store/slices/tabs/tabs-label-actions.ts
printf '%s\n' '--- terminal tab construction and types ---'
rg -n -F -- 'entityId:' src/renderer/src/store src/renderer/src/runtime/sync-runtime-graph src/renderer/src/hooks/ipc-events | head -80
rg -n -F -- 'contentType: ' src/renderer/src/store src/renderer/src/runtime/sync-runtime-graph | head -80
printf '%s\n' '--- appearance fixtures and assertions ---'
rg -n -F -- 'mobile-session-tab-appearance-window' .
rg -n -F -- 'setTabColor' src/renderer/src/hooks src/renderer/src/runtime src/renderer/src -g '*session*appearance*' -g '*.test.ts' -g '*.spec.ts' -g '*.tsx'
rg -n -F -- 'isPinned' src/renderer/src/hooks src/renderer/src/runtime/sync-runtime-graph -g '*session*appearance*' -g '*.test.ts' -g '*.spec.ts'

Repository: stablyai/orca

Length of output: 36417


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- host-session-tab-target.ts ---'
nl -ba src/renderer/src/hooks/ipc-events/host-session-tab-target.ts
printf '%s\n' '--- session appearance test ---'
nl -ba src/renderer/src/hooks/ipc-events/session-tab-appearance-ipc-bridge.test.ts
printf '%s\n' '--- terminal creation ---'
nl -ba src/renderer/src/store/terminals/terminal-tab-creation.ts | sed -n '165,215p'
printf '%s\n' '--- tab patch helpers ---'
rg -n -F -- 'function patchTerminalTabRow' src/renderer/src
rg -n -F -- 'function findRenamableUnifiedTab' src/renderer/src
rg -n -F -- 'function patchTab' src/renderer/src/store
printf '%s\n' '--- runtime event registration and relevant caller ---'
nl -ba src/renderer/src/hooks/ipc-events/session-tab-ipc-bridge.ts | sed -n '1,175p'
rg -n -F -- 'emitSetSessionTabAppearance' src || test "$?" -eq 1
rg -n -F -- 'setSessionTabAppearance' src/main src/renderer/src | head -100

Repository: stablyai/orca

Length of output: 16886


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- terminal row patch and unified lookup helpers ---'
nl -ba src/renderer/src/store/slices/tabs/tabs-host-mirroring.ts
nl -ba src/renderer/src/store/terminals/renamable-unified-tab.ts
nl -ba src/renderer/src/store/slices/tab-group-state.ts | sed -n '220,260p'
printf '%s\n' '--- host/local mapping implementation ---'
nl -ba src/renderer/src/runtime/web-session-tabs-sync/tracking-mappings.ts
rg -n -F -- 'resolveLocalTabIdForHostSessionTab' src/renderer/src
printf '%s\n' '--- terminal creation callers and IDs ---'
rg -n -F -- 'createTab(' src/renderer/src/store/terminals src/renderer/src/store/slices | head -100
rg -n -F -- 'createTerminalTab' src/renderer/src/store src/renderer/src/hooks src/renderer/src/runtime
printf '%s\n' '--- terminal/unified reconciliation ---'
rg -n -F -- 'tabsByWorktree' src/renderer/src/store/slices/tabs-model-reconciliation.ts src/renderer/src/store/slices -g 'tabs-model-reconciliation.ts' -g '*reconcil*.ts'
rg -n -F -- 'entityId === terminal.id' src/renderer/src
rg -n -F -- 'contentType: '\''terminal'\''' src/renderer/src/store -g '*.ts' | head -100

Repository: stablyai/orca

Length of output: 41810


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- terminal location ---'
nl -ba src/renderer/src/store/terminals/terminal-tab-location.ts
printf '%s\n' '--- tabs reconciliation ---'
nl -ba src/renderer/src/store/slices/tabs/tabs-reconciliation.ts
printf '%s\n' '--- explicit terminal id/entityId pairs ---'
python3 - <<'PY'
from pathlib import Path
import re
for p in Path('src/renderer/src').rglob('*.ts'):
    text = p.read_text(errors='replace')
    if "contentType: 'terminal'" not in text:
        continue
    lines = text.splitlines()
    for i, line in enumerate(lines):
        if "contentType: 'terminal'" in line:
            block = '\n'.join(lines[max(0,i-8):min(len(lines),i+8)])
            if re.search(r'\bid:\s*[^\n,}]+', block) and re.search(r'\bentityId:\s*[^\n,}]+', block):
                print(f'--- {p}:{i+1} ---')
                print(block)
PY
printf '%s\n' '--- reconciliation tests around terminal identity ---'
rg -n -F -- 'entityId:' src/renderer/src/store/slices/tabs-model-reconciliation.test.ts
rg -n -F -- 'id:' src/renderer/src/store/slices/tabs-model-reconciliation.test.ts | head -80

Repository: stablyai/orca

Length of output: 41606


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- pin actions exact block ---'
nl -ba src/renderer/src/store/slices/tabs/tabs-label-actions.ts | sed -n '125,212p'
printf '%s\n' '--- canonical runtime/unified fixture ---'
nl -ba src/renderer/src/store/slices/terminals-hydration-canonical-rows.test.ts | sed -n '1,215p'
printf '%s\n' '--- mobile terminal snapshot fields ---'
nl -ba src/renderer/src/runtime/sync-runtime-graph/mobile-session-terminal-tabs.ts | sed -n '100,132p'
printf '%s\n' '--- reachable appearance producer ---'
nl -ba src/main/window/runtime-window-lifecycle.ts | sed -n '168,190p'
nl -ba src/main/runtime/session-tabs/headless-terminal-tab-close.ts | sed -n '245,280p'
printf '%s\n' '--- changed diff context ---'
git diff 01800a092a94da1ed309a0590004b1350bf12cc4 b2a83d23ec75ee5dfd7db88d426e9ef1f2572b3f -- src/renderer/src/hooks/ipc-events/session-tab-ipc-bridge.ts src/renderer/src/store/slices/tabs/tabs-label-actions.ts

Repository: stablyai/orca

Length of output: 19877


Use the terminal entity ID when mirroring pin state.

pinTab and unpinTab receive the unified tab ID, but patchTerminalTabRow looks up tabsByWorktree by the terminal row ID. Canonical terminal tabs can have different IDs. The unified tab becomes pinned, but the terminal parent remains unpinned, so the mobile snapshot can publish a stale isPinned value.

Suggested fix
-          ...patchTerminalTabRow(state.tabsByWorktree, tabId, { isPinned: true }),
+          ...patchTerminalTabRow(
+            state.tabsByWorktree,
+            tab.contentType === 'terminal' ? tab.entityId : tabId,
+            { isPinned: true }
+          ),
-          ...patchTerminalTabRow(state.tabsByWorktree, tabId, { isPinned: false }),
+          ...patchTerminalTabRow(
+            state.tabsByWorktree,
+            tab.contentType === 'terminal' ? tab.entityId : tabId,
+            { isPinned: false }
+          ),

@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Closing per owner decision. This bug is minor (tab pin and colour from the web client or a paired desktop), and the single-copy layout refactor fixes it by design: with C6, main owns tab properties. We are not taking a one-off fix in the old window-forwarding path. The finding is logged for the refactor's verification.

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