Skip to content

Avoid no-op worktree activation fanout - #4416

Merged
nwparker merged 1 commit into
mainfrom
nwparker/renderer-switch-fanout-profile
Jun 1, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/renderer-switch-fanout-profile

Conversation

@nwparker

@nwparker nwparker commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve the Zustand root state reference when setActiveWorktree reselects an already-active, reconciled worktree with no derived active-state changes
  • avoid waking session persistence/runtime sync subscribers for that visible no-op
  • add a regression test that subscribes to the store and verifies same-worktree reselection does not notify
  • document the follow-up in the renderer memory profile notes

Validation

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/store-cascades.test.ts src/renderer/src/lib/session-write-subscriber.test.ts
  • pnpm run typecheck
  • pnpm exec oxlint src/renderer/src/store/slices/worktrees.ts src/renderer/src/store/slices/store-cascades.test.ts src/renderer/src/lib/session-write-subscriber.test.ts
  • git diff HEAD --check

@nwparker
nwparker merged commit 36384f1 into main Jun 1, 2026
2 checks passed
@nwparker
nwparker deleted the nwparker/renderer-switch-fanout-profile branch June 1, 2026 22:56
@nwparker

nwparker commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Post-merge addendum: profiling evidence and regression risk

This PR was already merged; adding the missing review context explicitly.

Profiling/data:

  • Worktree-switch profiling showed that reselecting the already-active worktree still changed the Zustand root state and woke subscribers even when the visible active workspace state did not change.
  • The expensive effect was indirect: session persistence/runtime-sync subscribers were triggered by a logical no-op. The regression test pins the intended measurement by asserting a same-worktree reselect does not notify subscribers.

Regression risk:

  • The guard could skip real work if it treats a meaningful activation as a no-op. The condition is intentionally narrow: already-active worktree, reconciled state, and no derived active-state changes.
  • Future callers that rely on reselect side effects rather than explicit activation options could miss updates; Skip visit writes for active worktree reselect #4417 handled the helper-level visit-write case separately.

Validation already run before merge:

  • Vitest for store cascades and session-write subscriber behavior.
  • Typecheck, oxlint, git diff --check.

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