OpenProgram / Conversation frontend / Target design

Read and interact while state recovers

Audience: frontend and runtime maintainers. Scope: initial open, navigation, long history, streaming, tools, approval waits, draft and send recovery, offline states, background work, and accessible interaction. The complete scenario matrix is the release contract; automated and installed-App evidence have separate owners.

Observed behavior

11–14 secondsNative refresh until the transcript appears.
0.18–0.20 secondsDirect initial history request.
16 recoveriesProcessed before the first history request; five history loads in one refresh.

The measured baseline reconnect path sends every persisted execution cursor before the selected conversation. The server processes commands serially per connection. Replay snapshots enter the live execution update path, which requests another transcript for terminal executions. Cursor storage retains completed executions and performs synchronous persistence on every cursor frame. Some persisted execution streams contain more than 200 MB of event payloads. The current Web replay handler only consumes the resulting execution snapshot. Recovery reads therefore request snapshot-only mode: the execution record and event cursor are read in one SQLite transaction without reading event bodies. Explicit event-history clients keep their existing behavior.

Official references and adoption

ReferenceSupported behaviorOpenProgram choice
Codex App ServerSeparate stored thread reads, resume/subscription, paginated turns/items, turn and item notifications.Adopt separate transcript and execution recovery ownership. Use existing OpenProgram protocol; do not claim to copy private desktop rendering internals.
Claude Code interactive modeQueued input, interrupt controls, editable queued entries, background tasks, prompt history.Preserve drafts and attachments independently of connection and execution state; show delivery and approval states explicitly.
Claude Code checkpointingConversation and file restoration choices.Keep existing OpenProgram branch/rewind semantics explicit; history viewing never executes or rewinds work.

These sources establish observable behavior and public protocols, not private implementation or benchmark equivalence. Experimental Codex pagination is a reference for bounded reads, not a compatibility dependency. Backgrounding semantics vary; OpenProgram retains its own cancellation and approval contracts.

State ownership and data flow

Conversation loading and recovery orderConnection opens, the visible conversation loads first, then relevant execution state recovers in bounded requests.Connection readyVisible transcriptBounded execution recoveryLive deltas remain authoritative
TranscriptOne request owner per session and view generation. Persisted messages, pagination, search targets and scroll anchors.
ExecutionMonotonic cursors and status versions, active task and approval identity. Snapshot recovery does not simulate a new terminal event.
ComposerSession-owned draft, attachments, queued entries and acknowledgement. Navigation or disconnect never clears unacknowledged input.

Connection generation owns timers, pending read requests and fragment buffers. Obsolete responses cannot mutate a new connection or the visible session. Storage failures degrade persistence, not event delivery. The server remains authoritative for authorization, execution, cancellation and approvals. No client optimization bypasses those boundaries.

Transcript read lifecycle

A connection owns one pending initial or refresh request per session. Navigation reuses an existing read; a mutation invalidates it and retains one replacement request with the latest options. Each response echoes its request ID. Expired, replaced and closed-connection replies are ignored. A read has a 15-second deadline and session-local loading, disconnected or failed presentation with a retry button. Cached messages remain visible. Live messages changed since the request began take precedence over its snapshot. The existing message store remains authoritative; no second transcript store is introduced.

Pagination keeps its existing window and generation checks. An invalid snapshot cursor triggers one cursor-free read around the current reading anchor; failure remains visible and retryable. If renewal fails, automatic paging stops against that invalid snapshot. Explicit retry uses a cursor-free anchor read that retains the requested branch head; a separate latest-history action is available when the anchor is gone. Route cache rendering reuses the existing message store, preserving live rows absent from the wire cache. Loading transitions do not reset exponential retry delays. Read retries never repeat mutations, submissions, approvals or cancellation commands.

Streaming and reading

Text and thinking deltas coalesce per reply into one animation-frame store update. A history request flushes its session's already-received deltas before capturing the baseline. Accepting the response flushes any later deltas before merging, so only progress received after the request can override its snapshot. History cleanup releases only that session's message routing; another pane's pending stream remains scheduled. Connection close and unmount flush received progress before clearing the old connection's routing and buffers. Tool and terminal events retain their immediate flush ordering. Existing bounded history windows, measured row recycling, lazy full tool output, and independent follow locks remain the rendering primitives.

Acceptance matrix

