Skip to content

test(layout-owner): switch-on edge-case tests against #52149 (C3, C4) - #52196

Merged
Jinwoo-H merged 1 commit into
layout-owner-c3-c4-server-framesfrom
layout-owner-c3-c4-adversarial-tests
Nov 29, 2026
Merged

Jinwoo-H merged 1 commit into
layout-owner-c3-c4-server-framesfrom
layout-owner-c3-c4-adversarial-tests

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Tests only (no product code changes) exercising the C3 and C4 fixes in #52149 across disconnect/reconnect, server closes (focused, split, last-tab, mid-start), same-ID close+recreate, multi-client agreement (two desktops + phone), server restart rebinding, and 200-workspace scale. Several tests fail against #52149 and expose real gaps in frame-dropped tab retirement and stream removal.

Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1850 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1850
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

Before / after

Scenario Result on #52149
CLI terminal created on an unopened workspace while desktop is disconnected, then reconnect PASS (unit + E2E) — appears from frames before visiting the workspace and shows offline output when opened
Server restart while a tab is open on desktop (plus an unopened workspace tab) PASS (E2E) — rebinds to the original PTY PID with no ghost or lost terminal
Two paired desktops plus a phone creating and closing tabs in turn PASS (E2E) — all clients and server converge with no leftover ptyIdsByTabId
Server with 200 workspaces (startup, frame apply, laziness in unopened workspaces) PASS (unit + E2E) — 200 real workspaces finish in 18s; zero panes mounted, zero pending starts, zero seeded tabs or extra PTYs in the 199 unopened workspaces
Server closes the last focused tab in the active workspace FAIL (unit + E2E) — buildLayoutFrameStorePatch never clears global activeTabId, and shouldRepairActiveTerminalTab skips repair when tabs.length === 0, leaving activeTabId pointing at the deleted tab permanently
Server closes and recreates a tab with the same ID while desktop is disconnected (or coalesced into one flush) FAIL (unit + E2E) — droppedTerminalTabRecordsPatch sees kept.has(tab.id) === true and mergeTerminalRow preserves existing.ptyId, so both tab.ptyId and ptyIdsByTabId[tabId] permanently retain the dead pre-disconnect PTY (and old localOnlyScrollbackByTabId) even after the new PTY attaches and echoes output
Server closes one pane of a split tab (unit patch check) FAIL (unit; E2E passes via React pane unmount cleanup) — droppedTerminalTabRecordsPatch only inspects whole dropped tabs, leaving the closed pane's PTY in ptyIdsByTabId and leaf scrollback in localOnlyScrollbackByTabId at the frame-patch layer
Server closes a tab mid-start PASS for terminalPaneStartsByPaneKey (unit); FAIL for pendingStartupByTabId (unit) — droppedTerminalTabRecordsPatch does not retire pendingStartupByTabId
Server emits a removed workspace frame FAIL (unit) — workspace-layout-frame-sync.ts skips keys missing from cache on flush (if (!layout) continue), leaving tabsByWorktree, terminalLayoutsByTabId, ptyIdsByTabId, and localOnlyScrollbackByTabId stranded

Mechanism

  • Unit tests (added to config/scripts/ci/layout-owner/switch-on-unit-tests.txt):
    • src/renderer/src/store/workspace-layout/frames/frame-dropped-terminal-tab-records.test.ts (5 tests: 4 fail, 1 pass)
    • src/renderer/src/runtime/workspace-layout/server/server-layout-frames-lifecycle.test.ts (6 tests: 2 fail, 4 pass)
  • Switch-on E2E specs (added to .github/workflows/layout-owner-switch-on.yml e2e-paired):
    • tests/layout-owner-e2e/paired-server-frames-disconnect-and-restart.spec.ts (2 tests: 2 pass)
    • tests/layout-owner-e2e/paired-server-frames-close-and-reopen.spec.ts (2 tests: 2 fail — last focused tab stale activeTabId, and disconnected same-ID close+recreate keeping dead PTY on both tab.ptyId and ptyIdsByTabId)
    • tests/layout-owner-e2e/paired-two-desktops-and-phone-tabs.spec.ts (1 test: 1 pass)
    • tests/layout-owner-e2e/paired-server-frames-many-workspaces.spec.ts (1 test: 1 pass)

