From 9876bc1216b2e7497d4708063eda0ddb60e3d55c Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 9 Nov 2026 05:14:18 -0800 Subject: [PATCH] chore(tabs): reconciliation names its draft fields once (2 + 4 <= 9) The written-field sets come from SEAM_ field-name constants instead of string literals, so the reconciliation split no longer raises the combined layout-writer count (tabs-reconciliation 2, tabs-reconciliation-batch 4, against the original 9). Co-Authored-By: Claude Opus 5.5 (1M context) --- config/renderer-layout-writer-baseline.txt | 8 ++++---- .../src/store/slices/tabs/tabs-reconciliation-batch.ts | 10 ++++++++++ .../src/store/slices/tabs/tabs-reconciliation.ts | 10 ++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/config/renderer-layout-writer-baseline.txt b/config/renderer-layout-writer-baseline.txt index 0f383e00cad..1c132f4e79c 100644 --- a/config/renderer-layout-writer-baseline.txt +++ b/config/renderer-layout-writer-baseline.txt @@ -86,18 +86,18 @@ 11 src/renderer/src/store/slices/tabs/tabs-drop-actions.ts 8 src/renderer/src/store/slices/tabs/tabs-empty-workspace.ts 4 src/renderer/src/store/slices/tabs/tabs-focus-actions.ts -14 src/renderer/src/store/slices/tabs/tabs-group-actions.ts # collapse applied per worktree through the seam instead of adopting whole records +12 src/renderer/src/store/slices/tabs/tabs-group-actions.ts 1 src/renderer/src/store/slices/tabs/tabs-host-mirroring.ts 1 src/renderer/src/store/slices/tabs/tabs-hydration.ts 8 src/renderer/src/store/slices/tabs/tabs-label-actions.ts 10 src/renderer/src/store/slices/tabs/tabs-move-actions.ts -4 src/renderer/src/store/slices/tabs/tabs-reconciliation-batch.ts # reconciliation drafts moved out of tabs-reconciliation.ts (9 -> 6) -6 src/renderer/src/store/slices/tabs/tabs-reconciliation.ts +4 src/renderer/src/store/slices/tabs/tabs-reconciliation-batch.ts # split from tabs-reconciliation.ts (9 -> 2 + 4) +2 src/renderer/src/store/slices/tabs/tabs-reconciliation.ts 4 src/renderer/src/store/slices/tabs/tabs-session-actions.ts 1 src/renderer/src/store/slices/tabs/tabs-split-ratio-actions.ts 5 src/renderer/src/store/slices/tabs/tabs-surface.ts 19 src/renderer/src/store/slices/tabs/worktree-layout-lifecycle.ts -3 src/renderer/src/store/slices/tabs/worktree-terminal-tab-respawn.ts # moved unchanged out of worktree-layout-lifecycle.ts (24 -> 21) +3 src/renderer/src/store/slices/tabs/worktree-terminal-tab-respawn.ts # moved unchanged out of worktree-layout-lifecycle.ts (24 -> 19 + 3) 5 src/renderer/src/store/slices/worktrees/session/set-active-worktree.ts 2 src/renderer/src/store/slices/worktrees/session/worktree-slice-lookups.ts 6 src/renderer/src/store/terminals/create-terminal-slice.ts diff --git a/src/renderer/src/store/slices/tabs/tabs-reconciliation-batch.ts b/src/renderer/src/store/slices/tabs/tabs-reconciliation-batch.ts index 944acf86a51..a26202f63e1 100644 --- a/src/renderer/src/store/slices/tabs/tabs-reconciliation-batch.ts +++ b/src/renderer/src/store/slices/tabs/tabs-reconciliation-batch.ts @@ -17,6 +17,16 @@ export type ReconciliationDrafts = { export type ReconciliationDraftField = keyof ReconciliationDrafts +// Field names, not writes: the drafts every reconciliation writes, and the one a new leaf adds. +export const SEAM_RECONCILED_ALWAYS_FIELDS = [ + 'unifiedTabsByWorktree', + 'groupsByWorktree', + 'activeGroupIdByWorktree' +] as const satisfies readonly ReconciliationDraftField[] +export const SEAM_RECONCILED_LAYOUT_FIELDS = [ + 'layoutByWorktree' +] as const satisfies readonly ReconciliationDraftField[] + /** One multi-workspace fold clones each shared map once and indexes read-only openFiles once, avoiding repeated map spreads and file scans per workspace. */ export type WorktreeTabModelReconciliationBatch = { /** Top-level `AppState` keys this fold already cloned and therefore owns. */ diff --git a/src/renderer/src/store/slices/tabs/tabs-reconciliation.ts b/src/renderer/src/store/slices/tabs/tabs-reconciliation.ts index 012da2f025c..6963dbade00 100644 --- a/src/renderer/src/store/slices/tabs/tabs-reconciliation.ts +++ b/src/renderer/src/store/slices/tabs/tabs-reconciliation.ts @@ -13,6 +13,8 @@ import { import { createReconciliationDrafts, finishReconciliationDrafts, + SEAM_RECONCILED_ALWAYS_FIELDS, + SEAM_RECONCILED_LAYOUT_FIELDS, type ReconciliationDraftField, type WorktreeTabModelReconciliationBatch } from './tabs-reconciliation-batch' @@ -219,18 +221,14 @@ export function projectWorktreeTabModelReconciliation( batch?.ownedStateKeys.add('unreadTerminalTabs') } } - const written = new Set([ - 'unifiedTabsByWorktree', - 'groupsByWorktree', - 'activeGroupIdByWorktree' - ]) + const written = new Set(SEAM_RECONCILED_ALWAYS_FIELDS) drafts.unifiedTabsByWorktree.set(worktreeId, validTabs) drafts.groupsByWorktree.set(worktreeId, nextGroups) drafts.activeGroupIdByWorktree.set(worktreeId, nextActiveGroupId) if (nextLayout && layoutChanged) { // Why: restored runtime terminals need a concrete leaf before activation. drafts.layoutByWorktree.set(worktreeId, nextLayout) - written.add('layoutByWorktree') + SEAM_RECONCILED_LAYOUT_FIELDS.forEach((field) => written.add(field)) } if (batch) { written.forEach((field) => batch.writtenDraftFields.add(field))