Day 5: My App Works Offline and Never Counts Twice
Watch an AI agent make a Flutter app work offline on AppAmbit. A cache under every read, an offline queue that survives a restart, and idempotent Cloud Code writes checked through the AppAmbit MCP. A real sync bug fixed on camera.
Watch the full tutorial or read the summary below
Overview
Day 5 of the Unshrimp build: an app that nags you to fix your posture, built prompt by prompt on AppAmbit.
With no network, every screen showed an error and a finished break was lost. Today the app learns to work offline. A cache under every read means the app still opens and shows your data, with an "Offline" label and the time of that data. An offline queue keeps every break you finish on the phone and sends it when the network returns, even after the app is killed.
Sending again must never count again. Each break gets an ID, and Cloud Code stores it in the same transaction as the count, so a duplicate is skipped. The agent proves it through the AppAmbit MCP: the same break sent twice, one row in the Database. A real bug shows up on camera, and the episode ends by replaying the same break on purpose: the count doesn't move.
In This Episode
- The problem: with no network, every screen showed an error and a finished break was lost
- A cache under every read: offline, the app shows the saved copy with an "Offline" label and the time of the data
- An offline queue: every break you finish is stored on the phone and sent when the network returns
- Idempotency: each break gets an ID, and AppAmbit stores it in the same transaction, so a duplicate is skipped
- The agent checks it through the AppAmbit MCP: same break sent twice, one row in the database
- Finishing a break offline gets you out of the Posture Roast, and the queue survives killing the app
- A real bug on camera: the queue wasn't sent when returning to the app. Found, fixed, retested.
- The final proof: "Replay last op" resends the same break, and the count doesn't move
Chapters
- 0:00 Where the app stands
- 0:58 Network off: everything breaks
- 1:40 Prompt 1: a cache under every read
- 2:05 Offline home, settings and label
- 2:30 A break offline gets lost
- 2:58 Prompt 2: an offline queue
- 3:20 Idempotency: counted once
- 3:40 Checking it through the AppAmbit MCP
- 3:50 Prompt 3: escaping the roast offline
- 4:35 Waiting to sync, even after a restart
- 5:00 A real bug: the queue never sent
- 5:25 The fix and the retest
- 6:05 Replay the same break: still counted once
- 6:25 Recap and what's next
More in the Series
Links
Frequently Asked Questions
Q What does the app show when there is no network?
The last copy it saved, with an "Offline" label and the time of that data. Home and settings still open instead of showing an error.
Q What happens to a break I finish offline?
It is stored in a queue on the phone and sent when the network returns. The queue survives closing or killing the app, and finishing the break still gets you out of the Posture Roast.
Q How does AppAmbit avoid counting a break twice?
Each break gets an ID. Cloud Code stores that ID in the same transaction as the count, so if the same break arrives again, it is skipped. Sending twice gives one row in the database.
Q What was the bug in this episode?
The queue wasn't sent when you came back to the app, so breaks sat waiting to sync. The agent found it, fixed it and retested it on camera.
Q How was the "never counts twice" rule tested?
Through the AppAmbit MCP, the agent checked the database after sending the same break twice and found one row. At the end, "Replay last op" resends the same break on purpose, and the count doesn't move.
Ready to get started with AppAmbit?
Monitor your mobile apps with real-time crash reporting, analytics, and app distribution.
Start Free Trial