As an agent user, I want to have an open conversation stay up to date and recover by itself when the connection drops, so that I never act on a stale picture of what my agent did.
Situation
My agent works for minutes while a conversation is open. My phone changes networks, or I leave the screen open for a long time.
What I do
Keep the conversation open.
If a red line says the connection was lost, wait a moment for the app to reconnect.
If I do not want to wait, tap "Retry" on that line or the refresh button in the bar.
What I should see
New messages, tool cards and run changes arrive in the Agent session by themselves. I never need to reload to see the reply.
When the live connection drops, a red line appears at the end of the conversation: "Live connection lost. Reconnect to see the latest messages." with "Retry".
The app tries again by itself: after about one second, then waiting twice as long each time, up to ten seconds between tries.
When the connection is back the red line goes away without my doing anything.
Messages that arrived while I was disconnected appear once, in the right place. Nothing is doubled and nothing is missing.
The bar always has a refresh button, read by VoiceOver as "Reconnect". Tapping it reconnects and reloads the conversation and its runs.
If only the updates about runs are lost, the line reads "Run updates disconnected. Reconnect to refresh."
A conversation left open and idle for several minutes still works: it stays connected and later loads succeed.
When I come back to the Agents tab from another tab, the screen I left is reloaded and reconnected.
On the Agents list, the server's status line ("Online" or "Offline") is checked again about once a minute, and pulling down checks it at once.
When something goes wrong
If the server stays unreachable, the red line stays and the app keeps trying every ten seconds. I can tap "Retry" at any time. The Agents list shows the server as "Offline" with the reason.
If a message was being sent when the connection dropped, my text stays in the field and I send it again. See Chat with an agent.
Not included
There is no sign that says the conversation is live. I am only told when the connection is lost (status signals).
The app does not notify me when an agent finishes while the app is closed or another tab is showing.
Requests to the agent server have no time limit of their own, so a server that accepts but never answers leaves the screen loading (current limits).
Trace
Story US-AGENT-09, status Shipped. These links are kept in step with the traceability matrix and with the "User stories" section of every page listed here.
Design
Page | Part it plays |
|---|---|
How each connection reports its state | |
The Disconnected state, the Reconnect action and the failure line | |
The failure line's place at the tail | |
The red line with Retry | |
The server status line and pull to refresh | |
The agent screen that refreshes by itself | |
Refresh behaviour | |
Failure with Retry | |
The Reconnect bar button | |
The Reconnect label | |
Connection loss is said, never hidden |
Implementation
Page | Part it plays |
|---|---|
The three WebSocket streams, their states and error texts | |
The borrowed server clock for reads and the run snapshot guard | |
upsertEvent: replay without duplicates | |
Signed Subscribe and the socket endpoint | |
Where the failure line and Reconnect are drawn | |
Subscribe keys, afterSeq replay and frame kinds | |
agentsReconnect, agentsHealth, agentsVisit, the reconnect delay state | |
Request time and read time stamps that reopen resources | |
Streams exposed as resources | |
The UI tests of disconnect and idle clocks | |
/dev/disconnect, /dev/clock-checkpoint and /dev/assert-fresh-reads | |
Unit tests of timestamps, bad frames and the stream race | |
Agents requests pass no timeout |
Code
File | What |
|---|---|
Session bar with the Reconnect button | |
Failure line and status line at the tail | |
agentsRequestTime, agentsReadTime and the reconnect state | |
agentsVisit, agentsAgentChanged, agentsHealth, agentsReconnect tasks | |
agentsStampVisit to agentsRefresh: backoff and reconnect | |
noteServerTime, readTime, parseFrame | |
agentsSessionStream | |
agentsRunStream | |
agentsAgentStream | |
Run snapshot guard against an older HTTP reply | |
upsertEvent |
Tests
File | What it checks |
|---|---|
a dropped stream reconnects and recovers the offline message once | |
read clocks advance on an idle session without reopening any stream | |
resource reads adopt server time only forward, so a long-open screen keeps working | |
a non-JSON WebSocket frame does not throw out of the stream mapper | |
idle reads use the fresh caller clock even when no live frame has arrived | |
a delayed HTTP tree cannot overwrite a newer completed run from the stream |
Delivery
Delivered by #1470.
Related stories
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime