Skip to content

perf: batch reasoning renderer updates - #387

Merged
SonyLeo merged 2 commits into
opentiny:developfrom
gene9831:codex/reasoning-sse-performance
Aug 18, 2026
Merged

perf: batch reasoning renderer updates#387
SonyLeo merged 2 commits into
opentiny:developfrom
gene9831:codex/reasoning-sse-performance

Conversation

@gene9831

@gene9831 gene9831 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

优化 Reasoning 流式内容渲染,避免大文本场景卡顿

背景

Reasoning 内容持续流式增长时,组件会频繁更新文本并执行自动滚动。原实现每次更新都会触发 nextTicksmooth 滚动,内容较大时容易造成主线程阻塞,导致页面卡顿。

改动内容

  • 使用 requestAnimationFrame 合并高频内容更新
  • 增加本地展示缓冲,减少重复文本渲染
  • 将平滑滚动改为直接设置 scrollTop
  • 组件卸载时取消未执行的动画帧任务
  • 保留原有展开、收起和自动滚动行为

验证

  • 流式超大 reasoning_content 测试通过
  • pnpm -F @opentiny/tiny-robot build 构建通过
  • 修改范围:packages/components/src/bubble/renderers/Reasoning.vue

Summary by CodeRabbit

  • Improvements
    • Reasoning content now appears more smoothly as it updates.
    • Expanded reasoning sections automatically stay scrolled to the latest content.
    • Scrolling behavior is more consistent when opening sections or receiving new reasoning updates.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Reasoning content rendering now uses an animation-frame buffer. Content and open-state changes schedule updates. Expanded details scroll to the bottom after updates. Unmount cleanup cancels pending animation frames.

Changes

Reasoning rendering

Layer / File(s) Summary
Buffered rendering and lifecycle cleanup
packages/components/src/bubble/renderers/Reasoning.vue
The component buffers displayed reasoning content, synchronizes the open state, schedules updates with requestAnimationFrame, scrolls expanded details to the bottom, and cancels pending frames during unmount.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ReasoningVue
  participant requestAnimationFrame
  participant HTMLDetailsElement
  ReasoningVue->>requestAnimationFrame: Schedule buffered content update
  requestAnimationFrame->>ReasoningVue: Run update
  ReasoningVue->>HTMLDetailsElement: Scroll expanded details to bottom
  ReasoningVue->>requestAnimationFrame: Cancel pending frame on unmount
Loading

Poem

I’m a rabbit watching thoughts unfold,
Frame by frame, the words are told.
When details open, I hop below,
To the newest line in a gentle flow.
At unmount, pending hops are cleared.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes batching reasoning renderer updates, which is the main change in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/components/src/bubble/renderers/Reasoning.vue`:
- Around line 39-48: The scheduleDetailUpdate path must not call
requestAnimationFrame during setup or in non-browser environments. Guard the
requestAnimationFrame scheduling with an appropriate browser/runtime check, or
defer the immediate watcher updates until after onMounted, while preserving the
existing displayedReasoningContent update and scroll behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a4d21da2-e019-498a-9722-fc544278ef31

📥 Commits

Reviewing files that changed from the base of the PR and between 2cb6596 and 4c3af36.

📒 Files selected for processing (1)
  • packages/components/src/bubble/renderers/Reasoning.vue

Comment thread packages/components/src/bubble/renderers/Reasoning.vue
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

✅ Preview build completed successfully!

Click the image above to preview.
Preview will be automatically removed when this PR is closed.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@SonyLeo
SonyLeo merged commit 33c31b0 into opentiny:develop Aug 18, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🧹 Preview Cleaned Up

The preview deployment has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants