Repository navigation
fix(client): keep the tree index across streaming deltas - #179
Merged
Merged
Conversation
`SessionStore::push_message`, `complete_streamed_turns`, `warm_empty`, `mark_focused`, and `evict_cold_bodies` mutate body state only, but went through `get_mut`, which drops the derived tree index. Every `AssistantMessageStarted` and `TextAppended` therefore rebuilt the sidebar order — exactly the per-frame rebuild `body_mut` exists to avoid. They now use `body_mut`. The test guarding this compared the order `Vec`'s pointer before and after, which passes whenever the allocator hands the rebuilt index the freed block; it failed on CI for main at 536a817 and for #176. The store now counts index rebuilds under `cfg(test)` and the test asserts exactly one, which fails deterministically against the old code (2 vs 1). Closes ENG-927.
4 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linear: ENG-927. Unblocks #176 (and any PR) — the
fmt, clippy, testsjob fails onmainitself since #162 landed.What CI was hitting
state::tests::streaming_deltas_keep_the_tree_indexinqq-client— a pointer-equality assertion:It failed on
mainat 536a817 and on #176 (which changes onlywebsite/and two markdown files). Locally it passes 30/30. It is not a flaky test; it is a flaky detector of a real bug.The bug
SessionStorekeeps a derived tree index (sidebar order, depth, children) in aOnceCell.get_mutdrops it — correct for summary changes — whilebody_mutexists specifically so streaming deltas don't rebuild the sidebar on every frame. But five body-only paths still went throughget_mut:push_message,complete_streamed_turns,warm_empty,mark_focused,evict_cold_bodies. So everyAssistantMessageStartedandTextAppendedthrew the index away — exactly the per-frame rebuild the doc comment onbody_mutsays we avoid.The test compared
thread_order().as_ptr()before and after. The index was being rebuilt; the newVecjust usually landed in the block the old one had freed. On CI's allocator state it didn't.The fix
body_mut.cfg(test), the store counts index rebuilds; the test asserts exactly one after the streaming events. Against the old code this fails deterministically (2 vs 1), verified by reverting the fix hunk with the new assertion in place.Verification
cargo test -p qq-client --lib22/22-D warningswall_clock_budget_settles_a_hanging_provider…, a wall-clock test), which passes alone; not touched here.Impact
Fewer sidebar rebuilds per frame during streaming — the intended behavior of
body_mut, now actually in effect for messages.