In an offline field-inspection mobile app, what app-wide sync status should technicians see, and what must happen to unsent outbox entries at sign-out?
answer
- the queue is the only truth
- a query, not a counter
- waiting is calm, parked is an alarm
- entries belong to one account
- discard only when confirmed
basics
~20 sShow counts derived from the outbox itself: changes waiting, sending, needing attention, and when it last synced. At sign-out, warn about unsent entries, try to send them, never send them under another account, and discard only on explicit confirmation.
solid answer
~40 sThe status view is a live query over the outbox, not a separate counter, so it stays true after any kill. It separates four states: waiting for coverage (normal, calm), sending ('3 of 12'), needing attention (parked entries the user must fix or discard), and synced, with the time of the last completed drain. Sign-out is where unsent work is most easily destroyed. Every entry is tagged with its account and only the signed-in account's entries are sent, so one technician's changes never go out under another's credentials. The app tells the user how many changes are unsent, tries to send them if online, and discards them only on a confirmation that names what is lost. Blocking sign-out until the queue is empty sounds safe but traps anyone holding a parked entry.
go deeper
Recall that the app must tell the user when changes are still waiting to be sent, and must not quietly throw them away when someone signs out.
Explain why the status comes from a query over the outbox, how waiting, sending, needs-attention and synced differ, and why each entry carries its account.
Design the sign-out path: warn, attempt a send, never cross accounts, discard only on confirmation, and avoid a block that traps users holding a parked entry.
Set one sync-status vocabulary and one sign-out rule for every offline feature, so support and supervisors can trust what any screen says about unsent work.
## The situation A site supervisor asks a technician: "Did yesterday's boiler inspection reach the office?" The technician looks at the app. Whatever it shows must be true - if it says "all synced" while three entries wait in the outbox, the office acts on an incomplete report. This question is about the **app-wide view of the outbox**: what it says, where its numbers come from, and what happens to unsent entries when the technician signs out. ## Derive the status from the queue itself The only honest source of "what has not been sent" is the outbox table. The status view should be an **observable query** over it rather than anything kept on the side: - **A separate counter drifts.** A kill between committing an entry and bumping the counter, or between an acknowledgement and the decrement, leaves it wrong for good. - **A query cannot drift.** It reads the same rows the drain changes, so after any crash it shows the truth. - **In-flight requests are the wrong source.** Offline, nothing is in flight, yet work is waiting. - **The server cannot help.** It cannot report what it has never received. ## Four states worth telling apart | State | What it means | What the technician sees | |---|---|---| | Waiting | Pending entries, no connection | "4 changes waiting - they'll send when you're back online" | | Sending | A drain is under way | "Sending 3 of 12" | | Needs attention | Parked entries the server rejected; resending unchanged will not help | "1 change couldn't be sent" with a link to fix or discard | | Synced | The queue is empty | "All changes sent - last synced 14:32" | In this app, waiting offline is normal and gets a calm tone; only **needs attention** is an alarm. Entries that have been retried for days without an answer can join "needs attention" as **stuck**, with advice to reach coverage. "Last synced" is the time of the last completed drain. The device clock is fine for showing it, though it must never be used to order or merge writes. A per-job count on the jobs list answers the supervisor's question directly; the marker on an individual field or finding belongs to the design of optimistic state. ## Signing out with unsent work The outbox holds one person's changes, attributed to that person's account. Sign-out is where that work is most easily lost: 1. **Never send one user's entries with another user's credentials.** Tag every entry with its account and drain only the signed-in account's entries; otherwise the server records the writes under the wrong name or refuses them. 2. **Say what is at stake** - "3 changes haven't been sent" - and try to send them now if there is a connection. 3. **Discard only on an explicit confirmation** that names what will be lost. 4. **If the technician must sign out with no coverage**, keeping the entries for that same account, to send at the next sign-in, is a reasonable choice - provided another user of the phone cannot read them. Blocking sign-out until the queue is empty sounds safe, but it traps a user whose queue holds a parked entry that will never be acknowledged. What the app wipes from its caches and local store at sign-out is a question for the caching design; the outbox's question is only what happens to unsent work. ## What the app cannot prevent Anything that deletes the app's private storage takes unsent entries with it: - an uninstall that removes the app's files; - clearing the app's data from the system settings; - a lost, broken or reset phone. A clear "N changes waiting" on the home screen is the main defence: technicians who can see unsent work do not reinstall the app to fix a glitch. Draining the queue in the background, when the OS allows it, is an extra route rather than a promise; when and whether an app may run in the background is a separate design area. The same status is also the app's best support tool. When a technician reports a missing inspection, "3 changes waiting, last synced Tuesday 16:05" on their screen tells support at once that the work is on the phone, not lost on the server, and that the fix is coverage rather than a bug hunt.
- Why not keep a simple counter of unsent changes in the app's settings?Because it is a second copy of a fact the outbox already holds, and the two drift apart: a kill between committing an entry and updating the counter leaves it wrong for good. A query over the queue's pending and parked rows changes in the same transactions as the queue, so it is right after any crash.
- Should a technician's unsent entries survive another technician signing in on the same phone?They can be kept, tagged with their own account, but they must never be sent under the second technician's credentials and must not be readable by that person. They resume when the original technician signs in again. If that cannot be guaranteed, the honest options are send now or discard with confirmation.
- Queued work needs no indicator; a spinner while requests are in flight is enough.
- Sign-out can just clear the database, because unsent entries are only a cache.
- A separate unsent-changes counter stays accurate if it is updated after each send.
- Leftover entries can be sent with whoever is signed in next.
- Every waiting entry is an error the user must be alerted to.