refactor: extract TodayPage and Worker god files - #44
Merged
Conversation
Keep worker.ts as the Hono composition root and TodayPage as the router export. Route groups move under src/worker/; Today sections and hook move under src/pages/today/. Food-entry behavior, auth, and D1 SQL semantics are unchanged. Closes #43
Move entry-sheet state, effects, and handlers into useTodayEntrySheet with module-scope helpers so useTodayPage is a composer under the 616 line cap. Lift worker route handlers out of register* wrappers and group a couple of Today panel props so complexity stays at 30 violations.
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.
Why
src/worker.ts(2,186 lines) andsrc/pages/TodayPage.tsx(2,091 lines) were unreviewable hubs. Domain libs were fine; the composition roots were not.What
Behavior-preserving extract only. No food-entry, auth, or D1 SQL semantic changes.
Worker —
src/worker.tsstays the Wrangler/Hono composition root (wrangler.jsoncmainunchanged). Route groups move tosrc/worker/:auth.ts— health, Better Auth, native handoff, session/MCP middlewareaccount.ts— profile, bootstrap, cycles, MCP tokens, journal exportjournal.ts— foods, entries, water, medications, weightsreads.ts— dashboard and historymcp.ts— MCP GET readsdb.ts/http.ts/types.ts— shared mapping, validation, app typesToday —
TodayPageremains the router export. Sections and hook live undersrc/pages/today/:useTodayPage.ts— load, optimistic log, undo, editorsSource tests now scan the Worker modules instead of a single file.
Closes #43
Line counts
src/worker.tssrc/worker/account.tssrc/worker/auth.tssrc/worker/db.tssrc/worker/http.tssrc/worker/journal.tssrc/worker/mcp.tssrc/worker/reads.tssrc/worker/types.tssrc/pages/TodayPage.tsxsrc/pages/today/useTodayPage.tssrc/pages/today/TodayEntrySheet.tsxsrc/pages/today/*Checks
pnpm test— 169 passedpnpm test:coverage— thresholds heldtscapp + workerbiomeformat + lintOut of scope: native rewrite, coverage-floor raises, deploys.