stream Claude replies token-by-token from stream_event deltas

A live capture against claude 2.1.150 (both --print and the interactive
stream-json transport clide uses) confirms --include-partial-messages
emits the in-progress reply as stream_event envelopes wrapping Anthropic
streaming deltas — NOT assistant events with partial:true, which is what
T-168 assumed, so that handler never fired and streaming was inert.

Replace it: accumulate content_block_delta text per message id (tracked
from message_start, since deltas carry no id) and emit a placeholder under
a stable partial-<id> uuid the controller upserts in place; the matching
single-text-block assistant event reuses that uuid to finalize, while
tool_use / thinking blocks keep their own uuids and append in order. Tests
rewritten against the captured shape; spike doc records it.

T-184.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-05-31 12:16:52 +02:00
co-authored by Claude
parent 494a6f13a5
commit d0ad8ed4aa
6 changed files with 185 additions and 79 deletions
+5
View File
@@ -18,6 +18,11 @@ heading, and (b) bumping `pubspec.yaml` `version:` in the same commit.
### Fixed
- Claude replies now stream token-by-token. The `--include-partial-messages`
output arrives as `stream_event` deltas (not `assistant`+`partial:true` as
first assumed), so the previous handler never fired; the session now reads the
real shape, growing a placeholder in place and finalizing it from the matching
`assistant` event. (T-184)
- Claude conversation card actions (copy + custom) are now keyboard-focusable
and always reachable — revealed on hover or focus, activatable by Tab +
Enter/Space, with Semantics labels for assistive tech (T-174).