Repository navigation
Conversation
`_update` treated an `undefined` previous snapshot as "nothing to compare against yet" so a custom `compare` never saw a computed atom's uncomputed snapshot. `undefined` is also a valid snapshot, though, so a computed atom that keeps returning `undefined` notified its subscribers on every recompute, and `compare` never ran while an atom held `undefined`. Track whether a computed atom has computed yet instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSDyHMgrdgjFz8EAk5VKo
🦋 Changeset detectedLatest commit: f72cae0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
First snapshot and subsequent comparisons packages/store/src/atom.ts, packages/store/tests/undefined-snapshot.test.ts, .changeset/atom-compare-undefined.md |
Computed atoms track whether a snapshot exists. The first result is stored without comparison; later results use the comparator. Tests cover undefined results, subscriber notifications, and the first computation. The changeset describes the comparison behavior. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related PRs
- TanStack/store#402: Both changes define how atom updates handle
undefinedvalues and snapshots.
Suggested reviewers: davidkpiano
Merge Risk: 
Minimal · up to f72ca
-
The change preserves the intended computed-atom comparison and notification behavior, with no merge-blocking risk established.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
`isFirstComputation` says what the guard is for, so the flag needs no comment to explain it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSDyHMgrdgjFz8EAk5VKo
🎯 Changes
Atoms skip
comparewhenever their previous value isundefined, so a computed atom that staysundefinednotifies its subscribers on every recompute._updatereads anundefinedprevious snapshot as "this computed atom has not computed yet" so that a customcomparenever sees an uncomputed snapshot.undefinedis also a valid snapshot, so the check fires for every atom that holdsundefined, andcomparenever runs for it.createAtom(undefined, { compare: () => true }).set(1)applies the write.hasSnapshotflag tracks whether a computed atom has computed yet. The first computation still skipscompare.tests/undefined-snapshot.test.ts. The first two cases fail onmainand pass with the fix. The third pins thatcompareis not called before the first computation.✅ Checklist
pnpm test:pr, or these tests do not apply to this pull request.🚀 Release Impact
🤖 Generated with Claude Code
https://claude.ai/code/session_01BvSDyHMgrdgjFz8EAk5VKo
Summary by CodeRabbit
undefinedare now handled consistently. The first computation stores its result, while later unchangedundefinedresults do not repeatedly notify subscribers. Custom comparison rules can determine whether a result should be treated as an update, including when the previous value isundefined. By default, value comparisons continue to use standard identity checks.