Repository navigation
fix(chat): stop observing prompt timeline host height - #330339
Conversation
There was a problem hiding this comment.
Pull request overview
Defers chat input-height publication until the next animation frame to prevent ResizeObserver delivery loops.
Changes:
- Coalesces carousel resizing and height publication.
- Adds fixture hooks and ResizeObserver tracing.
- Adds Playwright regression scenarios.
Show a summary per file
| File | Description |
|---|---|
chatInputPart.ts |
Defers input resize transactions. |
chatWidget.fixture.ts |
Adds fixture decoration hooks. |
chatIdleResizeObserver.fixture.ts |
Adds tracing fixtures. |
chatIdleResizeObserverTrace.spec.ts |
Adds Playwright coverage. |
Review details
Tip
Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (1)
test/componentFixtures/playwright/tests/chatIdleResizeObserverTrace.spec.ts:71
- The PR description says the tracer includes a self-resizing positive control that emits a native warning and records the corresponding edge, but no such fixture or test is present. Without that control, this negative edge assertion can pass if the tracer's warning/edge capture becomes vacuous. Add the described positive-control fixture and assertion, or correct the PR description if it is intentionally excluded.
expect(summary.warningCount).toBe(0);
expect(summary.geometryEdges.some(edge => edge.observerId === inputObserver.id && edge.target.includes('interactive-session'))).toBe(false);
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Balanced
|
Scope check: I tested whether this can be fixed only in On the exact 1.132 release worktree and the same restored-profile Electron/CDP sweep, I removed only the pet's Result across 3 identical runs:
The native tracer still constructed the pet observer, but it had zero targets and zero callbacks. The warning remained unchanged. This demonstrates that A separate cleanup could bind the pet observation to pet visibility, but it would remove a no-op callback and change the telemetry context—not fix this warning. I agree the broader height-publication behavior change deserves careful review, so the PR should remain draft while we decide whether to defer publication centrally or instead defer the specific host consumers. But limiting the root fix to ChatPetWidget is ruled out by this differential. |
7e79b07 to
8d9a4ef
Compare
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/vs/workbench/test/browser/componentFixtures/chat/chatIdleResizeObserver.fixture.ts:188
- Replacing the window-wide
ResizeObserverconstructor makes every component in the fixture use the test wrapper, so the harness can perturb the observer creation order and delivery behavior that this regression is intended to validate. Inject an observer factory into the production observer owner (defaulting to the native constructor) and pass the tracing implementation only to that instance instead of mutating the global.
Object.defineProperty(targetWindow, 'ResizeObserver', {
configurable: true,
writable: true,
value: TracingResizeObserver,
});
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
- Review effort level: Balanced
8d9a4ef to
4291909
Compare
PromptTimelineWidgetContrib used a ResizeObserver on the full chat-session host only to update the rail when its width changed. ResizeObserver also activates when that host's height changes. During a stacked input-height update, the deeper ChatInputPart observer publishes height synchronously and ChatViewPane resizes the chat-session host. Because PromptTimeline observes that shallower ancestor, Chromium cannot deliver its notification in the same observation phase and reports a loop with undelivered notifications. Exact 1.132 restored-profile experiments isolated the observed target: - baseline: warning in 3/3 runs; - pet observer removed: warning in 3/3; - ChatWidget list relayout removed: warning in 3/3; - ChatViewPane relayout removed: zero in 3/3; - PromptTimeline host observer removed with all relayout restored: zero in 3/3; - explicit widget layout-width signal: zero in 3/3. Replace the width-only host observer with ChatWidget.onDidLayout. Initialize the rail from the current client width, then update it from explicit widget layout widths. Sticky-only configurations no longer install a useless host observer. Input height publication and stacked ViewPane relayout remain synchronous and unchanged. Validation: - npm run typecheck-client - npm run transpile-client - 4 Playwright chat ResizeObserver tests - 5708 chat unit tests - exact 1.132 restored-profile differential Co-authored-by: Copilot <[email protected]> Copilot-Session: aacd276e-cf84-48bd-a2ab-6f6a4d4c3431
4291909 to
1e42fa1
Compare
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/vs/workbench/contrib/chat/test/browser/widget/chatWidget.test.ts:95
- This test never calls
ChatWidget.layout; it supplies a standalone emitter, so it would still pass if the new_onDidLayout.fire(...)were removed or emitted at the wrong point. Please add coverage using the real widget/layout path (or a focused testable layout-notification path) so the production propagation is actually verified.
silent: true,
locations: [ChatAgentLocation.Chat],
},
);
const prefix = new ChatRequestTextPart(new OffsetRange(0, 1), new Range(1, 1, 1, 2), ' ');
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Balanced
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/vs/workbench/contrib/chat/test/browser/widget/chatWidget.test.ts:166
- This test synthesizes
onDidLayoutitself, so it still passes ifChatWidget.layout()stops firing the new event (for example, if line 3335 is removed). Because the ResizeObserver fix depends on that producer-to-consumer connection, add coverage that invokes the widget layout path and asserts the emitted dimensions; keep this helper test separately for initialization and disposal.
test('prompt timeline width follows explicit widget layout', () => {
const onDidLayout = new Emitter<{ width: number; height: number }>();
const host = document.createElement('div');
Object.defineProperty(host, 'clientWidth', { value: 320 });
const widths: number[] = [];
const observation = observePromptTimelineHostWidth(
{ onDidLayout: onDidLayout.event },
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Justin Chen (justschen)
left a comment
There was a problem hiding this comment.
just reviewed + tested, this looks good, thanks!
Problem
Stable 1.132 has a rare
ResizeObserver loop completed with undelivered notificationsfailure mode. The new context telemetry frequently includedChatInputPart.containerHeightandChatPetWidget.dragBounds, but that context is intentionally non-causal.Fixes #327645. Relates to #316509 and #316501.
Root cause
A test-only native ResizeObserver tracer was run against the exact 1.132 release (
df53daabb18) in a restored OSS workbench profile.Prompt Timeline installed a native ResizeObserver on the full
.interactive-sessionhost only to learn width:ResizeObserver observes both dimensions. During a stacked input-height update:
The Prompt Timeline callback itself does not write height; the unnecessary height-sensitive ancestor observation creates the skipped notification.
One-variable isolation
Each variant used the same exact-release restored profile and size/zoom sweep, repeated three times:
This rules out a ChatPetWidget-only fix and avoids changing input-height or ViewPane timing.
Change
ChatWidget.onDidLayoutevent carrying{ width, height }after main widget layout.host.clientWidth.ChatWidgetlayout events..interactive-session.ChatInputPart.heightpublication and stackedChatViewPanerelayout remain synchronous and unchanged.Validation
npm run typecheck-clientnpm run transpile-clientThe full native tracer remains local diagnostic tooling and is not included in this PR.