Skip to content

Prevent preference render storms - #95

Merged
ctoth merged 1 commit into
masterfrom
agent/issue-82-preference-subscriptions
Jul 30, 2026
Merged

Prevent preference render storms#95
ctoth merged 1 commit into
masterfrom
agent/issue-82-preference-subscriptions

Conversation

@ctoth

@ctoth ctoth commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • migrate every React preferences consumer from whole-store subscriptions to exact domain or primitive selectors
  • add Zustand selector subscriptions for imperative consumers and prevent unrelated preference writes from triggering autolog pruning, media updates, output updates, or server sync checks
  • debounce preference persistence while flushing the latest pending state on pagehide

Root cause and impact

The monolithic preferences store exposed one broad subscription surface. Components and services subscribed to the entire state, so a write in any preference domain rerendered unrelated UI and invoked unrelated service work. Rapid slider changes also synchronously serialized every intermediate store state.

This keeps the existing store actions and persisted shape while isolating subscribers to the values they actually consume. Preference bursts now coalesce into one storage write without losing the final state when the page is discarded.

TDD and validation

  • RED: selector listeners were unsupported, three rapid updates produced three synchronous storage writes, and a general-preference change triggered autolog pruning
  • GREEN: focused affected suites passed
  • npm run typecheck
  • npm test (105 files, 1,047 tests)
  • npm run lint (passes; existing warnings remain)
  • git diff --check

Closes #82

@ctoth
ctoth merged commit ae62461 into master Jul 30, 2026
1 check passed
github-actions Bot pushed a commit that referenced this pull request Jul 30, 2026
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.

[epic] Monolithic preferences store causes app-wide render storms on every write

1 participant