During a long think Claude streams thinking_delta events that say
nothing and carry estimated_tokens: its live progress beat. Both
decoders (the Claude subscription's readOutput and decodeAnthropic)
read only the text, and anthropicEncoder skipped a thinking delta with
no text, so Claude Code heard nothing but keepalives for the whole think
and never showed "thinking ... with xhigh effort".
The count now rides the Event (Estimated). An empty thinking delta that
carries one opens the thinking block the way a spoken delta does and
goes to the client as it came; one without a count is still skipped
(#1445). A delta with text carries its count too. On a direct request
(last candidate, thinkingShown) the block's content_block_start is
eventThinking, so the stream flows at the first beat; on a group still
holding reasoning for a refusal handover (#248) the beat is held with
the rest, as text thinking is.
Run (mote, -tags nogui):
- TestThinkingProgressTokensReachTheClient, TestBareEmptyThinkingDeltaStaysQuiet,
TestAnthropicDecoderKeepsProgressCount: ok.
- Broken by hand: anthropic.go and claude_subscription.go put back to
origin/main, tests kept: TestThinkingProgressTokensReachTheClient FAIL
("the client never heard the progress beat "estimated_tokens":50"),
TestAnthropicDecoderKeepsProgressCount FAIL; the bare-empty test
passes on both (it pins #1445).
- -run 'Thinking|Anthropic|TestClaudeCutStream|TestStreamOutputCounted|TestTurn': ok.
- go test -timeout 45m ./internal/gateway/: ok 862s. GOOS=linux and
GOOS=windows go vet ./internal/gateway/: clean. gofmt -l: nothing.
Not tried: a real Claude subscription during a long think (the beat's
shape is the reporter's TUI tap), and Claude Code's own display of the
beat.
Reported by dusk2999 (#5390). Patch by ggbdpq; the decoder test is ours.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>