refactor(web): migrate weeklyDigestStorage off raw localStorage#1745
Conversation
Item #6 round-9 follow-up. Migrate the web-side StorageReader adapter in apps/web/src/shared/lib/storage/weeklyDigestStorage.ts off the inline try/catch around localStorage.getItem onto the shared safeReadStringLS helper, removing the file from the sergeant-design/no-raw-local-storage allowlist. Production allowlist count: 14 → 13 (headroom 0). Updated rationale in .tech-debt/localstorage-allowlist-budget.json. Tests: 3 existing + 2 new resilience scenarios that assert loadDigest and hasLiveWeeklyDigest do not throw when localStorage.getItem itself throws (Safari Private Mode / disabled storage). Co-Authored-By: Бу Ка <dmytro.s.stakhov@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR migrates ChangesWeekly Digest Storage Safe Wrapper Migration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 1/10 review remaining, refill in 48 minutes and 38 seconds. Comment |
Round-9 follow-up rollout: top-4 за залишковим ROI з roadmap-таблиці docs/diagnostics/2026-05-03-web-deep-dive/00-overview.md. - Item #6 (#1745): localStorage budget 14 → 13 (`weeklyDigestStorage.ts` → `safeReadStringLS`). - Item #8 (#1748): `useApiForm` rollout — `WaitlistForm` (/pricing). Тепер +1 public marketing-form поверх auth + settings. - Item #15 (#1750): `noUncheckedIndexedAccess` для `@sergeant/finyk-domain`. Strict-coverage 8/13 → 9/13 пакетів (69%). - Item #16 (#1752): Storybook 16 → 20 (IconButton, SkeletonCard, ProgressRing, EmptyState). Оновлюю: - 00-overview.md — round-9 update-блок + додаю round-9-фрази до 4 roadmap-рядків з PR-лінками й короткими summary. - 02-architecture-and-state.md — додаю follow-up #4 round-9 update-блок для finyk-domain з підсумком strict-coverage 8/13 → 9/13 (69%) і оновленим backlog-ом (4 пакети залишилось). Co-Authored-By: Бу Ка <dmytro.s.stakhov@gmail.com>
⏱️ CI Pipeline Duration ReportBased on the last 50 successful runs on the default branch. Overall Pipeline
Trend (last 20 runs): Per-Job Breakdown
|
Summary
Item #6 round-9 follow-up. The web-side
StorageReaderadapter inapps/web/src/shared/lib/storage/weeklyDigestStorage.tswas the last remaining higher-level wrapper still callinglocalStorage.getIteminside its own inlinetry/catch. Replace that with a delegation to the sharedsafeReadStringLShelper from./storageso the file no longer needs to live in thesergeant-design/no-raw-local-storageallowlist.apps/web/src/shared/lib/storage/weeklyDigestStorage.ts—webStorageReader.getItemnow callssafeReadStringLS(key). Same try/catch contract (returnsnullon failure), one fewer file with rawlocalStorageaccess.eslint.config.js— dropweeklyDigestStorage.tsfrom the webno-raw-local-storageallowlist; extend the round-9 migration comment..tech-debt/localstorage-allowlist-budget.json— production budget14 → 13(headroom 0). Updated rationale.apps/web/src/shared/lib/storage/weeklyDigestStorage.test.ts— keep the existing 3 happy-path scenarios and add 2 hardening cases that mockStorage.prototype.getItemto throw (Safari Private Mode / disabled storage), assertingloadDigestandhasLiveWeeklyDigestcollapse tonull/falseinstead of throwing.Roadmap:
docs/diagnostics/2026-05-03-web-deep-dive/00-overview.mdItem #6 follow-up (round 9). Burndown plan:docs/diagnostics/2026-05-03-web-deep-dive/02-architecture-and-state.md§2.2 +docs/tech-debt/frontend.md§2.Governing Skill
sergeant-web-uiPlaybook
safeRead*LS/safeWriteLSpattern documented indocs/tech-debt/frontend.md§2 and the diagnostic; previous rounds (5–8) shipped without a dedicated playbook for the same reason.Verification
Result:
tsc --noEmit: clean.Test Files 1 passed (1) | Tests 5 passed (5).lint:localstorage-allowlist:13/13 (headroom 0).Additional checks:
Docs and Governance
AGENTS.mdneeded an update.Updated docs:
noUncheckedIndexedAccess, WaitlistForm useApiForm migration), to keep that single roadmap-touching commit isolated.Risk and Rollout
webStorageReader.getItemreturns the exact same shape (string | null) and silently catches failures the same way the previous implementation did;@sergeant/sharedloadDigest/hasLiveWeeklyDigestare unchanged.Hard Rule #15
AGENTS.mdbefore coding.--no-verify.Reviewer Notes
The two new tests stub
Storage.prototype.getItemdirectly viaObject.definePropertyand restore the descriptor inafterEach; this matches the pattern used elsewhere in the repo for Safari Private Mode coverage and keeps the existing happy-path tests untouched.Summary by cubic
Migrated the web
weeklyDigestStorageadapter off rawlocalStorageto usesafeReadStringLS, keeping the same null-on-failure behavior and improving resilience. Removed the file from thesergeant-design/no-raw-local-storageallowlist and lowered the production budget to 13.apps/web/src/shared/lib/storage/weeklyDigestStorage.ts:webStorageReader.getItemnow callssafeReadStringLS(key); samestring | nullcontract.apps/web/src/shared/lib/storage/weeklyDigestStorage.test.ts: added two resilience tests whereStorage.getItemthrows;loadDigestreturnsnull,hasLiveWeeklyDigestreturnsfalse.eslint.config.js: droppedweeklyDigestStorage.tsfrom the allowlist and documented the round-9 change..tech-debt/localstorage-allowlist-budget.json: updated rationale; production count14 → 13.Written for commit abce050. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Chores