Stay connected to a live conversation
An agent user wants a conversation to keep itself up to date, recover by itself after a dropped connection, and say so when it cannot.

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

Badges, countdowns and connection status

How each connection reports its state

Agent session

The Disconnected state, the Reconnect action and the failure line

Session timeline

The failure line's place at the tail

AgentError

The red line with Retry

Agents list

The server status line and pull to refresh

Agent detail

The agent screen that refreshes by itself

Refresh, haptics and progress

Refresh behaviour

Loading, failure and empty states

Failure with Retry

Every bar button

The Reconnect bar button

Roles, headings and labels

The Reconnect label

Honest state: loading, failure and empty

Connection loss is said, never hidden

Implementation

Page

Part it plays

Agents: WebSocket streams as resources

The three WebSocket streams, their states and error texts

Agents: reads, commands and the clock

The borrowed server clock for reads and the run snapshot guard

Agents: chat rows and run cards

upsertEvent: replay without duplicates

Agents: signed action envelope and endpoints

Signed Subscribe and the socket endpoint

Agents: screens and components

Where the failure line and Reconnect are drawn

Agents server

Subscribe keys, afterSeq replay and frame kinds

Root declarations: Activity and Agents

agentsReconnect, agentsHealth, agentsVisit, the reconnect delay state

State, refresh and stale-reply patterns

Request time and read time stamps that reopen resources

The Exact framework

Streams exposed as resources

Contract UI tests

The UI tests of disconnect and idle clocks

Mock agents server

/dev/disconnect, /dev/clock-checkpoint and /dev/assert-fresh-reads

Bun unit tests

Unit tests of timestamps, bad frames and the stream race

Current limits and known gaps

Agents requests pass no timeout

Code

File

What

agents.contract L513-516

Session bar with the Reconnect button

agents.contract L501-504

Failure line and status line at the tail

app.contract L158-164

agentsRequestTime, agentsReadTime and the reconnect state

app.contract L199-206

agentsVisit, agentsAgentChanged, agentsHealth, agentsReconnect tasks

app.contract L432-463

agentsStampVisit to agentsRefresh: backoff and reconnect

src/agents/sources.ts L46-62

noteServerTime, readTime, parseFrame

src/agents/sources.ts L282-349

agentsSessionStream

src/agents/sources.ts L407-459

agentsRunStream

src/agents/sources.ts L221-244

agentsAgentStream

src/agents/sources.ts L370-376

Run snapshot guard against an older HTTP reply

src/agents/model.ts L106-108

upsertEvent

Tests

File

What it checks

agents.test.contract

a dropped stream reconnects and recovers the offline message once

agents.test.contract

read clocks advance on an idle session without reopening any stream

src/agents/__tests__/review.test.ts

resource reads adopt server time only forward, so a long-open screen keeps working

src/agents/__tests__/review.test.ts

a non-JSON WebSocket frame does not throw out of the stream mapper

src/agents/__tests__/parity.test.ts

idle reads use the fresh caller clock even when no live frame has arrived

src/agents/__tests__/parity.test.ts

a delayed HTTP tree cannot overwrite a newer completed run from the stream

Delivery

Delivered by #1470.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Attributes
Epic
Agents
name
Stay connected to a live conversation
Story
US-AGENT-09
Status
Shipped
summary
An agent user wants a conversation to keep itself up to date, recover by itself after a dropped connection, and say so when it cannot.