Land the Add Item grouped search on main (epic #43, frontend — re-land of #67) - #69
Merged
Merged
Conversation
Renders the multi-source search from the backend half of this epic: each
open database that returned hits gets its own labelled section with its
own "see more" link, so a shampoo hit is never mistaken for a pantry item.
Picking a suggestion now looks it up through the new source-aware
endpoint rather than by barcode alone, because USDA foods are keyed by
FDC id and generic ones ("bananas, raw") carry no barcode at all. The
barcode field is only populated when the chosen suggestion actually has
one.
The barcode-scan path and the suggestion path had drifted into one
function that could only fetch one way; the field-population logic is now
shared by both via runLookup(), which differs only in how it fetches.
Also adds nutrition_facts to ProductInfo. The backend has always returned
it and the form has always read it, but it was missing from the interface
-- surfaced by tsc once the surrounding code moved.
Drops the debug console.log calls that dumped every lookup response.
100% line coverage on both changed files. New tests cover the grouped
headings and per-source links, selection routing through lookupProduct,
and a barcode-less USDA suggestion leaving the barcode field empty.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-lands the frontend half of epic #43. Closes the gap left by #67.
What happened
#67 was opened with
feat/multi-source-product-search(the #66 backend branch) as its base, so its diff would show only frontend changes. GitHub retargets such a PR tomainonly when the base branch is deleted after merging. #66 was merged but its branch was kept, so #67 stayed pointed at it and merged into the already-merged backend branch instead of intomain.Net effect: GitHub reports #67 as merged, but none of its commits are on
main.This PR is the same commit, cherry-picked onto current
main. It applies cleanly — #68 touched a disjoint set of files.Why it matters (there is a live bug on main right now)
#66's backwards-compatible flat
resultsfield is what keptmainworking without the frontend — but that flat list now includes USDA entries, and generic USDA foods have no barcode:main's current frontend doeslookupBarcode(suggestion.barcode)on click, so selecting a barcode-less suggestion requests/barcode/Noneand shows "Product not found in database. Please enter details manually." This PR is the fix: suggestions carry their source, selection routes throughlookupProduct(source, id), and the barcode field is only populated when the suggestion actually has one.Verification on top of current main
tsc --noEmit: no errors in the touched files.Follow-up to prevent a repeat
Delete
feat/multi-source-product-searchandfeat/multi-source-search-frontendonce this merges — a stacked PR whose base branch outlives its merge is exactly the trap that caused this.🤖 Generated with Claude Code