Skip to content

fix(ssh): never start a hidden orcad shell for a tab the legacy relay bridge serves - #27939

Merged
OrcaWin merged 4 commits into
mainfrom
OrcaWin/bridge-followup-dup-shell
Oct 12, 2026
Merged

OrcaWin merged 4 commits into
mainfrom
OrcaWin/bridge-followup-dup-shell

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​172 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​172
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63

ELI5

After upgrading from 1.4.224, a terminal that the old relay still runs shows up in its old tab through the legacy relay bridge (#27787). But clicking that tab also told the new managed server (orcad) to start its own shell for the same pane. Nobody ever saw that second shell; it just kept running on the host. Now clicking the tab no longer starts it.

What Changed

Before: clicking a bridged tab, picking it from the palette, or switching to it with a tab-number shortcut sent session.tabs.activate to orcad. orcad sees a migrated pane with no terminal of its own, so it starts a fresh shell for that pane. The tab kept showing the relay terminal, so the new shell ran hidden. One wasted shell per bridged tab, every time it was activated before it had one.

After: those gestures skip the orcad activation for a pane the bridge serves. The tab still switches locally and still shows the old terminal. Sibling panes in the same tab, and every other tab, activate on orcad exactly as before. When the old terminal exits, the bridge drops the pane, and the next activation starts a normal orcad shell.

Mechanism: every user activation of a mirrored tab goes through one function, activateWebRuntimeSessionTab. It now asks the bridge's pane list (isLegacyRelayBridgedTab, the same tab-and-leaf matching the bridge transport already used, factored out) and returns early for a bridged pane. The pane's own mount path already went to the bridge and never reached orcad.

Why

  • orcad decides to start a shell only when a client activates a pane it has no terminal for. The lease that says "the relay still runs this pane" lives only on the desktop, so the desktop is the one place that can stop the request. Teaching orcad about relay leases would need a new RPC field and a new orcad build, and an older orcad would still start the shell.
  • The check covers both live and unverifiable bridged panes. A pane whose relay can't be reached right now is never treated as gone.

Linked Issue

Follow-up to #27787 (open item 1 from its author).

Visual Proof

N/A: nothing changes on screen. The only difference is a hidden process that no longer starts on the host.

Testing

  • Automated tests added/updated
  • New unit test web-runtime-session-legacy-relay-bridged-activation.test.ts. Written first, it failed on main because the activation reached orcad. It now passes. It also checks that a sibling pane and an unrelated tab still activate on orcad.
  • The Docker e2e ssh-orcad-legacy-relay-bridge.spec.ts now clicks the old tab in the tab strip after a new orcad terminal is opened. It checks that the old shell's screen is still shown, and that orcad still lists the migrated pane without a terminal of its own.
  • Locally: pnpm tc, pnpm lint, pnpm run check:code-quality:changed, oxlint, and focused vitest (the runtime session, tab group, palette and shortcut suites). No Docker or Electron was run locally; the e2e runs in CI.

Review

P0/P1 review: my own pass plus a codex reviewer (GPT-6.1 Sol), in parallel.

  • Codex P1, fixed: a click on a whole mirrored tab (web-terminal-<tab>, with no leaf named) did not match the bridged pane, so it still reached orcad. A click now resolves the pane on screen. If that pane is bridged, or no pane can be resolved, the activation is skipped. If the pane on screen is a sibling, the activation is aimed at it, so orcad never picks the bridged pane itself.
  • My pass, fixed: a skipped activation now also clears an earlier tab's pending focus. Otherwise that tab's late snapshot could pull focus back from the bridged tab.
  • Codex re-review of the fixes: no P0/P1.

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

  • Web and mobile clients have no bridge (window.api.legacyRelayBridge is undefined), so for them nothing changes.
  • No wire change. The renderer just skips one RPC.
  • The seam is tagged COMPAT(legacy-relay-bridge) and is removed with the bridge.

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 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dfba4bcc-1c53-4963-8de9-739d6be24bee

📥 Commits

Reviewing files that changed from the base of the PR and between 8f392313d4e49ed5e3dc4c068ff79a5ad729e3a7 and 07910aa.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 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: fd4af560-2dc6-4659-bbd6-1f0897e24a53

📥 Commits

Reviewing files that changed from the base of the PR and between fef6ab6 and ee6d728ba32e3346d4a3037a81af1a4d37d4f697.


📒 Files selected for processing (1)
  • src/renderer/src/runtime/web-runtime-session-tab-lifecycle.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.



📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds shared lookup helpers for legacy relay-bridged panes and uses them to detect bridged tab activation. Activation clears pending focus intent and skips the managed runtime call for bridged panes; other activations use the resolved leaf. New runtime tests cover bridged panes, sibling panes, and other tabs. The E2E test checks the bridged tab’s shell output and the status of matching managed-server panes.


Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to ee6d7

A leafless relay lease can suppress activation of a named sibling, and an early activation can miss the bridge inventory and start a hidden shell. These conditional failures affect the intended desktop activation behavior and should be fixed or explicitly accepted before merging.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title is concise, specific, and accurately describes the primary SSH activation fix.
Description check Passed The description is complete and focused. It explains the user impact, mechanism, rationale, linked issue, testing, visual proof, review notes, compatibility considerations, and checklist status.
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.

✨ 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: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 335ee2db-a7cf-4b19-8b8b-c809f61c2c84
📥 Commits

Reviewing files that changed from the base of the PR and between cfbf361 and fef6ab6.

📒 Files selected for processing (4)
  • src/renderer/src/components/terminal-pane/legacy-relay-bridge-panes.ts
  • src/renderer/src/runtime/web-runtime-session-legacy-relay-bridged-activation.test.ts
  • src/renderer/src/runtime/web-runtime-session-tab-lifecycle.ts
  • tests/e2e/ssh-orcad-legacy-relay-bridge.spec.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.

tabId: string,
leafId: string | null | undefined
): { inTab: LegacyRelayBridgedPane[]; leaf: string | null } {
ensureSubscribed()

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.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

set -o pipefail
printf '%s\n' '--- target module ---'
nl -ba src/renderer/src/components/terminal-pane/legacy-relay-bridge-panes.ts
printf '%s\n' '--- relevant symbols and callers ---'
rg -n -F --glob '*.{ts,tsx}' -- 'ensureSubscribed' src/renderer src/shared || test "$?" -eq 1
rg -n -F --glob '*.{ts,tsx}' -- 'onPanes' src/renderer src/shared || test "$?" -eq 1
rg -n -F --glob '*.{ts,tsx}' -- 'isLegacyRelayBridgedTab' src/renderer src/shared || test "$?" -eq 1
rg -n -F --glob '*.{ts,tsx}' -- 'hasLegacyRelayBridgedPane' src/renderer src/shared || test "$?" -eq 1
printf '%s\n' '--- bridge contract ---'
nl -ba src/shared/legacy-relay-bridge-contract.ts

Repository: stablyai/orca

Length of output: 29684


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- bridge API declarations and implementations ---'
rg -n -F --glob '*.{ts,tsx}' -- 'legacyRelayBridge' src/main src/preload src/renderer src/shared || test "$?" -eq 1
rg -n -F --glob '*.{ts,tsx}' -- 'listPanes' src/main src/preload src/renderer src/shared || test "$?" -eq 1
rg -n -F --glob '*.{ts,tsx}' -- 'onPanes' src/main src/preload src/renderer src/shared || test "$?" -eq 1
printf '%s\n' '--- activation lifecycle ---'
nl -ba src/renderer/src/runtime/web-runtime-session-tab-lifecycle.ts
printf '%s\n' '--- focused activation test ---'
nl -ba src/renderer/src/runtime/web-runtime-session-legacy-relay-bridged-activation.test.ts

Repository: stablyai/orca

Length of output: 41463


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- preload bridge API ---'
nl -ba src/preload/api/legacy-relay-bridge-api.ts
printf '%s\n' '--- preload subscription helper ---'
rg -n -F --glob '*.ts' -- 'function subscribe' src/preload
nl -ba src/preload/api/subscribe.ts 2>/dev/null || true
printf '%s\n' '--- main bridge IPC ---'
nl -ba src/main/ssh/legacy-relay-bridge/legacy-relay-bridge-ipc.ts
printf '%s\n' '--- main registry snapshot and notification wiring ---'
nl -ba src/main/ssh/legacy-relay-bridge/legacy-relay-bridge-registry.ts | sed -n '1,185p'

Repository: stablyai/orca

Length of output: 14445


Wait for the initial bridge inventory before evaluating activation.

onPanes only registers an IPC listener. It does not provide the current pane list. listPanes() resolves asynchronously, so activation can read the initial empty panes array. The bridge predicate then returns false and activateWebRuntimeSessionTab can call session.tabs.activate for a bridged pane.

Defer the activation decision until the initial inventory is available. Do not treat the pre-hydration empty list as proof that the pane is unbridged.

Comment on lines +70 to +71
inTab.find((pane) => pane.leafId === (leaf ?? '') || pane.leafId === leafId) ??
(inTab.length === 1 && !inTab[0].leafId ? inTab[0] : undefined)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- changed file ---'
nl -ba src/renderer/src/components/terminal-pane/legacy-relay-bridge-panes.ts | sed -n '1,180p'
printf '%s\n' '--- contract references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' 'leafId' src/shared src/renderer/src | rg 'legacy|relay|bridge|Lease|lease' | head -200 || true
printf '%s\n' '--- legacy relay contract ---'
rg -n -F --glob '*.ts' -- 'LegacyRelay' src/shared src/renderer/src | head -100 || true
printf '%s\n' '--- resolver and activation references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' 'isLegacyRelayBridgedTab' src || true
rg -n -F --glob '*.ts' --glob '*.tsx' 'legacyRelayBridgePtyIdForPane' src || true
rg -n -F --glob '*.ts' --glob '*.tsx' 'hasLegacyRelayBridgedPane' src || true
printf '%s\n' '--- tests mentioning leafless/sibling/migration ---'
rg -n -i --glob '*test*' --glob '*spec*' 'leafless|leafId|sibling|legacy.?relay|bridg|migration' src tests 2>/dev/null | head -300 || true

Repository: stablyai/orca

Length of output: 41971


🏁 Script executed:

set -eu
printf '%s\n' '--- contract ---'
nl -ba src/shared/legacy-relay-bridge-contract.ts
printf '%s\n' '--- activation lifecycle ---'
nl -ba src/renderer/src/runtime/web-runtime-session-tab-lifecycle.ts | sed -n '1,100p'
printf '%s\n' '--- focused activation test ---'
nl -ba src/renderer/src/runtime/web-runtime-session-legacy-relay-bridged-activation.test.ts | sed -n '1,220p'
printf '%s\n' '--- transport tests ---'
nl -ba src/renderer/src/components/terminal-pane/legacy-relay-bridge-transport.test.ts | sed -n '1,230p'
printf '%s\n' '--- bridge API and lease construction ---'
rg -n -F --glob '*.ts' --glob '*.tsx' 'legacyRelayBridge' src/main src/preload src/renderer src/shared | head -240 || true
rg -n -i --glob '*.ts' --glob '*.tsx' 'bridgedPane|BridgedPane|listPanes|onPanes|ptyId.*tabId|tabId.*ptyId' src/main src/preload src/renderer src/shared | head -300 || true

Repository: stablyai/orca

Length of output: 41371


Do not use a leafless lease to suppress named sibling activation.

When activation supplies a named leaf, bridgedPaneFor can return the tab's sole leafless lease through its fallback. activateWebRuntimeSessionTab then skips session.tabs.activate, so a managed sibling may not activate.

Use confirmed leaf identity for named activation targets. Preserve the leafless fallback for tab-level activation and the existing relay transport behavior.

🐛 Suggested fix
 export function isLegacyRelayBridgedTab(tabId: string, leafId?: string | null): boolean {
   const { inTab, leaf } = bridgedPanesInTab(tabId, leafId)
-  return leaf === null ? inTab.length > 0 : bridgedPaneFor(tabId, leafId) !== undefined
+  return leaf === null
+    ? inTab.length > 0
+    : inTab.some((pane) => pane.leafId !== undefined && pane.leafId === leaf)
 }

Comment on lines +83 to +87
.object({ result: z.object({ tabs: z.array(z.record(z.string(), z.unknown())) }) })
.parse(listed).result.tabs
return tabs
.filter((tab) => tab.type === 'terminal' && tab.parentTabId === tabId)
.map((tab) => String(tab.status))

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Require a status on each matching server pane.

z.record(z.string(), z.unknown()) accepts a matching terminal record without status. String(tab.status) then produces "undefined", so the no-ready assertion passes without checking a server status. Parse status as a required string for each record selected by the filter.

@OrcaWin
OrcaWin force-pushed the OrcaWin/bridge-followup-dup-shell branch 3 times, most recently from 51cff70 to 8f39231 Compare October 12, 2026 10:44
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