Repository navigation
chat: compute tool-confirmation carousel max-height during layout - #327933
Bryan Chen (bryanchen-d) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Moves carousel height allocation out of the primary container ResizeObserver to reduce loop warnings.
Changes:
- Performs carousel allocation during input layout.
- Adds a component-fixture regression probe.
- Adds Playwright coverage for warnings and settling behavior.
Show a summary per file
| File | Description |
|---|---|
chatInputPart.ts |
Relocates carousel height allocation. |
chatWidget.fixture.ts |
Adds the carousel budget probe. |
chatResizeObserver.spec.ts |
Tests the probe across height budgets. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 4
- Review effort level: Medium
| // warning (see #316509). It is computed in `_layout()` instead, from | ||
| // the same measurement pass that sizes the editor. | ||
| const inputResizeObserver = this._register(new dom.DisposableResizeObserver('ChatInputPart.containerHeight', () => { | ||
| updateCarouselMaxHeightScheduler.schedule(); | ||
| const newHeight = this.container.offsetHeight; | ||
| this.height.set(newHeight, undefined); |
| // Allocate the carousel from this same pass, once the editor has been | ||
| // sized. Doing it here rather than from the container's ResizeObserver | ||
| // keeps the write outside resize delivery, so it cannot force another | ||
| // notification pass (see #316509). | ||
| this.updateToolConfirmationCarouselMaxHeight(); |
| expect(Number(warningText?.replace('Warnings: ', ''))).toBe(0); | ||
| // A one-shot allocation reaches its final value immediately, rather than | ||
| // converging over successive frames. | ||
| expect(settled).toBe('true'); |
| /** | ||
| * Reproduces the `ChatInputPart.containerHeight` feedback edge. | ||
| * | ||
| * The input editor and the tool-confirmation carousel share one `_maxHeight` | ||
| * budget, and each derives its own allowance by measuring the container and | ||
| * subtracting itself — that is, by measuring "everything else", which includes | ||
| * the other one. Under a tight budget where both want more than their share, | ||
| * each hands back exactly the space the other just released, so the pair never | ||
| * settles. | ||
| * | ||
| * The probe squeezes the budget, then samples the carousel's resolved | ||
| * `max-height` and the editor's rendered height once per frame. If allocation | ||
| * converges, the tail of that sample series is constant. | ||
| */ |
|
Base:
|
`updateToolConfirmationCarouselMaxHeight()` measures `this.container` and then writes `max-height` onto the carousel, a descendant of that container. Calling it from the container's own ResizeObserver resizes the observed subtree during delivery, which forces another notification pass - the "ResizeObserver loop completed with undelivered notifications" warning tracked in #316509. 4b0aa24 already addressed that by deferring the write to an animation frame, and it works: in the probe added here, restoring the synchronous write produces warnings and the deferral produces none. This change is therefore not a behavioural bug fix and is not expected to change error rates. What it changes is ownership. The carousel allocation is a layout decision that depends on a measurement `_layout()` already takes, so computing it there removes the need for the ResizeObserver callback to schedule layout work at all: the scheduler goes away, the carousel no longer trails the input by a frame, and the callback is reduced to publishing `this.height`. Both consumers of `_maxHeight` are then resolved from one measurement pass rather than two mechanisms. The `ChatInputPart.containerHeight` bucket cannot validate either approach. `DisposableResizeObserver` records attribution as `_lastInvokedDisposableResizeObserver = this`, i.e. whichever observer ran last in the observation phase rather than the one that caused the loop, so the bucket aggregates every loop where this observer happened to run last. Verification: - New `ResizeObserverLoopCarouselBudget` probe sweeps budgets 560..280 and asserts zero warnings plus immediate settling. It guards against a vacuous pass by first requiring the carousel element to exist; an earlier revision silently tested nothing because the fixture starved the list to 0px. - The probe discriminates: performing the allocation only from the observer makes it fail. - The allocation series is byte-identical before and after (560:232|250, 500:232|190, 440:232|130, 380:232|70, 320:178|64, 280:138|64), so this changes when the value is computed, not what it is. - 5/5 playwright resize-observer tests pass; 5154 chat unit tests pass. Co-authored-by: Copilot <[email protected]> Copilot-Session: aacd276e-cf84-48bd-a2ab-6f6a4d4c3431
c35993f to
af9680b
Compare
|
Follow-up on the telemetry interpretation in this PR: The existing Consequently, the
I opened #328065 separately to correct the bucket mechanism. It replaces the misleading last-callback prefix with a bounded, deterministic, per-window set explicitly labeled I am keeping that telemetry correction separate so this PR does not mix a global bucket-shape change into the chat layout refactor. |
|
Closing after reconsidering the existing deferral and the CCR findings. The current Moving the calculation solely into
So the existing deferral is the safer and more complete fix for #316509. The broader error bucket cannot validate either approach because its current prefix is last-callback delivery order rather than causality; #328065 addresses that separately. CCR also correctly found two test/documentation gaps, and CI currently fails because the fixture passes an unsupported Thanks Harald Kirschner (@digitarald) and Copilot Code Review for catching the missing mutation paths and compact-mode re-entry. |
Relates to #316509 (
ChatInputPart.containerHeight, bucketb47563cc-656f-baae-0d1c-0996d4838019).What this is — and is not
updateToolConfirmationCarouselMaxHeight()measuresthis.container, then writesmax-heightonto the carousel — a descendant of that container:Calling that from the container's own
ResizeObserverresizes the observed subtree during delivery, forcing another notification pass — theResizeObserver loop completed with undelivered notificationswarning.4b0aa24 already addressed this by deferring the write to an animation frame, and it works. The probe added here confirms it directly:
main)_layout()(this PR)So this is not a behavioural bug fix, and reviewers should not expect it to change error rates. Please weigh it on the two things it actually offers.
1. Ownership
The carousel allocation is a layout decision that depends on a measurement
_layout()already performs. Computing it there means theResizeObservercallback no longer has to schedule layout work at all:AnimationFrameSchedulergoes away;this.height;_maxHeight(editor and carousel) are resolved from one measurement pass instead of two mechanisms.The deferral fixed when the write happens. This fixes who owns it.
2. Regression coverage
The original fix was validated manually (open DevTools, type rapidly). There was no automated test, which is why its effect was never measurable. This adds one.
Why telemetry can't settle this
Worth recording, because it is easy to misread this bucket — I did at first.
The attribution is assigned in
DisposableResizeObserver:That is whichever observer ran last in the observation phase, not the one that caused the loop. The bucket therefore aggregates every RO loop where this observer happened to run last. Consequences:
An earlier revision of this description argued from
7.2 → 6.7 hits/useracross 1.120 → 1.121 that the deferral "barely helped." That inference was unsound and has been removed.Separately: hits/user for this bucket jumps from ~4.4 (1.129.x) to ~57.8 (1.130.0 stable, 337,927 users) while
ChatListItemRenderer.itemHeightmoves the other way (13.6 → 10.5) over the same releases. Given attribution is non-causal I can no longer claim that is a carousel regression, but the asymmetry is real and probably deserves its own investigation.Verification
ResizeObserverLoopCarouselBudgetprobe sweeps budgets 560→280, asserting zero warnings and immediate settling.560:232|250 · 500:232|190 · 440:232|130 · 380:232|70 · 320:178|64 · 280:138|64Note on #316509
The issue auto-closed as COMPLETED when 4b0aa24 merged. Given the attribution caveat above, closure was never verifiable either way — but the bucket is still among the largest chat error buckets, so it may be worth revisiting on its own terms rather than treating it as resolved.