Repository navigation
test(e2e): pane-close specs close panes the way the user does and check main's copy (dark, layout-owner build only) - #30745
Conversation
…ck main's copy The pane-close consistency spec closed panes with a bare PaneManager.closePane, the drawing-layer call that never asks main. In a layout-owner build that close reached main only because killing the pane's terminal made main retire the pane; right after a reveal the terminal has not attached yet, so main kept the pane. Every user close path already sends the close to main first. The helpers now close through the pane close request the menu and shortcut use, and every scenario also checks that main's stored panes match the window's.
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
dd69ec05-b37f-48a3-a5da-ae8b01936a20
📒 Files selected for processing: 5
tests/e2e/helpers/main-terminal-layout.tstests/e2e/helpers/terminal-pane-operations.tstests/e2e/helpers/terminal.tstests/e2e/layout-stream-loss-reopen.spec.tstests/e2e/terminal-pane-close-layout-consistency.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| const raw = await page.evaluate( | ||
| (id) => | ||
| new Promise<unknown>((resolve, reject) => { | ||
| const timer = setTimeout(() => reject(new Error('main sent no layout snapshot')), 10_000) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,110p' tests/e2e/helpers/main-terminal-layout.ts
rg -n 'layout.subscribe|unsubscribe\(\)' tests/e2e/layout-stream-loss-reopen.spec.ts tests/e2e/helpers src/renderer | head -90Repository: stablyai/orca
Length of output: 11102
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- runtime subscribe definitions ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'function subscribe' -e 'const subscribe' -e 'subscribeRuntimeRpc' -e 'runtime.subscribe' src tests/e2e | head -120
printf '%s\n' '--- layout stream client ---'
sed -n '1,190p' src/renderer/src/runtime/runtime-layout-client.ts
printf '%s\n' '--- readMainLayout callers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'readMainLayout' -e 'expectMainHoldsWindowPanes' tests/e2eRepository: stablyai/orca
Length of output: 22429
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- lower-level subscription implementation and types ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'export async function subscribeRuntimeRpc' -e 'type Runtime' -e 'subscribe: ' -e 'runtime: {' src/renderer/src src/preload src/shared tests/e2e | head -100
sed -n '1,240p' src/renderer/src/runtime/runtime-rpc-subscribe.ts
printf '%s\n' '--- polling helper ---'
sed -n '145,190p' tests/e2e/terminal-pane-close-layout-consistency.spec.ts
printf '%s\n' '--- all direct readMainLayout call sites ---'
sed -n '45,78p' tests/e2e/layout-stream-loss-reopen.spec.tsRepository: stablyai/orca
Length of output: 15534
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- runtime API declaration and bridge ---'
sed -n '1,65p' src/preload/api/runtime-api.ts
sed -n '1,90p' src/preload/api/runtime-bridge.ts
printf '%s\n' '--- subscription dispatcher ---'
sed -n '1,220p' src/preload/runtime-environment-subscriptions.ts
printf '%s\n' '--- runtime subscription implementation references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'runtime.subscribe' -e 'subscribeRuntimeRequest' -e 'RuntimeSubscription' -e 'unsubscribe: () =>' src/main src/preload src/shared | head -160Repository: stablyai/orca
Length of output: 33420
🏁 Script executed:
set -o pipefail
rg -n -F --glob '*.ts' --glob '*.tsx' -e "'runtime:subscribe'" -e '"runtime:subscribe"' -e "'runtime:unsubscribe'" -e '"runtime:unsubscribe"' src/main src/preload src/sharedRepository: stablyai/orca
Length of output: 1803
🏁 Script executed:
set -o pipefail
sed -n '78,160p' src/main/ipc/runtime.ts
sed -n '110,165p' src/main/ipc/runtime-subscribe-lifecycle.test.ts
sed -n '245,335p' src/main/ipc/runtime-subscribe-lifecycle.test.tsRepository: stablyai/orca
Length of output: 8393
Unsubscribe on timeout, including a late-opened subscription.
When layout.subscribe opens but sends no snapshot, the timeout rejects without closing the stream. expectMainHoldsWindowPanes starts a new readMainLayout call during polling, so repeated timeouts can leave multiple subscriptions active.
A direct handle?.unsubscribe() in the timer is not sufficient. The subscription promise can resolve after the timer fires. Track the timeout and unsubscribe the handle both when the timer fires and when a late subscription resolves.
🔧 Suggested fix
- const timer = setTimeout(() => reject(new Error('main sent no layout snapshot')), 10_000)
let handle: { unsubscribe: () => void } | null = null
+ let timedOut = false
+ const timer = setTimeout(() => {
+ timedOut = true
+ handle?.unsubscribe()
+ reject(new Error('main sent no layout snapshot'))
+ }, 10_000)
let snapshot: unknown
...
})
.then((opened) => {
handle = opened
+ if (timedOut) {
+ opened.unsubscribe()
+ return
+ }
finish()
}, reject)| if (!target || panes.length < 2) { | ||
| return null | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '120,190p' tests/e2e/helpers/terminal-pane-operations.ts
sed -n '300,350p' tests/e2e/terminal-pane-close-layout-consistency.spec.ts
rg -n 'requestTerminalPaneClose|closeActiveTerminalPane' tests/e2eRepository: stablyai/orca
Length of output: 7534
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- caller blocks ---'
sed -n '1,380p' tests/e2e/terminal-pane-close-layout-consistency.spec.ts
printf '%s\n' '--- setup and assertion definitions ---'
rg -n -F --glob '*.ts' -e 'function setUpSplitTab' -e 'const setUpSplitTab' -e 'function waitForTabRemounted' -e 'const waitForTabRemounted' -e 'function expectLayoutConsistent' -e 'const expectLayoutConsistent' -e 'function createActiveTerminalTab' -e 'function parkHiddenTabBehindDecoy' tests/e2e
printf '%s\n' '--- helper callers and surrounding tests ---'
sed -n '1,230p' tests/e2e/helpers/terminal-pane-operations.ts
sed -n '1,230p' tests/e2e/terminal-pane-content-retention.spec.ts
sed -n '150,215p' tests/e2e/terminal-pane-layout-resize.spec.ts
sed -n '1,110p' tests/e2e/terminal-pane-binding-lifecycle.spec.tsRepository: stablyai/orca
Length of output: 36198
Assert that both panes are mounted before closing in the mid-reveal scenario.
waitForTabRemounted only confirms that the pane manager exists. requestTerminalPaneClose returns without dispatching the close event when fewer than two panes are mounted. The scenario then checks only the final one-pane state, so it can pass without proving that the close request ran.
Add a pane-count readiness assertion in this scenario. Keep the shared helper’s final-pane no-op behavior unchanged.
🔧 Suggested fix
await activateTerminalTab(orcaPage, tabId)
await waitForTabRemounted(orcaPage, tabId)
+ await expect
+ .poll(
+ () =>
+ orcaPage.evaluate(
+ (id) => window.__paneManagers?.get(id)?.getPanes().length ?? 0,
+ tabId
+ ),
+ {
+ timeout: 15_000,
+ message: `terminal tab ${tabId} did not mount both panes`
+ }
+ )
+ .toBeGreaterThanOrEqual(2)
// Close as soon as the manager exists — panes may still be attaching.
await requestTerminalPaneClose(orcaPage, tabId, 'last')
ELI5
A test that closes a split pane right after its tab is shown again failed in the layout-owner build. In that build the main process keeps the saved pane layout. The test removed the pane from the screen without telling the main process, so the main process kept the pane in its saved copy. Real closes made by the user (the pane menu, the keyboard shortcut, the tab bar) already tell the main process first, so users are not affected. This PR makes the test helpers close a pane the way a user does, and makes every scenario in the spec check that the main process's saved copy matches the screen.
Test-only change (dark, layout-owner build only: shipped builds are unchanged).
What Changed
tests/e2e/helpers/terminal-pane-operations.ts: newrequestTerminalPaneClose(page, tabId, 'active' | 'last'). It makes the target pane active and sends the same pane-close request the tab bar's "close split pane" item and the shortcut send, then waits for the pane to go.closeActiveTerminalPanenow uses it. It throws when the tab has no mounted terminal view.tests/e2e/terminal-pane-close-layout-consistency.spec.ts: every close goes through that request (the "same tick" scenario sends it inline and hides the tab without waiting). Every scenario, including the two where the shell exits on its own, now also checks that the main process's stored panes for the tab equal the window's.tests/e2e/helpers/main-terminal-layout.ts:readMainLayoutmoved here unchanged fromlayout-stream-loss-reopen.spec.ts, so both specs share it.Before, as a user would see it in the layout-owner build: nothing changes for users. Before, in the test: a pane closed by a direct call to the drawing layer right after the tab was revealed stayed in the main process's saved layout. After a relaunch it came back on screen and in
orca terminal list. After: the test closes through the user's path, and the saved layout matches the screen.Mechanism: the direct call (
PaneManager.closePane) only redraws the window. With the switch on, the only way it reached the main process was a side effect: removing the pane killed its terminal, and the main process removes a pane whose terminal exits. Right after a reveal, the pane's terminal has not reattached yet, so nothing is killed and the main process never hears of the close. Every user close goes throughexecuteClosePane(use-terminal-pane-close-actions.ts), which sends the close to the main process by pane id first and does not depend on the terminal being attached.Why
The failing step was not a path users can take. I checked every caller that removes a pane in the window. User closes, the exit path and the reconcile path all ask the main process first. The remaining direct calls apply something the main process already decided. A product change, such as making the drawing layer itself notify the main process, would send the main process's own closes back to it and add a second close path for no user-visible gain. The broader issue is the e2e helpers:
closeActiveTerminalPaneused the same direct call, so it is fixed too. Its three other users pass on both builds.Linked Issue
N/A (maintainer; layout-owner refactor follow-up).
Visual Proof
N/A: test-only change; no UI or behaviour change.
Testing
Repro (hidden windows, isolated profiles, switch on), with the old direct close right after a reveal: the main process kept 2 panes in 4 of 4 runs. Before a relaunch, the window,
orca terminal listand the phone-facing tab list each showed 1 pane. After a relaunch, the closed pane came back in the window and in the CLI list. The same flow through the user's close request: 1 pane everywhere, before and after relaunch, 4 of 4. With the switch off, both forms showed 1 pane everywhere.Failing first: the strengthened check, with the old direct close and the switch on, failed 4 of 6 runs ("main's stored panes differ from the window's"). It passed with the switch off.
After, switch on: the pane-close spec passed 21/21 (3 repeats) twice, and the reveal scenario passed 10/10.
terminal-pane-binding-lifecycle,terminal-pane-layout-resizeandterminal-pane-content-retentionpassed 9/9, andlayout-stream-loss-reopenpassed 2/2.After, switch off: the pane-close spec passed 21/21, and the three helper users passed 9/9.
layout-stream-loss-reopenis skipped (layout-owner build only, as on main).Save-divergence detector, switch on, same build, pane-close spec x4 plus the layout oracle: base 2 reports (
tab changed: panes, both at the quit checkpoint), head 0.Bundle diff, switch off, unminified, base vs head: identical except the source commit stamp, content hashes in file names, and one renderer manifest entry that moved because the manifest is ordered by hashed name.
pnpm tc, the e2e typecheck ratchet,check:code-quality:changed, the layout-writer and focus-read ratchets, the anti-slop lint and oxlint all pass. Full vitest (--maxWorkers=4): 61 failures in 13 files at head. 12 of those files fail the same way at base (60 failures). The 13th,daemon-init-provider-installation, had one failure under full-suite load and passes 14/14 on its own at head. None of these files is touched by this PR.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
One independent adversarial review: MERGE AS IS. It confirmed that no product path drops a user's close, and raised one low finding: the helper returned silently with no mounted view. That is fixed, and the delta review said MERGE AS IS.
Agent skill upstream boundary
Notes
Test-only. No effect on SSH, mobile, Windows or Linux code paths. The new assertion reads the main process's layout through the existing
layout.subscribemethod, which serves both builds.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)