fix(web): keep long streams responsive#1643
Conversation
🦋 Changeset detectedLatest commit: e774b6f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
@codex review |
commit: |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
ab9ad56 to
e774b6f
Compare
Related Issue
No linked issue. This is a focused fix for a reproduced long-stream rendering stall on the current kap-server
/api/v1path.Problem
When animation frames are suspended, high-frequency WebSocket render events accumulated without coalescing or a processing budget. A later lifecycle event synchronously drained the entire backlog, repeatedly cloning message state and producing a main-thread long task. The WebSocket remained healthy, but the transcript could stop visibly advancing until a refresh rebuilt it from the authoritative snapshot.
In an isolated kap-server session, 20,000 raw deltas became 1,544 Web render events; the old control-event drain processed all 1,544 at once, took 48.6 ms, and produced a 52 ms long task while still preserving the final 80,000-character text.
What changed
A stronger 400,000-character isolated burst reduced 782 Web enqueue calls to 13 capped reducer groups, with 1.2 ms total enqueue time, 0.8 ms coalescing time, and a 0.4 ms maximum reducer drain. The final text matched the server SHA-256 exactly. The terminal Markdown commit for that intentionally extreme unbroken block still produced one 61 ms task; the streaming queue itself did not, so this change does not introduce a broader UI state rewrite.
Validation:
pnpm --filter @moonshot-ai/kimi-web test(28 files, 499 tests)pnpm --filter @moonshot-ai/kimi-web typecheckpnpm --filter @moonshot-ai/kimi-web check:style(baseline findings only)pnpm --filter @moonshot-ai/kimi-web buildgit diff --checkNo user guide update is needed because commands, configuration, and interaction semantics are unchanged; the changeset records the user-visible reliability fix.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.