Repository navigation
test(e2e): terminal layout parity check against main - #25681
Conversation
Runs fixed terminal-layout journeys in the real app on two builds, captures the renderer topology and the saved workspace session, normalizes volatile values and fails on any difference not declared for a named bug. Co-Authored-By: Claude <[email protected]>
…roduce Co-Authored-By: Claude <[email protected]>
…ess-module warning Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
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⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds end-to-end terminal-layout scenarios that capture renderer and persisted session state. It adds normalization and comparison logic for captures, including declared-difference and main-instability classifications. A CLI command runs the scenarios against base and head checkouts, writes a report, and returns success only when the runs and comparison meet its stated conditions. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The new parity check can compare stale app output if run with SKIP_BUILD set and an existing build artifact. Clear the variable or rebuild before relying on that result; this is a bounded risk in the manual validation workflow. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The production terminal behavior is unchanged, and scenarios use disposable profiles. However, inherited remote-connection settings can redirect the new test command’s terminal requests outside those profiles. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 44.12% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 6 files. (1 skipped: 1 unsupported.)
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. Comment |
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:
c5583190-cc46-4227-9c49-9c16c3914728
📒 Files selected for processing (8)
config/scripts/run-terminal-layout-parity.mjspackage.jsontests/e2e/AGENTS.mdtests/e2e/helpers/runtime-types.tstests/e2e/terminal-layout-parity-declared-differences.tstests/e2e/terminal-layout-parity-snapshot.tstests/e2e/terminal-layout-parity-snapshot.unit.test.tstests/e2e/terminal-layout-parity.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| const declaration = declarations.find((entry) => covers(entry, scenario, path)) | ||
| if (declaration) { | ||
| used.add(declaration) | ||
| report.declared.push({ ...difference, bugId: declaration.bugId }) | ||
| } else if (unstableOnMain.some((entry) => covers(entry, scenario, path))) { | ||
| report.unstableOnMain.push(difference) | ||
| } else { | ||
| report.undeclared.push(difference) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Count a declaration as used only when its scenario has a declared difference.
declarations.find returns only the first matching declaration. Suppose two declarations cover overlapping prefixes in one scenario. The second declaration is never added to used. It is then reported in unusedDeclarations, and the run fails even though the fix was observed. Mark every declaration that covers the path as used.
Proposed fix
- const declaration = declarations.find((entry) => covers(entry, scenario, path))
- if (declaration) {
- used.add(declaration)
+ const matching = declarations.filter((entry) => covers(entry, scenario, path))
+ const declaration = matching[0]
+ if (declaration) {
+ matching.forEach((entry) => used.add(entry))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const declaration = declarations.find((entry) => covers(entry, scenario, path)) | |
| if (declaration) { | |
| used.add(declaration) | |
| report.declared.push({ ...difference, bugId: declaration.bugId }) | |
| } else if (unstableOnMain.some((entry) => covers(entry, scenario, path))) { | |
| report.unstableOnMain.push(difference) | |
| } else { | |
| report.undeclared.push(difference) | |
| } | |
| const matching = declarations.filter((entry) => covers(entry, scenario, path)) | |
| const declaration = matching[0] | |
| if (declaration) { | |
| matching.forEach((entry) => used.add(entry)) | |
| report.declared.push({ ...difference, bugId: declaration.bugId }) | |
| } else if (unstableOnMain.some((entry) => covers(entry, scenario, path))) { | |
| report.unstableOnMain.push(difference) | |
| } else { | |
| report.undeclared.push(difference) | |
| } |
…nt maps as empty Driving PaneManager.closePane directly left main to learn of the close from the PTY exit, which raced quit; the keyboard path commits the close in main first. Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
ℹ️ No critical issues — two minor bookkeeping suggestions inline.
Reviewed changes
tests/e2e/terminal-layout-parity.spec.ts— eight serial journeys that capture renderer topology (window.__storestate plus mountedPaneManagerDOM leaf order) and the persistedworkspaceSession, pacing on every pane's PTY binding and a matchingterminal.listbefore quitting.tests/e2e/terminal-layout-parity-snapshot.ts— relabels volatile ids by first appearance, masks times/pids/scrollback/paths, diffs base vs head, and classifies each difference as declared / unstableOnMain / undeclared.tests/e2e/terminal-layout-parity-declared-differences.ts— empty allow-list plus one evidencedunstableOnMainentry.config/scripts/run-terminal-layout-parity.mjsand thepackage.jsonscript — builds a cached detached checkout per SHA, runs head's spec against both builds bycwd, writesreport.json, and fails on any undeclared difference or unobserved declaration.tests/e2e/helpers/runtime-types.tsaddsgetLeafIdto the testPaneManagertype;tests/e2e/AGENTS.mddocuments the check.
I confirmed the unit tests pass, lint is clean on the new files, and that base e9ed75a5 already exposes PaneManager.getLeafId (so the head spec does not depend on a hook main lacks). The normalizer's label-by-first-appearance scheme is deterministic across runs; its only blind spot is swapping two otherwise-identical sibling panes, which is not user-observable and is detected once the panes carry distinct titles.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| const declaration = declarations.find((entry) => covers(entry, scenario, path)) | ||
| if (declaration) { | ||
| used.add(declaration) | ||
| report.declared.push({ ...difference, bugId: declaration.bugId }) |
There was a problem hiding this comment.
declarations.find marks only the first declaration that covers a path as used. When two declarations for one scenario have overlapping prefixes, the others are reported as unusedDeclarations and fail the run even though their difference was observed. I reproduced this: two declarations both covering [0].renderer.terminalLayoutsByTabId.#1.root.ratio leave the second under unusedDeclarations. Mark every covering declaration as used (the first still supplies the reported bugId).
| const declaration = declarations.find((entry) => covers(entry, scenario, path)) | |
| if (declaration) { | |
| used.add(declaration) | |
| report.declared.push({ ...difference, bugId: declaration.bugId }) | |
| const matching = declarations.filter((entry) => covers(entry, scenario, path)) | |
| const declaration = matching[0] | |
| if (declaration) { | |
| matching.forEach((entry) => used.add(entry)) | |
| report.declared.push({ ...difference, bugId: declaration.bugId }) |
… a drag-out scenario Co-Authored-By: Claude <[email protected]>
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:
7afc9ce6-0f37-462d-8a42-c706a3a14bfa
📒 Files selected for processing (3)
config/scripts/run-terminal-layout-parity.mjstests/e2e/AGENTS.mdtests/e2e/terminal-layout-parity.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/e2e/AGENTS.md
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| // The working tree builds in Playwright's global setup; checkouts were built above. | ||
| ...(side.skipBuild ? { SKIP_BUILD: '1' } : {}) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect the build-skip contract without running repository code.
rg -n -C 5 'SKIP_BUILD|VITE_EXPOSE_STORE' tests/e2e/global-setup.ts tests/playwright.config.ts config/scripts/run-terminal-layout-parity.mjsRepository: stablyai/orca
Length of output: 7566
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- runner captureSide and callers ---'
nl -ba config/scripts/run-terminal-layout-parity.mjs | sed -n '125,220p'
printf '%s\n' '--- global setup build guard ---'
nl -ba tests/e2e/global-setup.ts | sed -n '45,72p'
printf '%s\n' '--- PR base runner counterpart ---'
git show 17ecee6337e65ec39efe8de598183f679f8437c4:config/scripts/run-terminal-layout-parity.mjs 2>&1 | nl -ba | sed -n '125,220p'Repository: stablyai/orca
Length of output: 6317
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- PR diff for parity runner ---'
git diff --no-ext-diff --unified=6 17ecee6337e65ec39efe8de598183f679f8437c4 66af1c06c766bf4417efdf2c31e95c29430ddcab -- config/scripts/run-terminal-layout-parity.mjs
printf '%s\n' '--- run helper declaration and call sites ---'
rg -n -C 4 'function run|const run|run\(' config/scripts/run-terminal-layout-parity.mjsRepository: stablyai/orca
Length of output: 10354
🏁 Script executed:
#!/bin/bash
set -e
nl -ba config/scripts/script-child-process.mjs | sed -n '1,145p'Repository: stablyai/orca
Length of output: 2076
🏁 Script executed:
#!/bin/bash
set -e
rg -n -C 8 'runProcessSync|spawnSync|env:' src/shared/child-process/run-process.tsRepository: stablyai/orca
Length of output: 2413
🏁 Script executed:
#!/bin/bash
set -e
rg -n -C 8 'interface ProcessSpec|type ProcessSpec|function resolveSpawn|export .*resolveSpawn|env' src/shared/child-process/spawn-resolution.ts src/shared/child-process/run-process.tsRepository: stablyai/orca
Length of output: 6988
Clear inherited SKIP_BUILD for the working-tree head.
When the caller sets SKIP_BUILD and out/main/index.js exists, global setup skips the build. The head capture can then use stale output. Set SKIP_BUILD to a falsey value when side.skipBuild is false.
🐛 Suggested fix
- ...(side.skipBuild ? { SKIP_BUILD: '1' } : {})
+ SKIP_BUILD: side.skipBuild ? '1' : ''📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // The working tree builds in Playwright's global setup; checkouts were built above. | |
| ...(side.skipBuild ? { SKIP_BUILD: '1' } : {}) | |
| // The working tree builds in Playwright's global setup; checkouts were built above. | |
| SKIP_BUILD: side.skipBuild ? '1' : '' |
| const persisted = readPersistedSessions(session.userDataDir) | ||
| checkpoints.push({ label: 'after-quit', renderer, persisted, exit }) | ||
|
|
||
| const { expectedPaneCount = 0, times: restarts = 1 } = scenario.restart ?? { times: 0 } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Check whether the repo typecheck includes tests/e2e and reports this line.
fd -g 'tsconfig*.json' . --exec rg -n 'e2e' {}Repository: stablyai/orca
Length of output: 351
🏁 Script executed:
#!/bin/bash
set -e
git diff --unified=8 17ecee6337e65ec39efe8de598183f679f8437c4 66af1c06c766bf4417efdf2c31e95c29430ddcab -- tests/e2e/terminal-layout-parity.spec.ts
printf '\n--- complete relevant source with line numbers ---\n'
nl -ba tests/e2e/terminal-layout-parity.spec.ts | sed -n '1,270p'
printf '\n--- TypeScript configs and package scripts ---\n'
rg -n --glob 'tsconfig*.json' --glob 'package.json' --glob '!node_modules/**' 'typecheck:e2e|terminal-layout-parity|tests/e2e|include|exclude|files' .Repository: stablyai/orca
Length of output: 37754
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- e2e TypeScript configuration ---'
nl -ba config/tsconfig.e2e.json | sed -n '1,28p'
printf '%s\n' '--- package typecheck script ---'
nl -ba package.json | sed -n '58,70p'Repository: stablyai/orca
Length of output: 2886
Avoid destructuring expectedPaneCount from the fallback union.
The { times: 0 } fallback has no expectedPaneCount property, so the destructuring fails the TypeScript check. The runtime defaults are correct; this change preserves them.
Suggested fix
- const { expectedPaneCount = 0, times: restarts = 1 } = scenario.restart ?? { times: 0 }
+ const restarts = scenario.restart ? (scenario.restart.times ?? 1) : 0
+ const expectedPaneCount = scenario.restart?.expectedPaneCount ?? 0📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const { expectedPaneCount = 0, times: restarts = 1 } = scenario.restart ?? { times: 0 } | |
| const restarts = scenario.restart ? (scenario.restart.times ?? 1) : 0 | |
| const expectedPaneCount = scenario.restart?.expectedPaneCount ?? 0 |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor bookkeeping suggestion inline.
Reviewed changes
This run re-reviewed the two commits that landed since the prior pullfrog review (bae59d3fa7, 66af1c06c7).
- Build stamp is now written only after a passing build —
prepareCheckoutinstalls, builds (electron-vite build --mode e2ewithVITE_EXPOSE_STORE, thenbuild:cli), and stamps in one place; a failed build throws before the stamp, and the post-run stamp-on-existence write is gone. This closes the earlier concern aboutSKIP_BUILD=1reusing a partial or non-e2eout/. - Added
-g/--grepforwarding — the runner passes a scenario filter through to Playwright on both the base and head runs. - Added the
drag-out-to-tabscenario — a real pointer drag of a pane handle onto the tab strip, asserted to yield a second tab, then restarted twice through the newrestart.times. - Close-pane now uses the user's chord (
Cmd/Ctrl+W, confirming "Stop and Close") instead of drivingPaneManager.closePane, so main commits the close before quit rather than learning it from the PTY exit; the now-unobservedunstableOnMainentry was removed. - Absent and empty maps compare equal —
diffJsonskips a comparison only when both sides are empty, with a matching unit test;tests/e2e/AGENTS.mdand thePaneManagerLike.restarttype were updated.
I confirmed the 7 unit tests pass at head, the runner's build matches tests/e2e/global-setup.ts, and the -g option parses as documented.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| '--project', | ||
| 'electron-headless', | ||
| '--workers=1', | ||
| ...(values.grep ? ['--grep', values.grep] : []) |
There was a problem hiding this comment.
With -g filtering both runs to a subset of scenarios, compareParityCaptures still evaluates unusedDeclarations over the full declaration list, so any declaration for an un-run scenario is reported as UNOBSERVED and the run fails. The new docs advertise -- -g close-pane as an iteration workflow, but it becomes unusable the moment the first declaration for a different scenario lands.
Technical details
# Scenario filtering invalidates the unused-declaration check
The unused-declaration guard exists to catch a stale declaration on a full run. Under `--grep`, only the matched scenarios are captured, so declarations for every other scenario are necessarily unmatched and incorrectly fail the run.
## Affected sites
- `config/scripts/run-terminal-layout-parity.mjs:148` — forwards `values.grep` to Playwright on both sides, producing a partial capture set.
- `tests/e2e/terminal-layout-parity-snapshot.ts:260` — `report.unusedDeclarations = declarations.filter((entry) => !used.has(entry))` has no knowledge of a scenario filter.
## Required outcome
- A filtered run should not fail because of declarations belonging to scenarios that were intentionally not executed.
## Suggested approach (optional)
- Skip the `unusedDeclarations` check when a grep filter is set (e.g. only enforce it on a full run), or scope the declaration set to the scenarios actually captured.
ELI5
The terminal layout refactor is landing as many small PRs, and each one must either change nothing or fix a specific named bug. This PR adds a check that proves it: it builds main and the branch, drives the same terminal layout scenarios through the real app on both, and compares the resulting layouts and saved state. Any difference that isn't declared as a named bug fix fails the check. It is a test tool only; the app is unchanged.
What Changed
tests/e2e/terminal-layout-parity.spec.ts: Playwright Electron scenarios (create tab, split right then down, close pane, close tab, reorder panes, drag a pane out onto the tab bar with a real mouse drag and restart twice, split started from the CLI, split plus new tab across a restart, non-git folder workspace). Each captures the window's layout (tabs, groups, layout trees, terminal bindings, pane order, active pane), how the app exited, and the saved session for every partition. Scenarios wait like a user would (each pane's terminal started, main's terminal list matching the window) so main compares equal to itself.tests/e2e/terminal-layout-parity-snapshot.ts: turns ids into stable labels by where they first appear in the layout and masks timestamps, pids, ports, scrollback and temp paths, then diffs.tests/e2e/terminal-layout-parity-declared-differences.ts: the allow-list, keyed by scenario, bug id and field path. An undeclared difference fails, and so does a declared one that no longer appears.config/scripts/run-terminal-layout-parity.mjsandpnpm run test:e2e:terminal-layout-parity: installs and builds a detached checkout of the base commit once (marked done only after the build succeeds, then reused), runs the current spec against both builds and compares.-- --base <sha> --head <sha>compares any two commits;-- -g <name>runs only matching scenarios.tests/e2e/AGENTS.mdon when and how to run it.Before/after for users: none; test code only.
Why
Unit tests in this area mock the very internals the refactor rewrites, so they can't show that behavior is unchanged. Driving the real app through the e2e harness (already used by ~500 specs) stays stable across the refactor and compares what users actually get. Comparing against main, not against fixed snapshots, means no golden files to re-record.
Linked Issue
Maintainer PR. Supports the terminal layout refactor (Linear STA-9417, STA-9259).
Visual Proof
N/A: test tooling only.
Testing
Unit tests for normalizing and comparing (7): equal runs with different ids, paths, times and key order compare equal; an injected ratio change is detected; a declared change passes; a declared change that doesn't appear fails.
Main against itself: equal across 10 paced full-suite runs; the new drag-out scenario equal in 5 of 5 separate runs; default run PASS from a fresh shell.
Injected change (new splits default to 60/40): FAIL with 14 exact field differences across 5 scenarios, including after restart; declaring them makes it pass.
Runtime: about 1.5 to 2 minutes, plus a one-time install and build of the base checkout.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Test tooling only; run locally as described above.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
tab.ptyIdabout 1 run in 14 on main. The scenario now closes the pane with the keyboard shortcut, as a user does, so main hears about the close directly instead of racing the quit; the list of fields allowed to differ on main is empty.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)