Skip to content

refactor(layout-owner): one placement helper for drawn tab opens (dark, layout-owner build only) - #30174

Merged
Jinwoo-H merged 1 commit into
mainfrom
e2-6/p1-drawn-tab-placement
Oct 18, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
e2-6/p1-drawn-tab-placement

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{+}}}$​50 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​50
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​40 $\color{#cf222e}{\Huge{\mathbf{−}}}$​31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9

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

  • New 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: 0 when 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 existing newGroupSplitOf).
  • The chat tab, mobile emulator tab, and browser tab open recorders call it instead of their own copies. The commands they send carry the same fields with the same values.
  • Before and after for users: identical. The recorders only run in the layout-owner build, which does not ship.

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.ts covers 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=4 over 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 tc pass; pnpm run check:code-quality:changed pass; 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.js and orchestration-setup-state chunk: only the embedded source commit stamp.
    • renderer/.vite/manifest.json: two CSS entries change position (key order only, same files).
    • client chunk: 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 added for 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

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

Notes

Security, cross-platform, SSH, mobile, compatibility, performance: no change (dark refactor, same wire output).

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)

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

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca60621f-8d48-4f63-881e-8bb47aa3e7fb
📥 Commits

Reviewing files that changed from the base of the PR and between af056df and 115ad6d.

📒 Files selected for processing: 5
  • src/renderer/src/lib/simulator-tab-layout-owner.ts
  • src/renderer/src/runtime/agent-session-tab-layout-owner.ts
  • src/renderer/src/runtime/layout-owner-drawn-tab-placement.test.ts
  • src/renderer/src/runtime/layout-owner-drawn-tab-placement.ts
  • src/renderer/src/store/slices/browser/browser-layout-owner-commands.ts

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

📝 Walkthrough

The change adds drawnTabPlacement to calculate tab placement and split information. Simulator, agent-session, and browser tab-open recording now use the helper instead of calculating placement inline. Tests cover first, middle, and last tab placement, missing tabs or groups, and split metadata.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 115ad

The tab-open recorders preserve their previous behavior, so this change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 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 and concisely identifies the main change: consolidating drawn-tab placement logic into one helper for the layout-owner build.
Description check Passed The description follows the required template and explains the change, rationale, testing, scope, visual impact, compatibility considerations, and checklist status. The maintainer exception appropriat…
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 follows the required template and explains the change, rationale, testing, scope, visual impact, compatibility considerations, and checklist status. The maintainer exception appropriately explains why no linked issue is provided.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • 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.

@Jinwoo-H
Jinwoo-H merged commit e0abf71 into main Oct 18, 2026
64 of 66 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