You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1/arch] Every addEntry writes the entire entries array to localStorage synchronously — no debounce #331
historyStore.ts uses zustand/middleware::persist (src/stores/historyStore.ts:30-38) which writes the entire JSON state on every set.
Problem
With MAX_ENTRIES = 500 and an average entry of ~500 bytes (SQL + connection name + timestamps), each addEntry triggers a synchronous localStorage write of ~250 KB. That's measurable on slow disks (HDD, encrypted APFS) and blocks the main thread. The DebounceEditor (editorStore.ts:351-365) handles this with a 500ms debounce — the history store doesn't. After F1 raises the cap, the cost grows linearly.
Files
src/stores/historyStore.ts:30-38
Expected
In-memory state is immediately reactive (UI updates synchronous), but the localStorage write happens on a 500ms idle window.
Proposed fix
Scope S — wrap the set from addEntry in a debounced setter (Mirror editorStore.ts:351-365 pattern: _saveTimeout set/clear).
Acceptance
Rapid-fire 100 queries within 2 seconds result in ≤ 2 localStorage writes (instead of 100); the in-memory state is still up-to-date immediately.
Superseded by #585. The full-array synchronous rewrite is a property of persisting to localStorage, not something to debounce around — moving history to SQLite removes the problem rather than softening it. Closing in favour of that unless there's a reason to keep it separate.
Activity
EVWorth commentedon Sep 9, 2026
Superseded by #585. The full-array synchronous rewrite is a property of persisting to
localStorage, not something to debounce around — moving history to SQLite removes the problem rather than softening it. Closing in favour of that unless there's a reason to keep it separate.feat(history): move query history into SQLite
feat(history): move query history into SQLite