Skip to content

A paired server's workspace never gets main's layout commands: a pinning test (dark, layout-owner build only) - #30430

Merged
Jinwoo-H merged 1 commit into
mainfrom
e2-6/exit-retirement-keeps-exited-pane
Oct 18, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
e2-6/exit-retirement-keeps-exited-pane

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​143 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​143
Prod 0 0 0 0

ELI5

When Orca is paired with another Orca server, the tabs and panes of a workspace on that server belong to the server. In the build where this app's background process owns the layout, the window must never send that workspace's layout changes to its own background process. This PR adds a test that fails if any code path ever does.

What Changed

Test only. No product code changes, and nothing users see changes.

The new test src/renderer/src/runtime/layout-apply-paired-server-guard.test.ts uses the real owner lookup (not a mock) with a worktree and a folder workspace that a paired server owns, and checks that:

  • sendLayoutApply returns false and sends nothing for pane, tab, terminal-create, sleep and default-tabs commands, and recordLayoutApply sends nothing either.
  • The first terminal created when a workspace is activated sends nothing and falls back to the window's own path.
  • Showing a live terminal that has no pane yet sends nothing and returns as-today.
  • A source scan of the window code finds layout.apply named only in layout-apply-send.ts (once) and terminal-tab-create-through-layout-owner.ts (twice). Every other sender goes through sendLayoutApply, so a new direct sender fails this test until it carries the same check and a case here.

Why

Paired servers keep their own layout and the window mirrors it, before and after main takes over the layout. That rule rests on one owner check (runtimeEnvironmentIdUnlessTwin) at three call sites. The existing tests mock that check, so nothing pinned that a real paired-server workspace is caught, or that no sender bypasses it. A source scan was chosen over a per-caller test of all ~30 callers because the callers all funnel into the three checked sites; pinning the sites and the funnel covers every caller with one small test.

Linked Issue

N/A (maintainer, internal refactor step).

Visual Proof

N/A: test-only change, no UI or behaviour change.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • New test: 23 cases pass. With the owner check removed from sendLayoutApply and both terminal-create paths, 20 of 23 fail (the other 3 are the owner lookup and the source scan), so the test bites.

  • pnpm exec vitest run --maxWorkers=4 --config config/vitest.config.ts on the new test, layout-apply-send.test.ts and terminal-tab-create-through-layout-owner.test.ts: 46 passed.

  • pnpm tc: pass. pnpm run check:code-quality:changed: pass. check:layout-writer-ratchets, check:focus-read-ratchet, audit:anti-slop: pass.

  • Shipped build: unchanged by construction (only a .test.ts file is added, which no bundle includes). Save-divergence detector: not applicable (no runtime change).

Review

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

No security, platform, SSH, mobile, compatibility or performance impact: test only.

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)

…ayout.apply

Every renderer sender of layout.apply (sendLayoutApply, recordLayoutApply, the activation
terminal create and the live terminal adoption) returns before the call for a worktree or
folder workspace a paired server owns, and a source census pins that no other renderer file
sends layout.apply.
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Adds tests for paired-server worktree and folder workspaces. The tests check that ownership resolves to env-b, layout commands do not call layout.apply or the apply handler, and terminal creation and live-terminal adoption do not call layout.apply. A source scan checks the expected production locations and counts of layout.apply references.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to acb22

The new guard test has a narrow coverage gap: it may miss a future layout sender that bypasses the guard. Broaden the census before relying on it to detect new senders.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 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 paired-server workspace layout guard and the test-only scope. It is somewhat long, but it remains specific and relevant.
Description check Passed The description covers the required sections, explains the change and rationale, documents testing, and addresses visual proof and compatibility impact. The maintainer-specific Linked Issue exception …
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.
Full details: Description check

Explanation

The description covers the required sections, explains the change and rationale, documents testing, and addresses visual proof and compatibility impact. The maintainer-specific Linked Issue exception is stated, and the testing results are specific.

  • 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.

🧹 Nitpick comments: 1
src/renderer/src/runtime/layout-apply-paired-server-guard.test.ts: 1

112-143: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Count all valid layout.apply string spellings.

The census splits only on 'layout.apply'. A new renderer sender that uses "layout.apply" would be omitted, and the assertion would still pass. The layout-writer ratchet does not inspect RPC method names.

Suggested fix
-      const count = readFileSync(full, 'utf8').split(`'layout.apply'`).length - 1
+      const count = readFileSync(full, 'utf8').match(/(['"`])layout\.apply\1/g)?.length ?? 0

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4ee479c2-d80f-4e87-8de7-5f0ac3e9c431
📥 Commits

Reviewing files that changed from the base of the PR and between 4298ba9 and acb22d7.

📒 Files selected for processing: 1
  • src/renderer/src/runtime/layout-apply-paired-server-guard.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@Jinwoo-H
Jinwoo-H merged commit ecfc138 into main Oct 18, 2026
31 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