singularity-forge/packages
Jeremy 03b7142400 fix(tui): reset segment state on claude-code sub-turn shrink
Commit c8c416802 (#4144) introduced module-level renderedSegments state
to track interleaved text/tool components per assistant turn, but never
reset it when an adapter shrinks streamingMessage.content[] back to 0/1
at a provider sub-turn boundary within one assistant lifecycle (the
claude-code adapter does this). Consequence chain: the segment walker
finds the stale text-run entry at startIndex=0, calls updateContent on
it with the new (shrunk) message, and the in-place edit destroys the
prior sub-turn's visible text. New tool blocks at contentIndex=1 then
collide with stale registrations, causing visual ordering corruption.
hasToolsInTurn stays sticky-true and lastPinnedText never clears, so
the pinned "Working - Latest Output" mirror freezes on the pre-shrink
snapshot.

Track lastContentLength explicitly. On shrink, clear renderedSegments,
reset lastPinnedText, and reset lastProcessedContentIndex so the
walker treats the new sub-turn as fresh segments that append after
prior sub-turn children. Prior history stays rendered as frozen
components; pendingTools and the spinner border are untouched.

Adds two regression tests in chat-controller-ordering.test.ts: one
verifies prior sub-turn components are not overwritten and new tools
append in content[] order after a shrink, the other verifies the
pinned markdown updates from the first sub-turn's text to the second
sub-turn's text across a shrink boundary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 19:58:11 -05:00
..
daemon fix(pi-ai): remove Anthropic OAuth flow for TOS compliance 2026-04-10 17:33:34 -05:00
mcp-server fix(gsd): route quality gates through a per-turn registry 2026-04-12 21:13:16 -05:00
native fix: align @gsd/native module type with compiled output (#3253) 2026-03-30 13:51:57 -06:00
pi-agent-core fix claude code mcp elicitation bridge 2026-04-10 19:24:51 -05:00
pi-ai feat(claude-code): pass thinking level as effort 2026-04-13 18:05:19 +02:00
pi-coding-agent fix(tui): reset segment state on claude-code sub-turn shrink 2026-04-13 19:58:11 -05:00
pi-tui fix(pi-tui): filter kitty keypad private-use input (#4026) 2026-04-13 06:51:12 -04:00
rpc-client feat: Headless Integration Hardening & Release (M002) (#2811) 2026-03-26 23:33:22 -06:00