mirror of
https://github.com/stablyai/orca.git
synced 2026-09-29 08:03:20 +00:00
chore(store): tighten the copy-on-write comments in hydration placeholders
This commit is contained in:
@@ -23,11 +23,8 @@ export function buildRuntimeSessionPlaceholders({
|
||||
repos: readonly Repo[]
|
||||
worktreesByRepo: Record<string, Worktree[]>
|
||||
} {
|
||||
// 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)) {
|
||||
|
||||
@@ -12,10 +12,8 @@ export function addHydratedSshWorktreePlaceholders(
|
||||
tabsByWorktree: Record<string, TerminalTab[]>
|
||||
): Record<string, Worktree[]> {
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user