mirror of
https://github.com/NeuralNomadsAI/CodeNomad.git
synced 2026-07-10 00:14:27 +00:00
## Problem Streaming responses send many `message.part.delta` events per second. Each event triggers a Solid store mutation + re-render, causing: 1. **Mobile freezes** — KaTeX/highlight.js re-renders on every delta block the main thread 2. **Text duplication** — When `message.part.updated` replaces a part with the server's complete state, previously enqueued deltas would flush AFTER the replacement, concatenating stale text onto the fresh part ## Solution ### 1. Delta throttling (50ms buffer) Accumulate deltas in a buffer and flush every 50ms instead of updating on every event. This batches Solid mutations and cuts main-thread blocking during streaming. ### 2. Stale delta cleanup When a full `message.part.updated` arrives, clear any pending deltas for that part before applying the update. The update already contains the complete server state, so accumulated deltas are stale. ## Changes - `packages/ui/src/stores/session-events.ts`: Added `enqueueDelta`, `flushDeltas`, `clearPendingDeltasForPart`; updated `handleMessagePartDelta` and `handleMessageUpdate` ## Verification - Build passes: `npm run build:ui` - Tested on mobile — eliminates visible freezes during long streaming responses - No duplicate text observed at end of assistant messages after part updates --------- |
||
|---|---|---|
| .. | ||
| cloudflare | ||
| electron-app | ||
| opencode-plugin | ||
| server | ||
| tauri-app | ||
| ui | ||