Repository navigation
refactor(layout-owner): one placement helper for drawn tab opens (dark, layout-owner build only) - #30174
Conversation
…k, layout-owner build only) The chat, simulator, and browser tab recorders each computed where the window drew a just-opened tab with the same lines. They now share drawnTabPlacement.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
ELI5
In the build where the main process owns the tab layout, the window tells main where it drew each new chat, mobile emulator, and browser tab. Three files worked out that position with the same five lines. They now share one small function. Nothing a user sees changes.
What Changed
src/renderer/src/runtime/layout-owner-drawn-tab-placement.ts:drawnTabPlacement(state, worktreeId, groupId, tabId)returns the group, plus either the tab it was drawn after,index: 0when it is first, or nothing when the tab is not in the group's order; and the new split when the tab was opened to the side in its own group (the existingnewGroupSplitOf).Why
The three copies had to stay in step by hand (a review on #30034 flagged the second copy). One function means the next placement rule lands once. The alternatives were folding placement into
newGroupSplitOf(it answers a different question, and the terminal and editor opens use it without a position) or leaving the copies until the E2-6 cleanup; the cleanup would then have to touch three recorders at once.Linked Issue
None (maintainer refactor in the layout-owner series).
Visual Proof
N/A: no visual or interaction change; the code runs only in the layout-owner build.
Testing
Test first:
layout-owner-drawn-tab-placement.test.tscovers a tab at index 0, a middle tab, the last tab, a tab missing from the order (and a missing group), and an open-to-the-side tab in a new group. It failed before the helper existed (module not found), passes now.Callers' existing tests green:
vitest run --maxWorkers=4over the new test,browser-layout-owner-commands,agent-session-tab-layout-owner,store-open-to-side-layout-owner,simulator-tab-layout-owner,ensure-simulator-tab,ensure-simulator-tab-behavior: 7 files, 50 tests passed.pnpm tcpass;pnpm run check:code-quality:changedpass; layout-writer ratchets OK (main 211, renderer 651); focus-read ratchet OK (1082); anti-slop lint pass.Shipped build (switch off), unminified bundle diff of main at af056df against this branch, hashes normalized:
main/index.jsandorchestration-setup-statechunk: only the embedded source commit stamp.renderer/.vite/manifest.json: two CSS entries change position (key order only, same files).clientchunk: the new function and the three edited recorders (browser one is already tree-shaken). These recorders are exported but imported by no chunk in the shipped build, because every caller sits behind the off switch, so the changed code is unreachable there (same as before this PR).Layout-owner build, save-divergence detector, same 4 specs (
structured-chat-tabs-open-close,floating-mobile-emulator-tab,browser-tab,browser-split-shortcuts), 13 passed each: before 1 report, after 1 report, the same one (workspace addedfor the floating terminal workspace, which this PR does not touch).Platforms: macOS. No platform, SSH, or path code involved.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Flip capability list: none. No new layout command field or command type; the commands carry the same fields as before.
Agent skill upstream boundary
Notes
Security, cross-platform, SSH, mobile, compatibility, performance: no change (dark refactor, same wire output).
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)