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
perf(native-chat): window a bot chat's long runs of item notes - #45737
When a bot posts many short status notes in a row, the chat drew all of them at once, even the ones far off screen. Now it draws them in small groups, so only the groups near what you're looking at are on the page.
Files
Added
Deleted
Net
Test
3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$273
$\color{#cf222e}{\Huge{\mathbf{−}}}$2
$\color{#1a7f37}{\Huge{\mathbf{+}}}$271
Prod
8
$\color{#1a7f37}{\Huge{\mathbf{+}}}$271
$\color{#cf222e}{\Huge{\mathbf{−}}}$50
$\color{#1a7f37}{\Huge{\mathbf{+}}}$221
What Changed
Before: consecutive quiet item notes in a bot chat joined one transcript row with no size limit. A busy bot's hidden quiet turns join its notes across turns, so a long run became one huge virtual row: 400 notes mounted together (about 10k DOM nodes, each line with its own ResizeObserver), whatever was on screen.
After: a run splits into rows of at most 8 notes (MAX_NATIVE_CHAT_ITEM_NOTE_CLUSTER), counted from the run's first note, so a new live note only changes the last row. The virtualizer mounts only the rows near the view.
Spacing: notes still look the same, 4 px apart. A row that continues a run is created with followsNotes and pulls itself up into the row gap (-mt-4), and its height estimate subtracts that amount. A row never changes shape after it is drawn, so measurements the virtualizer keeps stay valid. The full gap stays where an approval card or the "New" marker sits between two rows, and on rows that fade out whole.
Jumps: a jump to a continuing row lands on its first note, not 16 px below it (nativeChatRowDrawnAbove). It still targets the row's index, with the virtualizer's start padding set to what the row draws above its top, so the landing is re-resolved as rows above it get measured.
Rows outside the window (a group turn, rows after the live turn) join a run's rows by the same rule (nativeChatSlotJoinsNotesAbove).
Housekeeping: the retired-measurement compaction effect moves unchanged into use-native-chat-retired-measurements.ts, so the window hook stays within the file-size limit.
Why
The unbounded row made the bot-chats view mount and measure a whole run at once. That is the cost behind a React #185 crash report from the bot-chats sidebar. The render-loop driver itself was fixed separately in #44647. Fixed-size blocks keep the change inside the existing slot model: no new virtualization layer, and no row is reshaped after it has been measured. We considered having the previous row shrink itself when a ninth note arrives, but that changes a row that has already been measured, so each row now sets its own top margin when it is created.
Checked against how comparable products handle this.
Linked Issue
No public issue; this comes from an internal crash report.
Visual Proof
N/A. Nothing is meant to look different: notes stay 4 px apart, and the change is only in which rows are mounted. The Chromium fixture spec measures the spacing.
Testing
pnpm check:changed: all 34 checks pass (format, oxlint, typecheck node + web, unit tests, ratchets, localization, import boundaries).
native-chat-bot-item-note-clusters.test.ts: splitting at 8, live-note stability (earlier rows don't change), followsNotes and the height estimate, and the join rules (approval card, "New" marker, rows that fade out whole).
tests/component-fixtures/native-chat-note-run.spec.ts (Chromium): an 18-note run rendered through the group-turn / post-live-turn stack measures 4 px between every pair of notes, including across row boundaries. With an approval card between two rows, the full 20 px row gap is kept. Run it with ORCA_BACKGROUND_LAUNCH=1 pnpm exec playwright test --config tests/component-fixtures/playwright.config.ts native-chat-note-run.
use-native-chat-viewport-align.test.ts: a jump lands on a continuing row's first note; other rows land by their own top. With a real virtualizer, the landing follows the row when a row above it is measured before the jump settles.
The added unit and Chromium tests fail when run against main (or with the pull-up removed).
I manually tested these changes locally (covered by the component tests above; a live link-click jump wasn't exercised by hand)
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
Mount cost: bounded. A note run used to mount O(n) notes, with a ResizeObserver per line, as soon as any part of it was in view. Now it mounts at most 8 notes per row in the overscan range, so a 400-note run drops from about 10k DOM nodes to a few hundred.
Clustering pass: still a single O(n) pass over the slots, with one extra comparison per note.
Join check:nativeChatSlotJoinsNotesAbove runs per rendered row. It looks at the previous slot and its notes' timed rows, which is at most 8 map lookups.
Jumps:nativeChatRowDrawnAbove adds two getBoundingClientRect reads, only on a jump to a row's start. When a jump's padding differs from the last one, one state update re-renders the window.
Reflow: live notes only change the last row, so streaming doesn't invalidate earlier measurements.
No new timers, subscriptions or IPC.
Risk
Level: Low. Renderer-only and limited to bot-chat item-note rows. The riskiest part is the spacing at the boundary between two rows of a run: if the pull-up didn't apply, users would see a slightly larger gap (20 px instead of 4 px) every 8 notes. A jump to a continuing row is the other edge case. A plain revert backs it out; no saved data or settings are involved.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Renderer layout only: no platform, SSH, mobile or persisted-state impact.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Consecutive quiet item notes joined one transcript slot with no bound, and
a busy bot's hidden quiet turns join its notes across turns, so the window
mounted the whole run at once (400 notes: about 10k DOM nodes, each line
with its own ResizeObserver). Split a run into slots of 8 notes; a slot the
next one continues draws 1rem shorter, keeping the notes 4 px apart.
A slot that carries on a run of notes now closes the row gap with its own
top margin, set when it is made, instead of the slot before shortening
itself once a ninth note arrives. A slot never changes shape after it is
drawn, so a measurement the window keeps for it stays true. The gap stays
whole where an approval card or the New marker sits between two slots, or
while the row fades out whole.
…join slots outside the window
A slot that carries on a run of notes draws 16 px above its own top, so a
jump to it now lands by what it draws rather than by its top. Rows drawn
outside the window (a group turn, rows after the live turn) join a run's
slots by the same rule as the window.
…mium
The spacing between two slots of a long note run is layout, which
happy-dom does not compute, so the class-name checks move to a component
fixture spec that measures each note's distance from the next: 4 px
across slot boundaries, and a full row gap below an approval card.
No actionable comments were generated in the recent review.
Walkthrough
Note runs are split into slots of up to eight notes. Continued slots carry a flag and can join the preceding row when the specified conditions permit. Transcript rendering applies the corresponding row spacing, and start-edge alignment accounts for content drawn above a row. Retired measurement cleanup is handled by a dedicated hook. Tests and fixtures cover clustering, row joining, alignment, and note spacing around an approval card.
Merge Risk: Minimal · up to e5f08
This change splits long runs of chat notes into bounded rows so the transcript mounts far fewer DOM nodes, and it keeps jump-to-row alignment correct for rows pulled up under the preceding notes. The earlier jump-alignment concern is addressed with an index-based target and a test. No actionable merge-blocking risk remains in the reviewed evidence.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "perf(native-chat): window a bot chat's long runs of item notes" matches the main change. The PR splits long runs of consecutive quiet notes into bounded rows of at most 8, so only nearby ro…
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.
Description check
The description follows the template closely: it has ELI5, What Changed, Why, Visual Proof (N/A with reason), Testing with checkboxes, Risk with level, and Checklist. It also includes a Performance se…
Full details: Title check
Explanation
The title "perf(native-chat): window a bot chat's long runs of item notes" matches the main change. The PR splits long runs of consecutive quiet notes into bounded rows of at most 8, so only nearby rows mount. The title is specific, concise, and follows a conventional commit style.
Full details: Description check
Explanation
The description follows the template closely: it has ELI5, What Changed, Why, Visual Proof (N/A with reason), Testing with checkboxes, Risk with level, and Checklist. It also includes a Performance section and an Agent skill boundary checkbox. Gaps: the Linked Issue section says there is no public issue and does not link one, though the template requires a link for outside contributors. The Risk section does not clearly state how to back out beyond a plain revert, and the AI Disclosure section is left blank. The Testing section also says a live link-click jump was not exercised by hand, which is a partial gap. The description is detailed and mostly complete, so it passes overall, but the linked issue gap should be noted.
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; 4 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
A jump to a slot that carries on a run of notes scrolled to a fixed
offset, so rows above it measured before the jump settled moved the
slot away from where it landed. It now targets the row's index like
every other jump, with the virtualizer's start padding set to what the
row draws above its top, so the virtualizer re-resolves the landing as
measurements arrive.
Moves the retired-measurement compaction into its own hook to keep the
window hook within the file-size limit.
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.
ELI5
When a bot posts many short status notes in a row, the chat drew all of them at once, even the ones far off screen. Now it draws them in small groups, so only the groups near what you're looking at are on the page.
What Changed
MAX_NATIVE_CHAT_ITEM_NOTE_CLUSTER), counted from the run's first note, so a new live note only changes the last row. The virtualizer mounts only the rows near the view.followsNotesand pulls itself up into the row gap (-mt-4), and its height estimate subtracts that amount. A row never changes shape after it is drawn, so measurements the virtualizer keeps stay valid. The full gap stays where an approval card or the "New" marker sits between two rows, and on rows that fade out whole.nativeChatRowDrawnAbove). It still targets the row's index, with the virtualizer's start padding set to what the row draws above its top, so the landing is re-resolved as rows above it get measured.nativeChatSlotJoinsNotesAbove).use-native-chat-retired-measurements.ts, so the window hook stays within the file-size limit.Why
The unbounded row made the bot-chats view mount and measure a whole run at once. That is the cost behind a React #185 crash report from the bot-chats sidebar. The render-loop driver itself was fixed separately in #44647. Fixed-size blocks keep the change inside the existing slot model: no new virtualization layer, and no row is reshaped after it has been measured. We considered having the previous row shrink itself when a ninth note arrives, but that changes a row that has already been measured, so each row now sets its own top margin when it is created.
Checked against how comparable products handle this.
Linked Issue
No public issue; this comes from an internal crash report.
Visual Proof
N/A. Nothing is meant to look different: notes stay 4 px apart, and the change is only in which rows are mounted. The Chromium fixture spec measures the spacing.
Testing
pnpm check:changed: all 34 checks pass (format, oxlint, typecheck node + web, unit tests, ratchets, localization, import boundaries).native-chat-bot-item-note-clusters.test.ts: splitting at 8, live-note stability (earlier rows don't change),followsNotesand the height estimate, and the join rules (approval card, "New" marker, rows that fade out whole).tests/component-fixtures/native-chat-note-run.spec.ts(Chromium): an 18-note run rendered through the group-turn / post-live-turn stack measures 4 px between every pair of notes, including across row boundaries. With an approval card between two rows, the full 20 px row gap is kept. Run it withORCA_BACKGROUND_LAUNCH=1 pnpm exec playwright test --config tests/component-fixtures/playwright.config.ts native-chat-note-run.use-native-chat-viewport-align.test.ts: a jump lands on a continuing row's first note; other rows land by their own top. With a real virtualizer, the landing follows the row when a row above it is measured before the jump settles.The added unit and Chromium tests fail when run against
main(or with the pull-up removed).I manually tested these changes locally (covered by the component tests above; a live link-click jump wasn't exercised by hand)
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
nativeChatSlotJoinsNotesAboveruns per rendered row. It looks at the previous slot and its notes' timed rows, which is at most 8 map lookups.nativeChatRowDrawnAboveadds twogetBoundingClientRectreads, only on a jump to a row's start. When a jump's padding differs from the last one, one state update re-renders the window.Risk
Level: Low. Renderer-only and limited to bot-chat item-note rows. The riskiest part is the spacing at the boundary between two rows of a run: if the pull-up didn't apply, users would see a slightly larger gap (20 px instead of 4 px) every 8 notes. A jump to a continuing row is the other edge case. A plain revert backs it out; no saved data or settings are involved.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Renderer layout only: no platform, SSH, mobile or persisted-state impact.
Checklist