Repository navigation
perf(client): stop idle Bot mode from re-rendering long timelines every frame - #2428
Merged
Merged
Conversation
…ry frame Three changes from 1.4.0 made an idle Bot-mode conversation cost grow with its history (#2413): - The hover toolbar every bubble keeps hidden was placed with a transform, so each repaint (the window companion repaints every frame) rebuilt compositing for every message. It is now placed with bottom instead. - BotPanel subscribed to the whole onboarding state, so the onboarding poll re-rendered the full conversation every five seconds. It now subscribes to the one boolean it reads. - Each message built new Intl date formatters on every render, and kept its own ResizeObserver. Formatters are now reused and the fold check shares one observer. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013edVLcdSJ7xqZLPLFFYCRT
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013edVLcdSJ7xqZLPLFFYCRT
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013edVLcdSJ7xqZLPLFFYCRT
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013edVLcdSJ7xqZLPLFFYCRT
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
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. Comment |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013edVLcdSJ7xqZLPLFFYCRT
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.
Requested by Vain · project thread
Why the change
Since 1.4.0, Bot mode keeps the main thread busy while idle on a long conversation, so the app feels laggy. 1.3.1 did not have this. 自 1.4.0 起,长对话在空闲时持续占用主线程,使用体验变卡;1.3.1 没有这个问题。
Refs #2413
The walking Tob companion (default-on since 1.4.0) repaints every frame. Three 1.4.0 changes made each repaint or re-render much more expensive on an un-virtualized timeline:
opacity: 0toolbar placed with atransform. Chromium then rebuilds compositing for every bubble on each repaint (Layerize 29–35 ms/frame → 1.9 ms/frame). The toolbar is now placed withbottom; geometry is unchanged (toolbar bottom stays 8 px below the bubble top, verified).BotPanelsubscribed to the whole onboarding state, so the 5 s onboarding poll re-rendered the whole conversation. It now subscribes to the derivedreleaseDeferredboolean.fullTimebuilt a newIntl.DateTimeFormatfor every message on every render (≈325 ms per 15 s), andMessageFoldcreated oneResizeObserverper message. Formatters are now cached and one shared observer serves the timeline.Special things to note
Idle measurement, isolated DSH Host, 400-message group, 1440×900 headless Chromium, 15 s,
BOTHARNESS_CLIENT_DIAGNOSTICS=0, CDPTaskDuration:1.4.0 measured the same as 1.4.1 (~111% with companion on).
Remaining gap with the companion on (not in this PR): per-message fold
ResizeObservertargets (~0.75 ms/frame), larger DOM per bubble (89k vs 81k nodes), and Tob being default-on. Follow-ups worth considering: virtualize the timeline or usecontent-visibility, observe fold sizes only while content can change, and pause the companion walk while idle.pnpm --filter @botharness/client test: passes except the two pre-existingnode:sqlitebundling failures that also fail on main. Updatedstyles-tokenstest asserts the toolbar has notransform.pnpm changelog:checkpasses.Hover toolbar checked visually in light and dark (below). Not run: native mobile (no mobile change).
Change outline
Hover toolbar position is unchanged / 悬浮工具栏位置不变:
packages/client/src/client/styles.ts:.bh-bubble-toolbarusesbottom: calc(100% - x3)instead oftop: 0+transform.packages/client/src/client/bot-main.tsx: cachedIntl.DateTimeFormat;BotPanelsubscribes toreleaseDeferred(state).packages/client/src/client/message-fold.tsx: one sharedResizeObserver.changes/2428-idle-timeline.md: bilingual Fixed entry.🤖 Generated with Claude Code
https://claude.ai/code/session_013edVLcdSJ7xqZLPLFFYCRT