Skip to content

test(e2e): pane-close specs close panes the way the user does and check main's copy (dark, layout-owner build only) - #30745

Merged
Jinwoo-H merged 1 commit into
mainfrom
e2-6/close-on-reveal-reaches-main
Oct 19, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
e2-6/close-on-reveal-reaches-main

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​132 $\color{#cf222e}{\Huge{\mathbf{−}}}$​89 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​43
Prod 0 0 0 0

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: new requestTerminalPaneClose(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. closeActiveTerminalPane now 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: readMainLayout moved here unchanged from layout-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 through executeClosePane (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: closeActiveTerminalPane used 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 list and 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-resize and terminal-pane-content-retention passed 9/9, and layout-stream-loss-reopen passed 2/2.

  • After, switch off: the pane-close spec passed 21/21, and the three helper users passed 9/9. layout-stream-loss-reopen is 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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.subscribe method, which serves both builds.

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)

…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.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The changes add shared end-to-end test helpers to read main’s terminal layout and request terminal pane closure through the close event. Pane-close scenarios now check that main’s stored pane IDs match the window’s root leaf IDs. The layout-stream test uses the shared layout reader instead of a local implementation.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to af4a8

The pane-close tests may leave subscriptions open on timeout and may pass one reveal scenario without exercising a close. Correct these test gaps before relying on their results; shipped behavior is not shown to change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 5 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 identifies the main test changes and specifies their scope. It is somewhat long, but it remains concise and descriptive.
Description check Passed The description covers all required sections, explains the user-facing and technical changes, documents testing results and known unrelated failures, and addresses scope and compatibility.
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: 💡 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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd69ec05-b37f-48a3-a5da-ae8b01936a20
📥 Commits

Reviewing files that changed from the base of the PR and between 36913fd and af4a800.

📒 Files selected for processing: 5
  • tests/e2e/helpers/main-terminal-layout.ts
  • tests/e2e/helpers/terminal-pane-operations.ts
  • tests/e2e/helpers/terminal.ts
  • tests/e2e/layout-stream-loss-reopen.spec.ts
  • tests/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)

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 | 🟡 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 -90

Repository: 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/e2e

Repository: 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.ts

Repository: 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 -160

Repository: 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/shared

Repository: 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.ts

Repository: 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)

Comment on lines +150 to +152
if (!target || panes.length < 2) {
return null
}

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

🔎 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/e2e

Repository: 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.ts

Repository: 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')

@Jinwoo-H
Jinwoo-H merged commit b358328 into main Oct 19, 2026
52 checks passed
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