mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-08-22 23:25:28 +00:00
* fix(webui): route useLocalStorage functional updates through prev state setValue applied a functional updater to the closed-over storedValue instead of React's previous state, so two setValue(fn) calls batched in one render both derived from the same base — the first update was lost and the stale-derived value was persisted to localStorage. Route the update through the setStoredValue(prev => …) form and persist the committed value. Adds a jsdom regression test for the batched-update case. * refactor(webui): persist via effect and guard against throwing updaters Address review: - Restore error handling around the functional updater: a throwing updater is caught and leaves state unchanged (previously it could propagate through render and crash the tree). - Move the localStorage write into an effect so the state updater stays pure (StrictMode-safe), keeping a first-run baseline ref so the initial value is never written on mount. - Add tests for the no-mount-write contract, invalid-JSON hydration fallback, and state updating when setItem throws. |
||
|---|---|---|
| .. | ||
| useFollowupSuggestions.test.tsx | ||
| useFollowupSuggestions.ts | ||
| useLocalStorage.test.tsx | ||
| useLocalStorage.ts | ||
| useTheme.ts | ||