Conversation
🦋 Changeset detectedLatest commit: a6b0a1e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6b0a1ee0b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Coalesce high-frequency render events onto the next animation frame; | ||
| // everything else is applied immediately. See createEventBatcher / | ||
| // processEvent above. | ||
| enqueueEvent({ appEvent, meta }); |
There was a problem hiding this comment.
Keep the WS cursor current before batching deltas
Because processEvent is also what advances rawState.lastSeqBySession, routing assistant/tool/task deltas through the rAF batcher leaves the app-level cursor stale until the next frame. If the user switches away and back to a still-streaming session before the queued deltas flush, subscribeToSessionEvents sends the old seq, and the server replays those same already-queued deltas; when both the original queue and the replay drain, text/tool output is appended twice. Flush before re-subscribing or advance the per-session cursor synchronously when enqueueing a durable event.
Useful? React with 👍 / 👎.
|
Superseded by #1085 (renamed branch to remove non-ASCII characters). |
Related Issue
No linked issue — investigated from a user report of stuttery streaming in LAN mode.
Problem
When using the server-hosted web UI (especially over LAN), the assistant stream looks stuttery: tokens appear word-by-word, and it gets worse as a session grows longer. Two independent causes were identified:
messagesToTurnsrebuild + full Markdown re-parse + scroll reflow). When the model streams fast, hundreds of redundant renders per second saturate the main thread, so the stream looks slow.What changed
apps/kimi-web): coalesce high-frequency streaming events (assistantDelta,agentDelta,toolOutput,taskProgress) onto the next animation frame so Vue commits at most one render per frame. Lifecycle / control-flow events still apply immediately (so turn-end cleanup is never delayed, even in a background tab), and any pending deltas are flushed before a session snapshot is applied to avoid duplication on resync. AddedeventBatcher.ts(pure, tested) and wired it into the WS event pipeline.packages/server): callsocket.setNoDelay(true)on the upgraded WebSocket socket so small delta frames are sent immediately instead of being held by Nagle's algorithm.The logging needed to confirm the arrival cadence already exists: enabling the opt-in debug trace (
?debug=1orlocalStorage["kimi-web.debug"]="1") records every inbound frame's arrival timestamp into a bounded ring buffer, so no new logging was added.Checklist
apps/kimi-web/test/event-batcher.test.ts)gen-changesetsskill, or this PR needs no changeset. (added two changesets)gen-docsskill, or this PR needs no doc update. (no user-facing doc change)