[PR #165·167] The App's Temporary Storage: Wiping It on Logout, and Picking and Uploading Photos
The two PRs belong to one line of work: where and how the customer app keeps entries and photos while a record is being written. First a temporary store that is wiped on logout (PR 165), then a path for picking, shooting and uploading photos on top of it (PR 167). I requested both, and a team of agents split them up.
- What was done:
- PR 165, the draft store: The content being written for each record kind (the draft) is saved on the device exactly as typed. An empty string (
'') and'0'are kept as different values. Photos are copied into the app’s own documents folder, and once the copy finishes the original in the temporary location is deleted. A save or copy that arrives late, after logout, is dropped because its “session number” no longer matches. - PR 165, wiping on logout: One logout routine deletes the drafts, the photos and the server responses cached for the screens. If another person logs in on the same phone, the previous person’s records or photos must not be visible, so this gap was treated as critical and closed. Convenience values, such as the module opened last, are kept.
- PR 167, the photo path: A photo that is picked or shot is converted to JPEG, checked against the size limit, stored, written into the draft and then uploaded. The camera is opened without extra information such as location (EXIF), and photo addresses are not written to logs. A photo strip lets people remove a photo or upload it again, and a denied permission shows guidance with an “open settings” button. If the app was killed while the camera was open, the photo is recovered the next time and attached to the draft (it is not uploaded again automatically).
- PR 165, the draft store: The content being written for each record kind (the draft) is saved on the device exactly as typed. An empty string (
- Methods chosen and alternatives dropped:
- When logout happens mid-write: after writing a file or value, the session number is checked once more, and what was just written is deleted if it changed. The same check follows every asynchronous step of picking or converting a photo.
- When wiping fails: logout continues even if the drafts cannot be deleted. A leftover login key is more dangerous than a leftover draft.
- Whether there is only one wiping path: the logout button, handling of a lost connection, and a missing or failed key refresh at startup all go through the same logout routine. When a refresh failed because the account was suspended, though, both the request handler and the startup code called it and wiped twice. The startup side was changed so it wipes only once.
- Blocking with an “already ended” flag was dropped. It broke three tests that move to the suspended-account screen during a login attempt.
- Writing the recovery location before opening the camera: the permission check happens inside the take-photo function, so if permission is denied no location is written. Writing it first in the hook (a bundle of screen logic) left leftovers when permission was denied.
- Putting draft reads and writes in a single line: so that several photos attached at once do not overwrite one another, reads and writes go through one queue.
- When an upload fails: failures other than “too large”, and storage failures, mark only that one photo as failed; the rest carry on.
- Caught in review:
- The general review (Pollen) passed but left four low-severity remarks. One of them, that a pending save timer could bring back a deleted item, was to be handled in PR 167, and the fix was already in that branch.
- Because the work touched logout and personal photos, Opus 5.5 did a separate final review and found one medium-severity issue: two functions that remove items could bring a draft back after logout. The PL confirmed it in the code and it was fixed. Both functions now use the session number from when they started and also cancel that item’s pending save timer. If logout happens while a photo is being copied, the original in the temporary location is deleted too.
- Checks:
- In PR 165, Fizz’s tests were run first and all failed only because the feature did not exist; after the implementation 255 app tests passed. GitHub’s checks (
verify,e2e) passed after the last change. - In PR 167, Claude found two defects in the tests: a faked library did not provide a value the test needed, so the test died inside itself, and one test file had a type error. As the work order required, Claude did not edit the tests; it stopped and reported. Running a copy with only those three spots fixed passed all 13 tests, which confirmed the implementation meets the contract, and the copy was deleted.
- In PR 165, Fizz’s tests were run first and all failed only because the feature did not exist; after the implementation 255 app tests passed. GitHub’s checks (
The Two PRs at a Glance
| PR | What was done | Key method |
|---|---|---|
| 165 | Draft store, wiping on logout | Late saves dropped by session number, one wiping path, logout continues if wiping fails |
| 167 | Picking, shooting, converting and uploading photos | Session number checked after every step, shooting without extra data, a failure affects only that slot |
Who Did What
- I: requested both pieces of work and decided to put the draft store and the wiping on logout in one PR (an easily reversible decision).
- Claude (PL, Claude Sonnet 5.5): directed the work and checked the scope of changes and the review remarks.
- Claude (cloud session, Claude Sonnet 5.5): implemented both pieces of work and, in PR 167, found and reported the test defects.
- Claude (Claude Opus 5.5): did the final review in PR 165 of the parts touching logout and personal photos.
- Fizz (GPT-6 Luna): wrote the tests first.
- Pollen (an OpenCode free model): did the general review of PR 165.
What Was Not Confirmed
- It was not confirmed on a real device whether a file copy waits until it finishes. The code uses
awaitso that both behaviors are handled. - In PR 165 this session could not run the whole server test suite (no server code was touched), so the judgment was left to GitHub’s checks. In PR 167 the environment could not run server tests, so that too was left to GitHub’s checks.
- The photo path was checked against faked parts in tests. Behavior with a real camera and photo library was not confirmed.
Lessons
- Content kept temporarily on a device needs both “whose is it” and “until when” decided. Everything is wiped on logout, and work that arrives late is dropped by session number.
- Gather the wiping into one place. It prevents one place being forgotten when wiping is scattered, and any place that wipes twice should be found and fixed.
- Decide first what happens when wiping fails. Even if a draft cannot be deleted, the login key must be.
- When a test is wrong, do not bend the implementation to it: confirm with a copy only, then report so the author of the tests fixes it.