[PR #162·164] The App Home Screen: The Server Sends a Summary, the App Only Turns Numbers into Text
I requested this work.
- What was done: I had the customer app’s home screen turned from a placeholder into a real screen, in two PRs.
- Server (PR #162): Claude built one route that returns everything the home screen needs,
GET /modules/:moduleId/home. It returns the module name and facility name, the schedule as of today (Korean date), and the average of the most recent measurement record. If there is no valid measurement record, it returnsnull, not 0. The route passes the same four access checks, in the same order, as the record routes built earlier. - App (PR #164): The home screen now has a header (tap the module name to switch modules), a stage label, a character, the latest average and its date, how many days have passed and how many remain, a progress gauge, and a
Recordbutton. The app does no date math; it only turns the numbers the server sends into text (homeDisplay).
- Server (PR #162): Claude built one route that returns everything the home screen needs,
- Choices made:
- The latest measurement is found with one SQL query (the language for asking the database), joined with the current version of each record, looking only at valid records, using exactly the sort rule the record list uses and taking one row. Reading everything and sorting in code was rejected because the sort rule would then live in two places.
- The average calculation was pulled out of the record list into a function that the list and the home route share. Copying it into the home route could let the two rules drift apart.
- The schedule is not recalculated; the existing schedule calculation is reused.
- The home summary is read-only, so it writes no audit record (a log of who did what).
- In the app, the home response is stored under a per-module key (
['home', moduleId]), and if the module in the response differs from the current module, nothing is drawn. This keeps even a brief flash of the previous module’s or previous account’s home from appearing. - Automatic retry is turned off for the home request. On an error there is a
Try againbutton, and automatic retry would only delay the error message by a few seconds. - The character is drawn with text symbols, with no new image file. When the design images arrive, only
HomeParts.tsxneeds to change.
- Checks:
- On the server, the full
npm run verifypassed (47 server test files, 569 tests). In the cloud session, Docker Hub’s rate limit (429) blocked pulling the PostgreSQL image once, and it worked when pulled again a little later. - In the app, the 7 tests in
home-display.test.tspassed. Of the 10 tests in the home screen filehome.test.tsx, 4 failed at first, and all four were problems on the test side (see Lessons). After Fizz, who wrote the tests, fixed them, GitHub CI’sverifyande2eboth passed.
- On the server, the full
- Review:
- Server: Fizz (backend and security) found no defect worth blocking on. General review normally goes to Pollen, but its free models had run out, so Honey (Claude Haiku 5.5) took it over and pointed out 3 test gaps.
- App: Pollen (an OpenCode free model) passed it. One medium finding (the latest-average line was missing its
latest averagelabel) was checked by the PL against the plan and confirmed, then applied.
| Item | Detail |
|---|---|
| Built | A home summary server route; the home screen (header, stage label, average, day counts, gauge, record button) |
| Prevented | The previous module’s or account’s home appearing; the list and home calculating averages differently |
| Checks | 569 server tests pass; app home tests pass after 4 test-side fixes; CI verify and e2e pass |
Who did what
- I: requested the work.
- Claude (cloud session, Claude Sonnet 5.5): implemented the server route and the home screen.
- Claude (PL, Claude Sonnet 5.5): coordinated the work and checked review findings against the code.
- Fizz (GPT-6 Luna): wrote the tests, did the server review (backend and security), and fixed the test problems.
- Honey (Claude Haiku 5.5): took over the general review on the server side.
- Pollen (an OpenCode free model): reviewed the app side.
Lessons
- When a screen’s data arrives asynchronously, the test has to wait for it. A test drew the screen and immediately looked for text, but the home response arrives later (asynchronously), so the screen was still loading. Switching to
findBy*, which waits, made it pass. Claude noted that the person writing the tests and the person implementing need a way to check each other on whether async responses are awaited. - The implementing side reported the test problems instead of editing the tests. One of the four first failures was
removeQueriesnot notifying the screen that was watching, so it never refetched. Another was that the app sends a refresh request when it gets an expired token, but the test registered no response for it. Claude fixed the first two in a temporary copy only to confirm they would pass, left the test file alone, and Fizz, who wrote the tests, fixed the file. - A tie-breaking test has to be tried with the sort key removed. A test checked sorting using two records with the same measurement time, but the two records had the same average, so it passed even without the sort key. The second record’s value was changed so the test fails if the sort is wrong. Only the test changed; the implementation did not. Because Fizz, who wrote the tests, made the fix, the rule that the implementer and the test writer are different people still held.
- Nonsense module IDs are blocked too. A module ID that is not shaped like a UUID (a long identifying number) gets a 403 from the existing access check. That test was added after review.