You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Long chat replies stream with less stutter: parse each block once - #34821
Status: final-head measurements. The rendering difference found in review is fixed and fresh correctness review passed. These values compare the final head with its merged-main baseline in four alternating run orders, with the native chat parser extensions installed. All seven workloads passed 3,430 exact-HTML comparisons; these are synchronous renderer measurements, not packaged frame-rate claims.
Workload (median / p95 per streaming update)
Before
After
Change (median)
Short reply (800 characters)
0.79 / 1.49 ms
0.55 / 0.93 ms
1.4× faster
Growing paragraph (50k)
51.76 / 84.91 ms
32.16 / 60.01 ms
1.6× faster
Growing code fence (56k)
15.45 / 20.84 ms
8.30 / 10.37 ms
1.9× faster
Growing list (48k)
86.44 / 134.51 ms
60.17 / 105.92 ms
1.4× faster
Completed fence + short streaming tail
12.56 / 18.21 ms
0.73 / 1.60 ms
17× faster
Code fence with inert visual marker
18.25 / 23.15 ms
17.05 / 22.37 ms
1.1× faster
Completed fence → visual fallback
0.76 / 10.50 ms
0.60 / 9.89 ms
1.3× faster
Common pattern?
Yes, with implementation differences. One common approach keeps a pristine parsed prefix through a safely closed code fence, parses what follows, and clones the prefix into a whole-document tree; this PR shares the reuse principle but keeps independently rendered blocks. Another common approach parses pieces to render them and reuses unchanged safe pieces, including completed fences; this PR instead retains raw trees and uses parser-derived boundaries. Both common approaches avoid reparsing settled content. This PR also reuses its block-discovery tree for rendering while preserving Orca's existing transform scope.
Long chat replies with large paragraphs, lists, or code blocks can stream slowly and make the app stutter because Orca parses the same text to find block boundaries and then parses it again to render it.
Reuse the first syntax tree for rendering, retain unchanged settled blocks, and stop rediscovering completed code fences while the following text streams. Rendering, copy text, word fade, code-block source lines, and reveal timing stay the same.
Workload
Before median / p95 (ms)
After median / p95 (ms)
Short reply (800 characters)
0.79 / 1.49
0.55 / 0.93
Growing paragraph (50k)
51.76 / 84.91
32.16 / 60.01
Growing code fence (56k)
15.45 / 20.84
8.30 / 10.37
Growing list (48k)
86.44 / 134.51
60.17 / 105.92
Completed fence + short tail
12.56 / 18.21
0.73 / 1.60
Measured with the production-pipeline harness on the same Mac, using the existing reveal cadence. Values are synchronous render-update latency, including discovery, transforms, React rendering, and DOM commit.
Plan: Remove duplicate parsing by adopting the common pattern: one configured parser supplies both block boundaries and the tree used by the existing rendering pipeline. Each render gets a pristine clone in block-local source coordinates, and parser configuration changes invalidate trees while preserving current cuts. HTML and definitions retain whole-document rendering. Repaired source, byte-order marks, and sliced indented openers intentionally retain their existing standalone parse because their parser inputs differ; this preserves exact output and source positions.
Validation: 308 tests passed across 20 named markdown/native-chat files. A differential test compares exact HTML, copy text, and code source-line attributes after every production reveal prefix, including all five workloads, lists/setext boundaries, HTML/definitions, math/repair, sanitized HTML, file links, word fade, indentation, and line endings. An actual-parser counter asserts one parse for discovery/render and tail-only parsing after a completed fence; the previous path parses more characters. All five original benchmark workloads passed. No reserved link-routing or math-cache files changed.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Walkthrough
The Markdown block splitter now accepts a parser callback and retains reusable block-local parse trees. CommentMarkdown builds the parser from active remark plugins and passes available trees to MemoizedMarkdown. Native-chat visual extensions provide extra flow-syntax markers. New tests compare incremental rendering with a legacy splitter and measure parsing and tree work across updates.
Priority: Normal
Merge Risk: Minimal · up to a0e0a
No identified issue blocks merging after normal checks.
Pre-merge checks: 3 · 2
Failed checks: 2 warnings
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check
The description provides detailed change rationale, performance data, implementation scope, and validation results, but it does not follow the required template. It omits the ELI5, What Changed, Why, …
Rewrite the description using the repository template. Add the required headings, link the actual issue in “Fixes #”, provide before/after visual proof or state N/A with a reason, document manual and automated testing with platforms, comple…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title clearly states the primary change: reducing streaming stutter by parsing each Markdown block once.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 16 functions across 10 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Full details: Description check
Explanation
The description provides detailed change rationale, performance data, implementation scope, and validation results, but it does not follow the required template. It omits the ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Review, Notes, and Checklist sections. No issue link or visual proof/N/A statement is provided.
Resolution
Rewrite the description using the repository template. Add the required headings, link the actual issue in “Fixes #”, provide before/after visual proof or state N/A with a reason, document manual and automated testing with platforms, complete the applicable checklist items, and add AI disclosure if applicable.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
The fixture contains no file-link candidate. The policy change therefore does not affect rendering. Add a supported candidate such as src/a.ts, then assert that the accepted link disappears when the callback rejects it.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Long streaming replies could stutter because Markdown was parsed once to find block boundaries and again to render, and completed fences were rediscovered as following text arrived. This change reuses the pristine boundary parse for rendering and retains completed fences while the tail streams. Rendering, copy text, source lines, word fade and reveal behavior are preserved.
Full review complete on a0e0ac30c0cec288faba03f8c042212120287fb7, including the once-only main merge. Review found and repaired a visual-directive boundary regression: unsafe parser inputs now use the complete existing discovery step, while compatible unchanged blocks retain their identity. A three-seat architecture ruling and fresh correctness verification covered that repair. Independent final review found low merge risk and no negative user-facing trade-off. No open findings or deferrals.
Verified on this head:
308 tests across 20 named files, including production-parser operation bounds at N and 10N, exact output, fallback transitions, iframe/fade identity, source positions and main’s file-link transform.
Seven real-scale benchmark workloads in four alternating baseline/branch orders; 3,430 exact-HTML comparisons passed. Every aggregate median and p95 improved. Completed fence plus streaming tail: median 12.56 → 0.73 ms, p95 18.21 → 1.60 ms. The PR body has the complete measurements.
CI passed, including static analysis/typecheck, all five test shards and macOS/Windows packaging. Whole-mechanism reference comparison, performance pass and readiness checklist passed. The outdated braces thread is addressed and resolved.
Performance is the tests row of the QA table: no app QA or screenshot is required because this change preserves appearance and changes no lifecycle flow. Timings measure synchronous renderer work and DOM commit in happy-dom; packaged frame rate, layout/paint, retained heap and other machines’ performance were not measured.
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
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.
Performance and the common pattern
Status: final-head measurements. The rendering difference found in review is fixed and fresh correctness review passed. These values compare the final head with its merged-main baseline in four alternating run orders, with the native chat parser extensions installed. All seven workloads passed 3,430 exact-HTML comparisons; these are synchronous renderer measurements, not packaged frame-rate claims.
Long chat replies with large paragraphs, lists, or code blocks can stream slowly and make the app stutter because Orca parses the same text to find block boundaries and then parses it again to render it.
Reuse the first syntax tree for rendering, retain unchanged settled blocks, and stop rediscovering completed code fences while the following text streams. Rendering, copy text, word fade, code-block source lines, and reveal timing stay the same.
Measured with the production-pipeline harness on the same Mac, using the existing reveal cadence. Values are synchronous render-update latency, including discovery, transforms, React rendering, and DOM commit.
Plan: Remove duplicate parsing by adopting the common pattern: one configured parser supplies both block boundaries and the tree used by the existing rendering pipeline. Each render gets a pristine clone in block-local source coordinates, and parser configuration changes invalidate trees while preserving current cuts. HTML and definitions retain whole-document rendering. Repaired source, byte-order marks, and sliced indented openers intentionally retain their existing standalone parse because their parser inputs differ; this preserves exact output and source positions.
Validation: 308 tests passed across 20 named markdown/native-chat files. A differential test compares exact HTML, copy text, and code source-line attributes after every production reveal prefix, including all five workloads, lists/setext boundaries, HTML/definitions, math/repair, sanitized HTML, file links, word fade, indentation, and line endings. An actual-parser counter asserts one parse for discovery/render and tail-only parsing after a completed fence; the previous path parses more characters. All five original benchmark workloads passed. No reserved link-routing or math-cache files changed.