From efe19bdfb570c8f4e17b873c7f011f85a586f16d Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 6 Sep 2026 13:41:46 -0700 Subject: [PATCH] chore(store): tighten the copy-on-write comments in hydration placeholders --- .../src/store/terminals/workspace-terminal-placeholders.ts | 7 ++----- .../store/terminals/workspace-terminal-ssh-placeholders.ts | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/renderer/src/store/terminals/workspace-terminal-placeholders.ts b/src/renderer/src/store/terminals/workspace-terminal-placeholders.ts index a2bb0674b7e..94a520993a0 100644 --- a/src/renderer/src/store/terminals/workspace-terminal-placeholders.ts +++ b/src/renderer/src/store/terminals/workspace-terminal-placeholders.ts @@ -23,11 +23,8 @@ export function buildRuntimeSessionPlaceholders({ repos: readonly Repo[] worktreesByRepo: Record } { - // Why not `repos.slice()`: hydration writes this array straight back to the store, and - // sessions that add no placeholder repo are the common case. Copying unconditionally - // gave `repos` a new identity on every workspace hydration, rerendering every component - // that selects the whole array. Appends below already build a new array, as - // nextWorktreesByRepo does for its own copy-on-write. + // Why copy-on-write: hydration writes both straight to the store, and an unconditional copy + // rerendered every whole-array/map selector on every hydration with no data change. let nextRepos: readonly Repo[] = repos let nextWorktreesByRepo = worktreesByRepo for (const workspaceSessionKey of Object.keys(runtimeHostIdByWorkspaceSessionKey)) { diff --git a/src/renderer/src/store/terminals/workspace-terminal-ssh-placeholders.ts b/src/renderer/src/store/terminals/workspace-terminal-ssh-placeholders.ts index d714d3cec38..b2cdc5581e2 100644 --- a/src/renderer/src/store/terminals/workspace-terminal-ssh-placeholders.ts +++ b/src/renderer/src/store/terminals/workspace-terminal-ssh-placeholders.ts @@ -12,10 +12,8 @@ export function addHydratedSshWorktreePlaceholders( tabsByWorktree: Record ): Record { const sshRepoIds = new Set(repos.filter((repo) => repo.connectionId).map((repo) => repo.id)) - // Why copy-on-write: hydration writes this map straight to the store, and a session - // that needs no SSH placeholder is the common case. Copying unconditionally gave - // worktreesByRepo a new identity on every hydration, rerendering the sidebar and - // everything else selecting the whole map for no data change. + // Why copy-on-write: hydration writes this map straight to the store; an unconditional copy + // rerendered every whole-map selector on every hydration with no data change. let worktreesByRepo = sourceWorktreesByRepo for (const worktreeId of Object.keys(tabsByWorktree)) { const repoId = getRepoIdFromWorktreeId(worktreeId)