Skip to content

Live token-by-token streaming in session connect#42

Merged
hbrooks merged 3 commits into
mainfrom
connect-token-streaming
Jul 13, 2026
Merged

Live token-by-token streaming in session connect#42
hbrooks merged 3 commits into
mainfrom
connect-token-streaming

Conversation

@hbrooks

@hbrooks hbrooks commented Jul 13, 2026

Copy link
Copy Markdown
Member

What

Adds the client side of live streaming to agent session connect: an in-progress assistant line that fills token-by-token and a footer token counter, matching local Claude Code.

The committed transcript is unchanged (still the structured steps API, grouped tool calls/results). This layers the backend's new ephemeral delta frames (partial assistant text + running output_tokens, from the --include-partial-messages relay) on top:

  • ws.ts: delta added to StreamFrame (text?, output_tokens?); flows through onFrame, doesn't terminate the stream.
  • ConnectApp.tsx: a delta frame updates a live overlay (append text) + the live token counter, and does NOT trigger a steps refresh (no polling storm). The overlay clears when the committed assistant step lands (superseding it) or the turn settles.

Compatibility

Backward-compatible: against a backend that doesn't emit delta frames (current prod, until the monorepo PR ships), behavior is unchanged (step-granular, as v0.8.2). Safe to merge/release ahead of the backend.

Depends on

The backend relay (monorepo PR): headless run_session_loop + --include-partial-messages to an agent_deltas channel to a {type:"delta"} frame on /stream. This PR is the consumer.

Tests

typecheck + 214 vitest tests + build all green.

hbrooks added 3 commits July 13, 2026 10:11
The committed transcript still comes from the steps API (grouped tool calls /
results), but the socket now also carries ephemeral `delta` frames (partial
assistant text + a running output-token count) from the backend's
--include-partial-messages relay. Render them as a live in-progress line and a
footer token counter (the token-by-token feel of local Claude Code), superseded
by the committed step when it lands. Delta frames do NOT trigger a steps refresh
(no polling storm). Backward-compatible: against a backend that doesn't emit
deltas, behavior is unchanged (step-granular).
@hbrooks hbrooks merged commit a4fff23 into main Jul 13, 2026
1 check passed
@hbrooks hbrooks deleted the connect-token-streaming branch July 13, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant