Conversation
- Adjust snapToWordBoundary loop to check budget-bounded indices only - Add logic to distinguish: whitespace within budget, beyond budget, or nowhere - Return 0 when whitespace exists beyond budget to wait for larger budget - Return maxLen only when no whitespace exists anywhere (guarantee progress) - Add drainFor check to break when snapToWordBoundary returns 0
When snapToWordBoundary returns 0 (word boundary exists beyond budget), the previous tick's elapsed time was discarded, creating a fixed-point where budget never grew and long unbroken tokens stalled indefinitely. Now accumulate elapsed time across ticks where no progress is made, so the budget grows monotonically until reaching the word boundary or running out of whitespace entirely. Fixes stalls on long URLs, code tokens, and unbroken CJK runs.
Removes vitest import and vi.isFakeTimers() detection from production code. Implements plain buffering of all chunks through StreamSmoother as specified in the brief, with no environment-conditional logic.
Updated the 'streaming dot appears during streaming and disappears after chunk_end' test to use fake timers and advance past one pacing tick before the first assertion. This accounts for the ~50ms delay introduced by StreamSmoother pacing, which prevents the dot from rendering until the smoother's timer fires and emits the buffered content.
npm test doesn't run tsc/eslint, so noUncheckedIndexedAccess violations and formatting issues in Task 1's files went unnoticed until `make update-dist` ran the real build/lint pipeline.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Streamed responses in
ChatandMarkdownStreamtoday render exactly as fast as chunks arrive over the wire — neither chatlas nor ellmer pace their generators, so the visual rhythm of a response is entirely at the mercy of the model provider's SSE chunking behavior. Some providers trickle steadily, others burst large chunks irregularly, which makes streaming feel inconsistent from provider to provider.This adds a client-side-only pacing layer (
StreamSmoother) that smooths that out: text now drains onto the screen at a steady, readable pace regardless of how bursty the underlying chunks are, while still never introducing a perceptible delay for short, single-shot responses. No changes to Python, R, chatlas, or ellmer — the wire protocol is untouched, and pacing parameters are fixed sane defaults (not app-configurable) for this first iteration.What reviewers should look at
js/src/streaming/StreamSmoother.ts— the framework-agnostic pacing class (buffer + adaptive drain loop, word-boundary-safe cuts, flush/dispose semantics, congestion backoff).ChatandMarkdownStreamhave separate message-handling paths:js/src/chat/ChatApp.tsxandjs/src/markdown-stream/markdown-stream-entry.ts.Test plan
tsc -noEmitandeslintclean.make update-dist) and committed for bothpkg-pyandpkg-r.