How it was tested

Switch on (ORCA_LAYOUT_OWNER=main, ORCA_SERVER_LAYOUT_OWNER=main, exported and logged), darwin, hidden windows (ORCA_BACKGROUND_LAUNCH=1), foreground runs with timeouts:

  • Unit tests (pnpm test ... --maxWorkers=2): 11 tests run — 5 passed, 6 failed for the real reasons above.
  • E2E tests (playwright test --config tests/layout-owner-playwright.config.ts --project electron-headless --workers=1):
    • paired-server-frames-disconnect-and-restart.spec.ts: 2/2 passed (50.4s) (an earlier attempt briefly hit the shared Mac's host-wide 256-terminal cap; subsequent full run passed cleanly)
    • paired-server-frames-close-and-reopen.spec.ts: 0/2 passed (2 real failures reproduced in Electron: stale activeTabId on last-tab close, and stale pre-disconnect PTY kept on both tab.ptyId and ptyIdsByTabId after same-ID recreate)
    • paired-two-desktops-and-phone-tabs.spec.ts: 1/1 passed (35.9s)
    • paired-server-frames-many-workspaces.spec.ts: 1/1 passed (18.0s)
  • Static checks: pnpm run typecheck:ci, pnpm run check:e2e-typecheck-ratchet, oxlint (default, code-quality-native, js-plugins), oxfmt --check, ast-grep, check:max-lines-ratchet, check:flaky-test-pattern-ratchet, check:layout-writer-ratchets, check:test-file-runners, check:path-literal-ratchet — all clean.

Visible changes

None (tests and switch-on lane wiring only; no product code modified).

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · The PR appears safe to merge, with two non-blocking gaps in what the new E2E tests prove.RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The changes reach test execution, not app runtime behavior.

The PR appears safe to merge, with two non-blocking gaps in what the new E2E tests prove.

Findings

  1. P2 Mid-start case may never start ▶
  2. P2 Binding cleanup can pass unchecked ▶

Summary

Adds unit and paired-client tests for server-created and server-closed tabs, plus switch-on CI wiring.

  • Server-frame tests check cleanup when tabs and workspaces close.
  • Reconnect tests check terminals created while the desktop is away.
  • Two desktops and a phone compare their tabs with the server.
  • Scale tests cover startup and frame updates across 200 workspaces.

Reviews (1) · Last reviewed commit: "test(layout-owner): add C3/C4 paired ser..." · Reviewed by Greptile

Comment on lines +214 to +224
await host.client.call('layout.apply', {
command: {
type: 'createTerminalTab',
workspace: worktreeId,
tabId: midStartId,
leafId: randomUUID()
}
})
await host.client.call('layout.apply', {
command: { type: 'closeTabs', workspace: worktreeId, tabIds: [midStartId] }
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Mid-start case may never start

This step creates a tab and immediately closes it without checking that the desktop saw it or began a start. If the desktop receives only the final empty layout, every assertion passes without testing cleanup during a start.

Wait for the tab’s starting state before closing it. Make this a separate test so an earlier failure cannot skip it.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +219 to +223
// Mount every tab on both desktops so closing tests real binding retirement on both sides.
for (const webId of [tabFromA, tabFromB, tabFromPhone]) {
await openTab(desktopA, worktreeId, webId)
await openTab(desktopB, worktreeId, webId)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Binding cleanup can pass unchecked

This loop says it establishes live bindings on both desktops, but openTab only waits for a pane manager to exist. That manager is registered before the pane layout is restored. The final absence check can therefore pass without proving that each desktop ever held a PTY binding for the closed tabs.

Wait for expectPanesBoundToHandles on both desktops before closing them.

@Jinwoo-H
Jinwoo-H merged commit 7d04443 into layout-owner-c3-c4-server-frames Nov 29, 2026
50 of 55 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