Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| ); | ||
| } | ||
|
|
||
| export function getSafeLocalStorage(): Storage { |
There was a problem hiding this comment.
🟢 Low lib/browserStorage.ts:40
memoryStorageEntries is a module-level Map shared across all server-side requests. When getSafeLocalStorage falls back to memoryStorage on the server, data written by one request persists and leaks to subsequent requests from other users. Consider creating a fresh storage instance per call, or throw in server environments to prevent accidental usage.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/web/src/lib/browserStorage.ts around line 40:
`memoryStorageEntries` is a module-level `Map` shared across all server-side requests. When `getSafeLocalStorage` falls back to `memoryStorage` on the server, data written by one request persists and leaks to subsequent requests from other users. Consider creating a fresh storage instance per call, or throw in server environments to prevent accidental usage.
Evidence trail:
apps/web/src/lib/browserStorage.ts (REVIEWED_COMMIT):
- Line 1: `const memoryStorageEntries = new Map<string, string>();` - module-level Map
- Lines 3-20: `memoryStorage` object uses this shared Map
- Lines 40-58: `getSafeLocalStorage()` returns `memoryStorage` when `globalThis.localStorage` is unavailable (server-side case)
|
Closing as part of backlog cleanup: this PR is stale, currently conflicting with main, has no approval, and has not had active remediation for 30+ days. If the change is still relevant, please rebase onto current main and request reopening or submit a focused current diff. Thank you for the contribution. |
…ed time (pingdotgg#692) A stored rule order can hold fewer than three rules, or none, and the lastCalled shape time can be 0. Pin that only rules in the order are used, an empty order shows the Default Icon, and a 0 time holds at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ck-fixtures test(bots): icon rule fields in test fixtures (pingdotgg#692)
Add resolveBotIcon, a pure evaluator that picks a Bot's timeline image or rule shape from its icon rules, with the next moment the result can change, and botLeftForYouSinceMs for the leftOnDelivered minute 0. Add the start time parser and short formatter for the editor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A thread never visited now counts as read for leftOnDelivered, through the same unread check the Bot list uses. resolveBotIcon no longer takes the Bot's status, since each rule's start time already says whether it applies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed time (pingdotgg#692) A stored rule order can hold fewer than three rules, or none, and the lastCalled shape time can be 0. Pin that only rules in the order are used, an empty order shows the Default Icon, and a 0 time holds at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BotAvatar now resolves a Bot's icon rules wherever it knows the Bot: a timeline image or rule shape replaces the Default Icon in the one slot, re-resolved once at each boundary instead of on a tick. The next timeline image loads ahead, and a stored image stays up until the next one loads. Muted Bots keep their Default Icon, now grayed out. Editors opt out. The roster's workingSince, deliveredAt and erroredAt now reach the client through ScopedBotEntry, and botIconInputs turns them and the Bot thread's shell into each rule's minute 0. The evaluator uses the contract types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(bots): icon rules storage and roster timestamps (pingdotgg#692)
✨ feat(bots): resolve and show Bot icons from their rules (pingdotgg#692)
Count unreadable icon times as a change, so Discard and the close prompt apply. Gate Save only on the mode the draft Default Icon turns on, and send a hidden mode with a problem as saved. Refresh the editor's now badge elapsed time once a minute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✨ feat(bots): icon editor foundation (pingdotgg#692)
✨ feat(bots): edit a Bot's icon timeline in settings (pingdotgg#692)
🐛 fix(bots): keep missing saved timeline images and center time fields (pingdotgg#692)
Summary
Guard persisted web stores when
localStorageis unavailable or unusable.Why
Some environments throw either when reading
localStorageor when calling its methods. The original fallback also used a module-level in-memory store, which can leak state across server-side requests. This update switches to per-call in-memory fallback storage and permanently falls back after the first storage access failure.Testing
bun x vitest run apps/web/src/lib/browserStorage.test.tsbun lintbun typecheckNote
Guard web composer and terminal persisted stores by using
getSafeLocalStorageto handle unavailablelocalStorageIntroduce
getSafeLocalStoragewith in-memory failover and update zustand persist stores to use it; add tests and acreateMemoryStorageutility.📍Where to Start
Start with
getSafeLocalStoragein apps/web/src/lib/browserStorage.ts.Macroscope summarized 1964131.