Keep food logging beside products and prevent premature search timeouts - #132
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There is a confirmed duplicated/ inconsistent validation error path for invalid custom portions that can surface redundant UI and should be corrected before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves the “Log Food” UX by embedding the portion/confirmation controls inside the selected search result card, keeping the selected product visible and keeping feedback (success, sign-in prompts, and errors) colocated with the selected item.
Changes:
- Move portion controls from a global section into the selected
FoodCard, and add per-card inline feedback plus selection-generation guarding for late responses/logout. - Add
FoodCardexpand/focus behavior (reveal once, preserve focus intent, restore keyboard focus on cancel). - Add new UI behavior tests and run them in CI.
File summaries
| File | Description |
|---|---|
tools/tests/food_logging_ui.test.mjs |
Adds behavior tests covering selection, scaling, blocking during save, error states, late responses, and focus behavior. |
frontend/components/FoodSearchPlaceholder.tsx |
Embeds portion controls within the selected result card; introduces per-selection feedback/error handling and blocks interactions while saving. |
frontend/components/FoodCard.tsx |
Adds expandable region support for embedded controls, focus management, disabled states, and inline feedback rendering. |
.github/workflows/ci.yml |
Includes the new UI test in the CI test invocation list. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
There is an unrelated global background image change included that isn’t explained in the PR description and should be confirmed as intentional or removed.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 5/6 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
The updated food logging flow clears logError during log submission, which can incorrectly hide the sign-in/logs error state and cause UI flicker while a save is in flight.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
frontend/components/FoodSearchPlaceholder.tsx:493
- confirmPortionLogging() clears logError (used for the Logged Foods section) even though portion/logging errors are now handled via portionError/logFeedback. This can temporarily hide the sign-in prompt or any existing log loading error while a log-food request is in flight (and then reappear on 401), causing UI flicker and coupling unrelated state.
- Files reviewed: 9/10 changed files
- Comments generated: 0 new
- Review effort level: Lite
Selecting Log Food currently opens portion controls below the entire results list, separating confirmation from the chosen product. The embedded app also uses the CalorieToken wallpaper instead of the requested CalorieApp mark.
This places portion controls inside the selected FoodCard. Product name, brand, percentage and scaled nutrition stay next to Add to food log. The card reveals and focuses the controls, restores focus on cancel, and keeps save feedback and sign-in/error messages beside the result. A new search clears an unfinished selection; pending saves block switching and duplicate submissions. A generation guard prevents late responses from restoring feedback after logout.
The screenshot audit also exposed a concrete search deadline mismatch: the existing backend primary/fallback attempts could outlast the proxy's 18 seconds and the browser's 20 seconds. Only food search now uses a 45-second proxy limit and 50-second browser limit, with clear waiting, 429 and timeout messages. Existing provider attempt/rate limits and all identity deadlines remain unchanged; no automatic search retry is added. A virtual-clock test runs the real proxy and browser helper together and completes one 26-second search response. This demonstrates the timing defect; the screenshot itself lacks a trace proving its exact cause.
The app now loads
frontend/public/calorieapp-background.pngthrough its existing global background rules. The muted repeating wallpaper uses the original CalorieApp phone-and-cutlery motif, with pale grey/blue tones and the existing light appearance. WordPress's outer background remains as it is.Background source and edit:
frontend/public/background.png, Git blob992a76238ce68adbafe61c6777e677d9ed1a61fa. Drive also contains a same-named 350,765-byte source file; the inspected reference bytes came from the app repository.calorieappdraft3.ai, rendered as a PNG reference.7961fe8ec2727e58f5175697392ee45e510d4101.Validation and review:
c1f8915e4103cf1c30842c392ff8c1eb4b3222c0, based on app main4baea3acaeaa14dacc602ae8d6154ab4c7e97836.35a933d452bff83d3e75b01fb7f506d717b233f4and identified one suppressed finding in review 5134578220: starting an inline save cleared the unrelated Logged Foods error/sign-in message.This is the CalorieApp part of the user's first bundled refinement cycle. The user has now installed WordPress Bridge 0.3.27; public Home, Richlist and CalorieApp HTML references that version. This app-only follow-up needs no replacement WordPress ZIP. No merge or app deployment has been performed.