refactor(web): decomp NutritionApp.tsx into per-page components (initiative 0013, Sprint 2)#2500
Conversation
…iative 0013, Sprint 2) Splits 766-LOC apps/web/src/modules/nutrition/NutritionApp.tsx into: - pages/NutritionStartPage.tsx (108 LOC): NutritionDashboard + photo disclosure (PhotoAnalyzeCard) - pages/NutritionPantryPage.tsx (124 LOC): pantry items / shopping list subtabs - pages/NutritionLogPage.tsx (59 LOC): meal log - pages/NutritionMenuPage.tsx (137 LOC): day plan / recipes subtabs - hooks/useNutritionPwaAction.ts (69 LOC): pwaAction effect (add_meal, add_meal_photo) extracted з NutritionApp - hooks/useNutritionRecipeCache.ts (58 LOC): sessionStorage recipe cache hydration when on menu/recipes tab - hooks/useNutritionPrefsState.ts (45 LOC): prefs useState + persistNutritionPrefs effect + SQLite-cache overlay NutritionApp.tsx стає orchestrator ~451 effective LOC (530 raw) — drops з eslint.config.js max-lines:600 allowlist (initiative 0013). i18n allowlist (apps/web/eslint.i18n-allowlist.json) розширено 4 новими page-файлами — Cyrillic JSX literals (SectionErrorBoundary title, SubTabs labels, photo-card summary) перенесено без змін. Strict refactor — no behavioral changes; усі 263 nutrition test pass. Co-Authored-By: dmytro.s.stakhov <dmytro.s.stakhov@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughNutritionApp is refactored to extract monolithic state management and UI rendering into reusable custom hooks and dedicated page components. Three new hooks encapsulate prefs state synchronization, PWA action routing, and recipe cache reading; four new page components replace inlined UI rendering. The main app orchestrates these while preserving existing functionality and reducing code complexity. ChangesNutrition Module Refactoring
Sequence Diagram(s)sequenceDiagram
participant App as NutritionApp
participant PrefsHook as useNutritionPrefsState
participant PwaHook as useNutritionPwaAction
participant RecipeHook as useNutritionRecipeCache
participant Pages as Page Components
App->>PrefsHook: Initialize with sqliteCacheTick
PrefsHook->>PrefsHook: Load from localStorage
PrefsHook->>PrefsHook: Overlay SQLite cache when tick changes
PrefsHook->>App: Return prefs, setPrefs, error
App->>PwaHook: Initialize with pwaAction, controllers
PwaHook->>App: Watch pwaAction, trigger navigation/UI updates
App->>RecipeHook: Initialize with activePage, menuSubTab, cache key
RecipeHook->>RecipeHook: Read cache only when in menu/recipes view
RecipeHook->>App: Populate recipes state
App->>Pages: activePage === 'start' render NutritionStartPage
App->>Pages: activePage === 'log' render NutritionLogPage
App->>Pages: activePage === 'menu' render NutritionMenuPage
App->>Pages: activePage === 'pantry' render NutritionPantryPage
Pages->>App: User interactions, state updates
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏱️ CI Pipeline Duration ReportBased on the last 50 successful runs on the default branch. Overall Pipeline
Trend (last 20 runs): Per-Job Breakdown
|
Summary
Splits the 766-LOC
apps/web/src/modules/nutrition/NutritionApp.tsxorchestrator into 4 per-page components and 3 dedicated hooks, dropping the file from theeslint.config.jsmax-lines:600allowlist (initiative 0013, Sprint 2).Per-page components (
apps/web/src/modules/nutrition/pages/):NutritionStartPage.tsx(108 LOC) —NutritionDashboard+ the «Аналіз фото страви» disclosure (PhotoAnalyzeCard)NutritionPantryPage.tsx(124 LOC) — pantry items / shopping list subtabsNutritionLogPage.tsx(59 LOC) — meal logNutritionMenuPage.tsx(137 LOC) — day plan / recipes subtabsDedicated hooks (
apps/web/src/modules/nutrition/hooks/):useNutritionPwaAction.ts(69 LOC) —pwaActioneffect (add_meal,add_meal_photo)useNutritionRecipeCache.ts(58 LOC) — sessionStorage recipe cache hydration when on menu/recipesuseNutritionPrefsState.ts(45 LOC) —loadNutritionPrefsstate + persist effect + SQLite-cache overlayNutritionApp.tsxстає orchestrator з 451 effective LOC (530 raw) — суто компонує сторінки, оверлеї та хуки.The i18n allowlist (
apps/web/eslint.i18n-allowlist.json) is extended with the 4 new page files because theirSectionErrorBoundarytitles /SubTabslabels / disclosure summary carry the same Cyrillic JSX literals that the original file already had on the allowlist.Governing Skill
.agents/skills/sergeant-web-ui/SKILL.mdPlaybook
Verification
pnpm --filter @sergeant/web typecheckзараз падає уsrc/core/hub/chat/ChatEmpty.tsx:74— це pre-existing помилка наmain(поза скоупом цього PR).Additional checks:
Docs and Governance
AGENTS.mdneeded an update. (no — initiative0013is the authoritative tracker; allowlist updated ineslint.config.js)Updated docs:
Risk and Rollout
NutritionAppdefault export, props, behavior) identical.Hard Rule #15
AGENTS.mdbefore coding.--no-verify.Audit-freeze (until 2026-06-02)
Reviewer Notes
AssetsTable.tsx; #2499 дляfizrukActions.ts).eslint.config.jsтримає 2 файли:hubChatContext.ts(потребує architectural sketch) іHubDashboard.tsx(837 LOC — окрема сесія).NutritionApp.tsxНЕ має власних тестів — public surface не змінювалась; покриття залишається на рівні hooks/components.Link to Devin session: https://app.devin.ai/sessions/7994b57a53e24056aa05b7d2f9af7b19
Summary by cubic
Split the monolithic NutritionApp.tsx into four per‑page components and three focused hooks to simplify the nutrition module and remove the file from the ESLint max‑lines allowlist. No behavior changes.
NutritionApp.tsxnow orchestrates pages/overlays/hooks (~451 LOC) and was removed fromeslint.config.jsmax‑lines allowlist.apps/web/eslint.i18n-allowlist.json.Written for commit 92cbfee. Summary will update on new commits.
Summary by CodeRabbit