fix(chat): debounce sidebar-width localStorage write during pointer drag - #210
Merged
Conversation
PR-FE-BUG-HUNT-5 (LOW from kenji-led bug-hunt 2026-06-24 round 1): sidebar-list resizer fires `setSessionListWidth` on every pointermove during a drag — at ~60Hz over a long drag, that's a couple hundred localStorage writes for a single resize gesture. The setting converges to the user's final width at rest; intermediate values aren't load-bearing. Fix: 200ms trailing debounce on the `useEffect` that flushes to localStorage. Cleanup clears the pending timeout on each fresh width change, so only the last-render value gets written. Drag finished → 200ms idle → one localStorage write. Behavior is invisible — the user's final width persists exactly as before, just without the per-frame I/O. Especially noticeable on spinning disks and on Electron's IPC-backed safeLocalStorage path. Diff: 1 file, +10/-2. Single function in main.tsx. No conflict zone with the in-flight PRs (the localStorage write at line 1153 is far from the SearchModal/CommandPalette callback area at line 768/3083 that PR #202 touches).
This was referenced Jun 24, 2026
jackwener
added a commit
that referenced
this pull request
Jun 24, 2026
…scape hatch (#214) Kenji aesthetic-audit reminder 9 (msg `bacde601` 2026-06-24, findings #2 + #3): two chrome design-system holes still leaking gradients / non-token blur into the app. ## #2 — darwin sidebar footer gradient `html[data-os="darwin"] .maka-session-panel-footer` was setting: `background: linear-gradient(180deg, transparent 0%, oklch(.../0.30) 100%)` The panel above already has a 50% glass base + 8px backdrop blur, so the footer doesn't need any additional material — but the 180deg fade IS the same "上面灰下面白" pattern WAWQAQ called out twice before in chat sweep (`1e693dee` / `5d3b10e5`). Replaced with flat `oklch(...) / 0.15` + hairline border-top. ## #3 — `[data-gradual-blur-layer]` block A 56-line block that let any element opt into: - `linear-gradient(to bottom/top, var(--background) → transparent)` - `backdrop-filter: blur(6px)` - raw `z-index: 5` just by wearing the `data-gradual-blur-layer` attribute. Kenji called it a "blur escape hatch" — a future surface could re- introduce blur and a non-token z-index without going through any review of the design system. `grep -rn data-gradual-blur-layer --include=*.tsx` confirms zero JSX consumers — the CSS is dead. Removing the entire block kills the escape hatch + retires one of the four raw z-index numbers kenji flagged in finding #4. `notes/reference-atlas.md` references stay — those describe what reference upstream does, not what we ship. ## Diff 1 file changed, 18 insertions(+), 60 deletions(-) net delete. No JSX touched. No tests touched (no contract pinned this attr). Footer change is darwin-only so non-darwin platforms unaffected. Far from PR #202 styles.css edit area (onboarding ~1500-1700 + cubic-bezier sweep on transition rules). PR #210 touches main.tsx debounce, not styles.css. No merge conflicts.
jackwener
added a commit
that referenced
this pull request
Jun 24, 2026
Kenji aesthetic-audit reminder 9 (msg `bacde601` 2026-06-24, finding #4): four bare integer z-index sites in styles.css (line 407 z-4, 3858 z-2, 7193 z-35, 14463 z-5) sidestep the `--z-*` token scale defined in maka-tokens.css. PR #214 already took out the gradual-blur-layer site (z-5). This PR closes the remaining three. ## Changes 1. `maka-tokens.css`: add two new tokens preserving the previous raw values exactly: - `--z-panel-action: 4` - `--z-settings-fullpage: 35` 2. `styles.css` line 407 (`.maka-workspace-top-actions`): `z-index: 4` → `var(--z-panel-action)`. Identical stacking. 3. `styles.css` line 7193 (`.settingsModal.settingsPage`): `z-index: 35` → `var(--z-settings-fullpage)`. 35 sits between `--z-titlebar` (40) and `--z-sticky` (20) so the OS titlebar still owns top of the stack. Preserved visual behavior exactly. 4. `styles.css` line 3858 (`.maka-skill-featured-art span:nth-child(2)`): bare `z-index: 2` kept. This is local stacking among 3 decorative sticker spans inside a fixed-size container — they never escape the parent and don't need a global token. Added explicit allowlist comment. 5. New `apps/desktop/src/main/__tests__/z-index-contract.test.ts` enforces: - every bare `z-index: <integer>;` must be tokenized or allowlisted (with a documented reason) - allowlist entries must be present in styles.css (no stale entries) - the 10 semantic `--z-*` tokens stay defined in maka-tokens.css Future PRs that re-introduce a bare z-index will fail this test unless they explicitly bump the allowlist. ## Diff 3 files: maka-tokens.css +7, styles.css +17/-2, new test +~110 lines. No visual change. Far from PR #202 (transition sweep), PR #210 (main.tsx debounce), PR #214 (footer/gradual-blur). No conflict. ## Verification Disk still ~100%, couldn't run `pnpm install && pnpm test`. Contract test is greenfield — first run will validate the 4 sites in this same PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR-FE-BUG-HUNT-5 (LOW from kenji-led bug-hunt 2026-06-24 round 1).
Bug
The sidebar-list resizer drag fires `setSessionListWidth` on every pointermove event — at ~60Hz over a long drag, that's a couple hundred localStorage writes for a single resize gesture. The setting converges to the user's final width at rest; intermediate values aren't load-bearing.
Fix
200ms trailing debounce on the `useEffect` that flushes to localStorage. Cleanup clears the pending timeout on each fresh width change, so only the last-render value gets written. Drag finished → 200ms idle → one localStorage write.
Behavior invisible — the user's final width persists exactly as before, just without the per-frame I/O. Especially noticeable on spinning disks and on Electron's IPC-backed safeLocalStorage path.
Diff
`1 file changed, 11 insertions(+), 1 deletion(-)` — `apps/desktop/src/renderer/main.tsx:1153`. Same-file as PR #202 but in a different region (line 1153 vs PR #202's edits at lines 768 + 3083), so trivial merge resolution if both land.
Verification
Local disk still at 100%, couldn't run `pnpm install && pnpm test` end-to-end. Mechanical pattern.