-
Notifications
You must be signed in to change notification settings - Fork 2.8k
web-evals: useLocalStorage for persisted UI state #10514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Re-review complete. All previously flagged items look resolved.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| export function deserializeNumber(raw: string): number | undefined { | ||
| const parsed = tryParseJson(raw) | ||
| if (typeof parsed === "number" && Number.isFinite(parsed)) return parsed | ||
|
|
||
| const asNumber = Number(raw) | ||
| return Number.isFinite(asNumber) ? asNumber : undefined | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In deserializeNumber(), falling back to Number(raw) means inputs like "" or "null" deserialize to 0, which can prevent ?? DEFAULT fallbacks from applying and leave a persisted invalid value in localStorage.
| export function deserializeNumber(raw: string): number | undefined { | |
| const parsed = tryParseJson(raw) | |
| if (typeof parsed === "number" && Number.isFinite(parsed)) return parsed | |
| const asNumber = Number(raw) | |
| return Number.isFinite(asNumber) ? asNumber : undefined | |
| } | |
| export function deserializeNumber(raw: string): number | undefined { | |
| const parsed = tryParseJson(raw) | |
| if (typeof parsed === "number" && Number.isFinite(parsed)) return parsed | |
| const trimmed = raw.trim() | |
| if (trimmed === "" || trimmed === "null") return undefined | |
| // Legacy raw-string storage: accept only plain decimal numbers. | |
| if (!/^-?\d+(\.\d+)?$/.test(trimmed)) return undefined | |
| const asNumber = Number(trimmed) | |
| return Number.isFinite(asNumber) ? asNumber : undefined | |
| } |
Fix it with Roo Code or mention @roomote and request a fix.
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
apps/web-evals) to useusehooks-ts/useLocalStoragefor browser storage state.Changes:
usehooks-tsdep.useLocalStorage()(Runs()).groupByStatus+ New Run form persisted settings touseLocalStorage().deserializeToolGroups()) + tests.Testing:
cd apps/web-evals && pnpm run lintcd apps/web-evals && pnpm run check-typescd apps/web-evals && npx vitest runImportant
Migrate UI state persistence to
useLocalStorageusingusehooks-tsand add deserialization functions for better state management inapps/web-evals.useLocalStoragefromusehooks-tsinrun.tsx,new-run.tsx, andruns.tsx.storage.tsforboolean,enum,number, andstring[].deserializeToolGroups()andserializeToolGroups()intool-groups.ts.storage.spec.ts.usehooks-tstopackage.json.This description was created by
for 28c49b1. You can customize this summary. It will automatically update as commits are pushed.