Repository navigation
fix(id-web): needsRefresh treats non-numeric/future stored timestamps as stale (#847) - #857
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Timestamp validation and tests pkgs/id/web/src/identity-refresh.ts, pkgs/id/web/src/identity-refresh.test.ts |
identityNeedsRefresh treats missing, empty, non-finite, and future timestamps as requiring refresh. Tests also cover current, recent, and interval-old timestamps. |
Main refresh integration pkgs/id/web/src/main.ts |
needsRefresh delegates its decision to identityNeedsRefresh, passing the stored timestamp, current time, and refresh interval. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: 
Minimal · up to 2dc9a
-
The timestamp validation and main integration show no actionable merge blocker in the supplied evidence.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the change:
needsRefreshnow treats non-numeric and future stored timestamps as stale, which matches the helper extraction in identity-refresh.ts and the linked issue#847. It is specific, one sentence, and free of file lists or vague wording. The title uses the fix(scope) convention and cites the issue number.
Full details: Linked Issues check
-
Explanation
Issue
#847requires invalid or non-finite stored timestamps and future timestamps to return true, while preserving missing, recent, and interval-elapsed behavior.identityNeedsRefreshimplements these cases withNumber.isFinite, a future-time check, andelapsed >= intervalMs.main.tsdelegates to the helper with the existing storage key and interval.identity-refresh.test.tscovers all required cases, including the exact interval.
Full details: Out of Scope Changes check
-
Explanation
The changes are limited to
pkgs/id/web/src/main.tsand the directly related helper and test files. The helper extraction, delegation, and tests support issue#847. No unrelated behavior or files are changed.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
🔧 Biome (2.5.15)
-
pkgs/id/web/src/identity-refresh.test.ts
-
Biome could not lint this file: nested root configuration. Check the repository's Biome configuration and plugins.
pkgs/id/web/src/identity-refresh.ts
-
Biome could not lint this file: nested root configuration. Check the repository's Biome configuration and plugins.
pkgs/id/web/src/main.ts
-
Biome could not lint this file: nested root configuration. Check the repository's Biome configuration and plugins.
-
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 @coderabbitai help to get the list of available commands.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Sweep fix-up: the nix flake check failure (run 40175418824) was a real but formatting-only failure — biome |
|
Sweep update: merged current main 0b9ea76 (new head b117750). This also pulls in the #866 fix (PR #867) — the treefmt FAILURE on the previous head was that unrelated main breakage (proxy-port guard vs literal 18747/18748 in opencode.jsonc), not this PR. Fresh CI now running on a clean main base; the identity-refresh biome fix (18edf73) is unchanged. |
|
Sweep 2026-10-25: merged current main |
|
Sweep 2026-10-25: fresh rollup on head |
Fixes #847
needsRefresh()inpkgs/id/web/src/main.tsdidDate.now() - Number(refreshedAt) >= interval. For a non-numeric storedid_identity_refreshed_atvalue that isNaN >= interval=falseforever, so the SPA-navigation keep-alive never refreshed the 30-day identity token. A far-future timestamp had the same shape (negative elapsed).Change:
identityNeedsRefresh(raw, now, intervalMs)in newpkgs/id/web/src/identity-refresh.ts(same extraction pattern asworld-seed.ts): missing, non-numeric, or non-finite stored values count as needs-refresh, as does any timestamp in the future. Only a finite past timestamp is compared against the interval.needsRefresh()inmain.tsdelegates to the helper; normal behaviour unchanged.Tests: new
identity-refresh.test.ts(missing/empty, garbage/NaN/Infinity, future, recent, exact-interval, long-elapsed). Verified locally on this branch: vitest run src/identity-refresh.test.ts — 5/5 PASS; tsc --noEmit clean.Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit