Repository navigation
docs: Show one Query read across a store in the computed properties demo - #4484
Conversation
The Global computations demo is now a cart on the demo layout: one Query joins each CartItem's quantity with its Product's price into the count, subtotal, shipping and total, read by both the header's badge and the order summary. Changing a quantity moves both; the demo plays itself once in view. The design system gains a quantity stepper, and stats labels stay in line when a figure is plain text. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
…subgrid The stepper's hover and press join upvote's rules and its focus ring keeps the shared one. Stats columns share one row for figures and one for labels, so a plain-text figure sits level without moving the figures of a column whose label wraps. The cart row's text takes the slack instead of resetting the trailing price's auto margin, and the fixture's types come from its data. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
|
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. |
|
Docs preview: https://docs-site-pr-4484-data-client.vercel.app Built from 4f7e660 merged into |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4484 +/- ##
=======================================
Coverage 98.37% 98.37%
=======================================
Files 161 161
Lines 3080 3080
Branches 605 605
=======================================
Hits 3030 3030
Misses 10 10
Partials 40 40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Shipping now follows from the amount left until free shipping, so an emptied cart no longer reads "Add $50.00 more" beside "Free". On touch screens the stepper's buttons grow to 40px, and on phones under 360px the stats figures step down a size so three prices fit side by side. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
…page The demo becomes a small routed store, so the one Query visibly serves many readers: the header's cart badge on every page, a free-shipping bar on both pages, and the cart's order summary and checkout button. Adding a product in the shop moves all of them; the cart page already has the totals. Products add with getList.push, so the cart list stays whole. The design system gains a progress element and the stepper's single Add state; an empty cart ships free again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
The stepper renders one wrapper for both states and holds its width on itself, so Add and the − count + controls can't drift apart. Shipping derives from the amount left to free shipping again, with an empty cart free. The fixture's cart lines are a literal, typed from itself. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94a0fabb34
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…he row Deleting a line left its id in the cart's Collection, and pushing the same product again appended a second copy, so the cart page showed the line twice while the totals counted it once. Lines now drop to quantity 0 and Add reuses them; the cart page hides empty lines. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
|
Staff engineer (Cursor agent): Reviewed The demo fix is fine. I checked whether The future case worth tracking is in the library, not the docs. The bug this commit works around will hit anyone who deletes an entity and later pushes the same id back into a
After this lands, it's worth deciding (with a failing test first) whether array-collection adders should skip pks already present, or whether a delete should prune its pk from collections. Then the cart demo could go back to a plain delete. I'm not opening that change here, because it's a behavior change in What I validated: I read the commit diff with |
|
Agreed, and it's already filed as Linear REACT-13 ("Collection push duplicates the ref of an entity re-created after delete"). The ticket starts with a failing test and weighs both fixes, deduping push/unshift or pruning invalidated pks. After that lands, the demo goes back to a plain delete. The duplicate row was reproduced with Playwright on the playground before the fix. Generated by Claude Code |
The stepper's min-width left out its 1px border on each side, so the Add state measured 80px while the count state measured 82px and the row shifted. A shared --stepper-count now sets the count's width in both rules. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
… totals sum Keeping a removed line at quantity 0 left a phantom line that every reader had to filter out. Removal is a plain delete again, and the cart page reads its lines from All(CartItem), which skips deleted lines and holds each line once, so a product removed and then added back shows up as one row. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
The cart page built a new All(CartItem) each render, which missed the memo cache and gave its list a new identity on every store change. getCartTotals now exports the cartItems schema that it and the cart page both read. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
Its code now sits beside the preview, like the page's other playgrounds, instead of behind a Code toggle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
The Query now reads the same list the cart page renders, and only its new Query line is highlighted. Remove-then-add counts correctly with #4487. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4f7e660. Configure here.
|
|
||
| export const freeShippingAt = 50; | ||
|
|
||
| export const getCartTotals = new Query(CartResource.getList.schema, items => { |
There was a problem hiding this comment.
Remove then add duplicates cart lines
Medium Severity
getCartTotals and the cart page now read CartResource.getList again. Collection.push still appends a second ref after delete of the same pk (REACT-13), so removing a line and adding it back renders two rows and double-counts that line in the totals.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 4f7e660. Configure here.
There was a problem hiding this comment.
Known. The bug is in the library, not in this demo: after delete, the collection still holds the deleted id, so re-creating the same pk shows it twice. It's tracked as REACT-13 and fixed in #4487, which lands before 0.19. I'm leaving this thread open until #4487's design is settled.
Generated by Claude Code


Requested by Nathaniel · project thread
Motivation
Improvement. The Global computations demo in the Computed Properties guide counted users and admins inside a single component. It did not show why a
Querybeats computing in components. The real benefit is an aggregate that many places use, computed once, that can never disagree with itself.Solution
The demo is now a small coffee store in a normal playground
row(code beside the preview), built on the router and the design system.getCartTotalsis oneQueryoverCartResource.getList.schema:Product's price into the count, subtotal, shipping, total, and the amount left until free shipping.CartItem.totalgetter ties back to the page's Singular computations section.QuantityStepperserves both pages. It reads its line withuseQuery(CartItem, { id }), adds withgetList.push, and changes or removes withpartialUpdate/delete. All three are optimistic.autoRunadds filters, adds a dripper, opens the cart and removes the dripper.stepper, whose one-button Add state is as wide as the count state;progress;statsfigures and labels on a shared subgrid, so a plain-text figure ("Free") lines up with the numbers.Depends on #4487. Before that fix, removing a product and adding it back puts its id in the list twice, so the totals count it twice. This PR can merge first; the fix ships before the 0.19 release.
Assumptions and validation
yarn check:doc-examples react|vue).getList.schema.MemoCachekeying a Query's result on its args and the entities it read.🤖 Generated with Claude Code
https://claude.ai/code/session_015gC38VCqJFH8PMKWL49Le5
Note
Low Risk
Documentation, playground fixtures, and scoped preview CSS only; no changes to the data-client library runtime.
Overview
Replaces the Global computations example in the Computed Properties guide: instead of counting users/admins in one page, it uses a Daily Grind mini-store where a single
getCartTotalsQuerydrives the header badge, free-shipping bar, order summary, and checkout button across Shop and Cart routes, with optimisticQuantitySteppermutations and prose on why aggregates belong inQuery, not components.The public doc playground now wires
cartFixturesand acartDemoauto-run (add filters → cross $50 free shipping → cart navigation). Matching agent skill references are updated via the same source doc. Playground design system gainsstepper, styledprogress, andstatssubgrid tweaks so the demo layout stays aligned on small screens.Reviewed by Cursor Bugbot for commit 4f7e660. Bugbot is set up for automated code reviews on this repo. Configure here.