[PR #258·259] Fixing Review Findings Separately: New Records on Switched-Off Devices, and Dates and Times That Drifted
These two PRs fix findings that came out of reviews of earlier PRs. PR 258 fixes switched-off devices still collecting new records, and PR 259 fixes two ways dates and times drifted when picked in the customer app. I decided on 2026-11-22 to make both fixes and put that in the decision log.
| PR | What was wrong | Cause | What changed |
|---|---|---|---|
| 258 | Switched-off devices still collected new device input and refill records | The server did not check whether the device was switched off | Only new records are rejected with 400; edits of older records and resends of the same request work as before |
| 259 | A future time could be picked on Android | Only the date picker had a “today” limit; the time picker had none | Values later than now are refused, with a notice |
| 259 | Dates shifted by a day when the phone’s time zone was not Korea’s | The picker got midnight in Korea, read back on the Korean calendar | The picker gets noon in the phone’s time zone, read as a date on the phone’s calendar |
The two PRs split the work the opposite way.
- PR 258: A Claude Code session on my Windows computer (Claude Opus 5.5) wrote the work instructions and the implementation, and Codex (
gpt-6.1-terra) wrote the tests. The implementation side did not edit the tests. A lead session on the same computer (Claude Opus; the devlog gives no version) directed the overall work. - PR 259: The other way around: a Claude Code session (Claude Sonnet 5.5) wrote the tests and instructions first, and Codex (
gpt-6.1-terra) implemented.
PR 258: Switched-Off Devices Accept No New Records
What was wrong
Even when an admin had switched a device off, the customer app could still add new device input and refill records for it. Records piling up on a device that is not in use throw off the remaining-amount calculation.
What changed
- Server: A new device input or refill for a switched-off device is rejected with response code 400, and nothing is saved.
- Older records work as before: Edits, exclusions and undos of records made before the device was switched off are still accepted.
- Resending the same request works as before: If a request saved before the switch-off is sent again with the same request number, the server returns the saved record as is. This is what keeps a resend after a dropped connection from creating a duplicate record.
- Customer app: When the device input or refill screen gets this error, it shows a “switched-off device” notice and keeps what was typed.
The app’s device list already shows a “device not in use right now” notice instead of the record button for switched-off devices. The new notice is for when the list is out of date, such as an admin switching the device off after the screen was opened.
Chosen approach and rejected options
- Response code 400: The other errors of the same kind, “in use no more” (a switched-off material type, a switched-off reading item), are all 400, so this one matches.
- Rejected — 409 (state conflict): The lead session first said it would likely be 409, but I confirmed 400.
- Where the check goes: Right after the device is looked up in the function that saves a new record (
saveNew). The “was this request already sent?” check comes before it, so a request already saved keeps getting the same record back. The function that edits a record (newVersion) was left alone.- Rejected — reusing the “device not found” error: it gives the wrong reason for the rejection.
- Rejected — blocking edits too: a wrong record on a switched-off device could no longer be corrected.
- Replacing an old test: An earlier test, “switched-off and unnamed devices still accept records”, checked the old rule, so Codex replaced it with a test of the new rule. The part saying unnamed devices accept records was kept separately.
PR 259: Two Date and Time Problems in the Customer App
1. A future time could be picked on Android
What was wrong: On Android, picking a date first and then a time could give a time later than now. The date picker had an “up to today” limit, but the time picker had none. The time fields for input records and reading records share the same code, so both were affected.
What changed:
- A value later than now is not accepted; the previous value stays and the app shows “You can’t enter a future time”.
- The rule is “picked value > now”. Exactly now is accepted. On Android the combined date and time is checked, and on iOS the value the picker returns, with the same rule. The iOS picker in the reading time field also got a maximum date (
maximumDate). - The server check that rejects times more than 60 seconds in the future stays as it is.
- The notice text is kept separately for the two screens with the same wording, to follow the existing structure of the text groups.
2. Dates off by a day when the phone’s time zone is not Korea’s
What was wrong: The screen that records count changes passed “midnight in Korea” to the date picker and read the picked value back on the Korean calendar. On a phone not set to Korea’s time zone, the picker could open on the previous day, or the picked day could shift by one. For example, midnight in Korea is 3 p.m. the previous day in UTC, so on a phone set to UTC the date shows as the day before.
What changed: It now uses the approach another date screen (the input history screen) already used. The picker gets noon in the phone’s time zone, and the picked value is read as a date on the phone’s calendar. Noon stays on the same date even when time zones differ by several hours. The default “today” and the future-date check still use the Korean date.
Changing the time zone in the test environment
Time zone bugs only show up when tests run in another time zone. These are the methods Claude chose and rejected.
- Rejected — changing
process.env.TZinside a test: In jest (a JavaScript test tool),process.envinside a test is a copy, so changing it did not change the time zone. - Rejected — faking time zones with a fake
Date: the test drifts away from real behavior. - Chosen — a test environment file (
src/test/timezone-environment.js) that changes the process time zone per test file: one test file per time zone, with the test cases kept in one shared file that both time zone files use. It checks two zones: UTC and the US West Coast (behind Korea).
Having a test environment change the process time zone is new in this repository.
How it was checked
PR 258
- Codex wrote 6 tests (4 server, 2 customer app) and confirmed that the 2 new app tests failed on a commit holding only the tests. The server tests could not run on Codex’s side because it had no Docker (a tool that starts the database).
- After implementation, 17 tests in 2 server device test files and 60 tests for the app’s device input screen passed, along with type checks for the server, customer app and admin web.
- Full
npm run verifypassed in 667 seconds: admin web 492, customer app 761, server 860. No test needed a rerun. codex exec review --base origin/main(180 seconds) found nothing.- The admin web code did not change, so
npm run e2ewas not run.
PR 259
- Claude committed the tests first and confirmed they failed. Before implementation, 8 future-time tests failed, and 4 date time zone tests failed in each file.
- After Codex’s implementation, 312 tests in the 16 related suites (test groups) passed. Full
npm run verifyalso passed (480 seconds): customer app 785 in 60 suites, admin web 492, server 857. codex exec review --base origin/mainraised one finding. When the time zone test environment finished, just deleting theTZenvironment variable on Windows did not bring back the original time zone, so the same worker (a process that runs a share of the tests) could run the next test file in the changed zone, and an existing test could fail depending on order. The finding was right, so the fix saves the original time zone name and restores it at the end. After the fix, 48 tests in 4 suites passed with--runInBand(running tests one after another in a single process).- This last fix changed only the test environment file, and the full verify was not run again after it (only the related tests and lint). App lint had 0 errors and 11 warnings (all already there).
Not checked
- Trying to pick a future time on a real Android phone was not done.
- The full
npm run verifywas not rerun after PR 259’s last fix. - Whether the time zone test environment leaks into other tests was only checked once, with
--runInBand.
Lessons
- When a rule changes, first look for tests that checked the old rule. PR 258 had one, and Codex replaced it. Next time, the instructions list it as a “test to change” from the start.
- On Windows, deleting the
TZenvironment variable does not bring back a time zone that was already changed. Save the value before changing it and restore that value.