Skip to content

fix(tui): guard streaming part appends with a part index - #48560

Open
rekram1-node wants to merge 1 commit into
v2from
part-index-guard
Open

fix(tui): guard streaming part appends with a part index#48560
rekram1-node wants to merge 1 commit into
v2from
part-index-guard

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

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 linearly with loaded history.

This maintains a Set of part keys: rebuilt from the plain reduce() output on each reconcile (via a new syncRows helper), extended on append, and checked O(1) before touching the store. Reasoning completion still flows through to flip the group flag, and the in-producer hasPart check stays as the source of truth.

Measured with a headless createTestRenderer probe (mixed markdown + tools, 50 deltas + settle, 1 frame):

loaded msgs before after
4000 578ms 34ms
1000 133ms 34ms

Delta cost is now flat in session size.

Verification: bun typecheck clean, prettier clean, session-home + markdown-streaming + session-wheel-focus + runtime tests pass (24/24).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant