fix(tui): guard streaming part appends with a part index - #48560
Open
rekram1-node wants to merge 1 commit into
Open
fix(tui): guard streaming part appends with a part index#48560rekram1-node wants to merge 1 commit into
rekram1-node wants to merge 1 commit into
Conversation
Every session.text.delta calls appendPart, which ran setRows(produce(...)) plus a hasPart full-tree scan even when the part already existed. On a root-array Solid store the no-op update still unwraps the whole rows tree, so per-delta cost scaled with loaded history (~580ms per 50-delta burst at 4000 messages). Maintain a lazily-rebuilt Set of part keys: rebuilt from the plain reduce() output on each reconcile, extended on append, and checked O(1) before touching the store. Reasoning completion still flows through to flip the group flag. Measured with a headless createTestRenderer probe (mixed markdown + tools, 50 deltas + settle): 578ms -> 34ms at 4000 messages, 133ms -> 34ms at 1000 messages.
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.
Every
session.text.deltacallsappendPart, which ransetRows(produce(...))plus ahasPartfull-tree scan even when the part already existed. On a root-array Solid store the no-op update still unwraps the whole rows tree, so per-delta cost scaled linearly with loaded history.This maintains a
Setof part keys: rebuilt from the plainreduce()output on each reconcile (via a newsyncRowshelper), extended on append, and checked O(1) before touching the store. Reasoning completion still flows through to flip the group flag, and the in-producerhasPartcheck stays as the source of truth.Measured with a headless
createTestRendererprobe (mixed markdown + tools, 50 deltas + settle, 1 frame):Delta cost is now flat in session size.
Verification:
bun typecheckclean, prettier clean,session-home+markdown-streaming+session-wheel-focus+runtimetests pass (24/24).