Skip to content

Resume chat after reconnect via sequence cursor (gateway + mobile clients) #100197

Description

@steipete

Problem

When a mobile client loses its WebSocket mid-run (backgrounding, network handoff), events emitted while disconnected are gone: the gateway keeps no replay buffer, and gap detection today only broadcasts an observational "seq gap" error. Clients recover by refetching full history — the iOS app additionally runs a post-send polling ladder (1.5s→90s) to catch late messages. Recovery is slow, bandwidth-heavy, and still misses in-flight streaming state.

Proposal

Additive, no protocol version bump:

  1. Gateway: optional afterSeq cursor on chat.history — return only messages after the given per-run/session sequence point (existing seq fields in the chat event schema; offset pagination unchanged when the param is absent).
  2. Clients (iOS, Android): track the last applied seq per session; on reconnect, fetch the delta via afterSeq and reconcile instead of refetching everything. Fall back to full history against gateways that don't support the param (App Store app vs. older gateway is a real skew). iOS can then retire most of the post-send polling ladder.

Impact

Fast, cheap recovery after backgrounding — the top item on the mobile "reconnect recovery" workstream — and less gateway load from full-history refetches.

Metadata

Metadata

Assignees

Labels

P1High-priority user-facing bug, regression, or broken workflow.app: androidApp: androidapp: iosApp: iosclawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.enhancementNew feature or requestimpact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.maintainerMaintainer-authored PRmaturity:stableIssue affects a taxonomy feature currently scored M4/M5.

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions