Skip to content

perf(app): isolate answer streaming from the global store - #2

Merged
goodylili merged 1 commit into
mainfrom
perf/store-subscriptions
Jun 23, 2026
Merged

perf(app): isolate answer streaming from the global store#2
goodylili merged 1 commit into
mainfrom
perf/store-subscriptions

Conversation

@goodylili

Copy link
Copy Markdown
Owner

The top-level app component subscribes to the entire store, so the answer typewriter (which wrote each tick into the main store) re-rendered the whole ~8500-line tree up to 24 times per reply, plus on every keystroke elsewhere. Park the in-flight partial text in a dedicated stream store read only by a tiny node; the chat message still holds the empty placeholder while streaming and the final text is committed back to the store ONCE at the end. Net: the app tree re-renders twice per answer (push + commit) instead of ~24 times.

Behavior is unchanged: same typewriter cadence (24 ticks / 55ms), same final Markdown render, all text paths (server, BYOK, error fallback) and the media path are untouched.

The top-level app component subscribes to the entire store, so the answer
typewriter (which wrote each tick into the main store) re-rendered the whole
~8500-line tree up to 24 times per reply, plus on every keystroke elsewhere. Park
the in-flight partial text in a dedicated stream store read only by a tiny
<StreamingAnswer /> node; the chat message still holds the empty placeholder while
streaming and the final text is committed back to the store ONCE at the end. Net:
the app tree re-renders twice per answer (push + commit) instead of ~24 times.

Behavior is unchanged: same typewriter cadence (24 ticks / 55ms), same final
Markdown render, all text paths (server, BYOK, error fallback) and the media path
are untouched.
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cortex-frontend Building Building Preview, Comment Jun 23, 2026 1:14pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
cortex-docs Skipped Skipped Jun 23, 2026 1:14pm

@goodylili
goodylili merged commit 6b3a4bc into main Jun 23, 2026
3 of 4 checks passed
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