Repository navigation
Conversation
…ashiels#55 Weighted (per-kg) butchery lines were rejected by /carts/update with "Missing weight range". New lines now carry selectedWeightRange ({minimumValue, maximumValue} in grams, from the product's variableWeightOptions) and are priced at the range maximum, rounded down, which matches what the app writes (R229.99/kg x 1.1kg -> 25298). - add --weight <min-max>; defaults to the product's only range and requires a choice when there are several - adds merge into an existing line only when the range matches - quantity changes on existing weighted lines are no longer refused - safeErr surfaces the server's JSON message field (only that field), e.g. HTTP 498 now reads "The item is currently out of stock..."
There was a problem hiding this comment.
🛡️ Sentinel review
The weighted-range confirm path, reconcile comparison, and server-message sanitization need fixes before this lands.
2 inline comments below.
Other notes:
src/lib/cart-mutate.ts— modeSets aggregates quantity by productId only, so for weighted products with different selectedWeightRange a server change that collapses or swaps ranges still matches the intended totals and snapshotEquivalent reports success, leaving the wrong pack range/price.
Automated review via deepseek:deepseek-flash + deepseek:deepseek-v4-pro verifier. Findings only — not an approval. Push new commits to re-review.
- --confirm no longer resolves the weight range: the plan already holds it, so a multi-range product confirms without repeating --weight - reconcile keys weighted lines by product and range, so a server swap or collapse of ranges is divergent instead of a matching total - server messages have control characters stripped before display
|
On the |
Codex review on yashiels#60: - remove takes --weight; with one product in several ranges it refuses without one, and only touches the chosen range's lines (the gate also refuses an unscoped weighted remove) - the preview -> confirm fingerprint includes each line's range, so a range change since the preview refuses instead of merging elsewhere - product lookup by id uses the exact id, never another display variant
|
Second review pass: fixed in 2e566c0.
The new tests cover the first two and fail on the previous commit. The exact-id fix has no test: Not applied here: unaddressed fresh carts reading as divergent. That is #61. |
There was a problem hiding this comment.
🛡️ Sentinel review
Weighted add support works, but confirm fingerprint and partial weighted removal need attention.
Other notes:
src/lib/cart-mutate.ts— The confirm fingerprint only includes id, productId, quantity, and price. Because cart.add merge now depends on selectedWeightRange, a concurrent change that only alters a line's range won't be detected, so confirm can merge or append against cart state the user never previewed.src/lib/cart-mutate.ts— cart.remove still groups matches only by productId, so a partial remove of a product with multiple weighted ranges decrements whichever line appears first. Since weighted lines are no longer refused, this can remove the wrong pack range. Partial weighted removals need a range selection or an explicit rejection.
Automated review via cursorbridge:gpt-5.6-sol + deepseek:deepseek-v4-pro verifier. Findings only — not an approval. Push new commits to re-review.
Addresses items 1 and 2 of #55.
Weighted products
Per-kg butchery lines failed on
/api/v3/carts/updatewithMissing weight range. Captured from lines the app wrote to a live cart:selectedWeightRangeis{ minimumValue, maximumValue }in grams, taken from the product'svariableWeightOptions.priceis the per-kg price at the range maximum, rounded down: R124.99/kg × 0.5kg → 6249, R99.99/kg × 0.9kg → 8999, R229.99/kg × 1.1kg → 25298.Changes:
add <id> [qty] --weight <min-max>. Defaults to the product's only range; errors with the list when there are several.variableWeightOptionsare still refused.Server error messages
safeErr()now appends the server's JSONmessagefield (only that field, single line, truncated to 160 chars). For example, an opaqueHTTP 498 Unknownnow readsHTTP 498 Unknown: The item is currently out of stock and cannot be added to your basket.Testing
make cipasses:tsc --noEmit, plus 434 vitest tests including new ones for range selection, pricing, line merging andsafeErr.Not included: items 3 (cart cap message) and 4 (stored mobile fallback) from #55.