Repository navigation
fix(ssh): never start a hidden orcad shell for a tab the legacy relay bridge serves - #27939
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
📥 Commits
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to 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 |
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
335ee2db-a7cf-4b19-8b8b-c809f61c2c84
📒 Files selected for processing (4)
src/renderer/src/components/terminal-pane/legacy-relay-bridge-panes.tssrc/renderer/src/runtime/web-runtime-session-legacy-relay-bridged-activation.test.tssrc/renderer/src/runtime/web-runtime-session-tab-lifecycle.tstests/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() |
There was a problem hiding this comment.
🩺 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.tsRepository: 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.tsRepository: 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.
| inTab.find((pane) => pane.leafId === (leaf ?? '') || pane.leafId === leafId) ?? | ||
| (inTab.length === 1 && !inTab[0].leafId ? inTab[0] : undefined) |
There was a problem hiding this comment.
🎯 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 || trueRepository: 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 || trueRepository: 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)
}| .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)) |
There was a problem hiding this comment.
🎯 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.
51cff70 to
8f39231
Compare
…b's pending focus
8f39231 to
07910aa
Compare
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.activateto 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
liveandunverifiablebridged 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
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.ssh-orcad-legacy-relay-bridge.spec.tsnow 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.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.
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.Agent skill upstream boundary
Notes
window.api.legacyRelayBridgeis undefined), so for them nothing changes.COMPAT(legacy-relay-bridge)and is removed with the bridge.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)