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)