Scenario / public entryRequired outcomeEvidence
Open or reconnect / useWSVisible history requested before saved execution recovery. No replay-driven transcript storm. At most one recovery request in flight; duplicate needs coalesce.Controlled transport tests and native cold/warm refresh timing.
Switch A → B → ADraft and reading position survive. Late A responses cannot replace B. Cached content stays visible during refresh.Rapid switching and delayed response acceptance.
Long history / paging and jumpBounded reads and DOM, stable prepend anchor, stale cursor recovery, reachable earliest message, explicit retry on failure.Large transcript, oldest/latest/search targets, interrupted paging.
Streaming text and toolsFrame-batched updates; reading history is not interrupted by auto-follow. Expanded output loads on demand; completion flushes final deltas.Burst/delayed deltas, output expansion, long-content render budget.
Send, queue, steer, stopInput retained until acknowledgement; no duplicate submission on reconnect; explicit queued/sending/failed state; cancellation cannot revive the old turn.Disconnect before/after ACK, active queue, retry and cancellation.
Approvals and questionsWaiting is distinguishable from generating. Reconnect restores current waits. A stale answer cannot resolve a newer generation.Refresh during ask/approval and terminal cleanup.
Background and nested workRelevant status recovers without resetting the foreground transcript or merging child history.Two-session and nested execution tests.
Errors and accessibilityLoading, offline and failed reads have visible, keyboard-accessible recovery. No false success, infinite spinner or lost draft. Reduced motion and narrow layout remain usable.Transport faults, keyboard checks and native visual inspection.

Implementation sequence

  1. Centralize reconnect and execution recovery, distinguish recovered snapshots from live transitions, and make cursor persistence resilient. Use atomic snapshot-only reads for ordinary UI recovery; preserve full event replay for explicit inspection.
  2. Centralize history request ownership, navigation generations, stale-cursor recovery and loading/error/retry presentation.
  3. Validate and optimize long-history rendering, streaming batching, tool output expansion, scroll follow and jump behavior.
  4. Complete interaction coverage for drafts, queue/ACK/retry/cancel/steer, approvals, background tasks and accessibility.
  5. Run combined verification, update the default App once, and measure the full scenario matrix.

Each stage receives independent specification and quality review. Passing one stage does not establish completion of the whole frontend. No new execution runtime, remote service, account integration or historical data deletion is part of this design.

Resource projection during chat loading

Resource polling shares the worker with transcript hydration. Each resource-list request reuses one conversation graph, one predecessor index and memoized origin and branch-name results across all visible resources. The current-branch query may use one separate graph snapshot. These values live only for that request; the next request observes branch renames and head changes. Resource visibility, execution attribution, control reconciliation and stable branch-reference selection remain authoritative. Native acceptance exposed repeated per-resource DAG reads and history responses exceeding the 15-second read deadline. The repair passes independent specification and quality reviews, a public resource-endpoint regression and the complete combined verification manifest. On the affected conversation, equivalent resource queries take 124–147 ms instead of 5,741–5,760 ms; these are resource-query measurements, not whole-page load times.

Implementation evidence

The integrated implementation passes independent review and complete automated verification, including the resource-projection repair found during native acceptance. Recovery ordering, snapshot-only reads, correlated history requests, visible retry, session-scoped streaming buffers and the existing interaction primitives pass independent specification and quality reviews. The final integrated candidate also preserves failed-reply details, streaming steer interruption and stopped-turn history retention.

The combined manifest passes 10,480 Python tests, 964 Web tests and 168 browser tests. It reports 138 Python skips, one expected Python failure and 20 browser skips. Structural checks, typecheck, production build, documentation links and diff checks pass. Focused regressions verify that recovery never reads historical event payload bodies, snapshot records and cursors are consistent, old read replies cannot replace later progress, cancelled buffers cannot revive a reply, and cancelled steering drafts cannot automatically send after history reconciliation.

The browser matrix covers bounded large-history rendering, anchor restoration, failed cursor renewal and keyboard retry, peer-session isolation, draft and attachment ownership, queue receipts, stop and steer ordering, question remounts, IME, narrow layout and reduced motion. The local release ledger records exact implementation and integration commits, review verdicts and gate logs. Installed-App acceptance remains a separate release requirement: the release report owns the installed revision, target-conversation reload measurements, older-history navigation, draft preservation and native visual evidence. The figures above are baseline measurements, not a claim about the optimized App.