Skip to content

Land the Add Item grouped search on main (epic #43, frontend — re-land of #67) - #69

Merged
untraceablez merged 1 commit into
mainfrom
fix/land-frontend-search-on-main
Jul 27, 2026
Merged

Land the Add Item grouped search on main (epic #43, frontend — re-land of #67)#69
untraceablez merged 1 commit into
mainfrom
fix/land-frontend-search-on-main

Conversation

@untraceablez

Copy link
Copy Markdown
Owner

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 to main only 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 into main.

Net effect: GitHub reports #67 as merged, but none of its commits are on main.

origin/main  f2d468f  (#68)  fix(frontend): make the test suite deterministic
             bb3e5fe  (#66)  backend: five open databases
             e05a8f9  (#65)  ...
                              ^ no #67 anywhere

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 results field is what kept main working without the frontend — but that flat list now includes USDA entries, and generic USDA foods have no barcode:

Peanut Butter    source=usda   barcode=None      <-- clicking this 404s
Peanut Butter    source=usda   barcode=048737002276

main's current frontend does lookupBarcode(suggestion.barcode) on click, so selecting a barcode-less suggestion requests /barcode/None and shows "Product not found in database. Please enter details manually." This PR is the fix: suggestions carry their source, selection routes through lookupProduct(source, id), and the barcode field is only populated when the suggestion actually has one.

Verification on top of current main

  • Full frontend suite: 452 passed (43 files).
  • tsc --noEmit: no errors in the touched files.
  • Cherry-pick applied with no conflicts.

Follow-up to prevent a repeat

Delete feat/multi-source-product-search and feat/multi-source-search-frontend once this merges — a stacked PR whose base branch outlives its merge is exactly the trap that caused this.

🤖 Generated with Claude Code

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>
@untraceablez
untraceablez merged commit 6744a74 into main Jul 27, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant