Skip to content

fix(chat): stop observing prompt timeline host height - #330339

Merged
Bryan Chen (bryanchen-d) merged 2 commits into
mainfrom
copilot/vscode/idle-resize-observer-tracer
Aug 12, 2026
Merged

Bryan Chen (bryanchen-d) merged 2 commits into
mainfrom
copilot/vscode/idle-resize-observer-tracer

Conversation

@bryanchen-d

@bryanchen-d Bryan Chen (bryanchen-d) commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Stable 1.132 has a rare ResizeObserver loop completed with undelivered notifications failure mode. The new context telemetry frequently included ChatInputPart.containerHeight and ChatPetWidget.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-session host only to learn width:

PromptTimeline host ResizeObserver
  target: .interactive-session (ancestor)
  callback: rail.setHostWidth(host.clientWidth)

ResizeObserver observes both dimensions. During a stacked input-height update:

ChatInputPart.containerHeight callback (deeper target)
  → synchronous height publication
  → ChatViewPane synchronously relayouts stacked sessions
  → .interactive-session changes 116px → 142px
  → PromptTimeline's shallower ancestor observation is active
  → Chromium cannot deliver it in the same phase
  → loop warning with undelivered notifications

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:

Variant Result
Baseline warning in 3/3
ChatPetWidget observer disconnected warning in 3/3; same input→session edge
ChatWidget list relayout disabled warning in 3/3
ChatViewPane stacked relayout disabled 0 warnings in 3/3
Prompt Timeline host observer removed, all synchronous relayout restored 0 warnings in 3/3
Host observer replaced with explicit widget layout-width signal 0 warnings in 3/3

This rules out a ChatPetWidget-only fix and avoids changing input-height or ViewPane timing.

Change

  • Add a concrete ChatWidget.onDidLayout event carrying { width, height } after main widget layout.
  • Initialize the Prompt Timeline rail from the current host.clientWidth.
  • Update subsequent rail widths from explicit ChatWidget layout events.
  • Remove the native ResizeObserver from .interactive-session.
  • Sticky-header-only configurations no longer install a useless width observer when there is no rail.

ChatInputPart.height publication and stacked ChatViewPane relayout remain synchronous and unchanged.

Validation

  • npm run typecheck-client
  • npm run transpile-client
  • 4 Playwright chat ResizeObserver tests
  • 5708 chat unit tests, including explicit width initialization, layout propagation, and disposal
  • exact 1.132 restored-profile differential: 0 warnings in 3/3 runs
  • independent code review: no significant issues

The full native tracer remains local diagnostic tooling and is not included in this PR.

Authored with Copilot

Copilot AI balanced review requested due to automatic review settings August 11, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@bryanchen-d
Bryan Chen (bryanchen-d) marked this pull request as draft August 11, 2026 20:32
@bryanchen-d

Copy link
Copy Markdown
Collaborator Author

Scope check: I tested whether this can be fixed only in ChatPetWidget.

On the exact 1.132 release worktree and the same restored-profile Electron/CDP sweep, I removed only the pet's resizeObserver.observe(this.dragBounds) registration and kept ChatInputPart.height synchronous.

Result across 3 identical runs:

Variant Native loop warnings Causal geometry edge
1.132 baseline 1 ChatInputPart.containerHeight callback → observed .interactive-session 116px → 142px
Pet observer disconnected, run 1 1 same edge
Pet observer disconnected, run 2 1 same edge
Pet observer disconnected, run 3 1 same edge

The native tracer still constructed the pet observer, but it had zero targets and zero callbacks. The warning remained unchanged. This demonstrates that ChatPetWidget.dragBounds is phase context/last-callback noise for this repro, not the causal fix scope.

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.

@bryanchen-d
Bryan Chen (bryanchen-d) force-pushed the copilot/vscode/idle-resize-observer-tracer branch from 7e79b07 to 8d9a4ef Compare August 11, 2026 21:42
@bryanchen-d Bryan Chen (bryanchen-d) changed the title fix(chat): publish input height outside resize delivery fix(chat): schedule stacked input relayout outside resize delivery Aug 11, 2026
@bryanchen-d
Bryan Chen (bryanchen-d) requested a balanced review from Copilot August 11, 2026 21:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

src/vs/workbench/test/browser/componentFixtures/chat/chatIdleResizeObserver.fixture.ts:188

  • Replacing the window-wide ResizeObserver constructor 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

@bryanchen-d
Bryan Chen (bryanchen-d) force-pushed the copilot/vscode/idle-resize-observer-tracer branch from 8d9a4ef to 4291909 Compare August 11, 2026 23:55
@bryanchen-d Bryan Chen (bryanchen-d) changed the title fix(chat): schedule stacked input relayout outside resize delivery fix(chat): stop observing prompt timeline host height Aug 11, 2026
@bryanchen-d
Bryan Chen (bryanchen-d) requested a balanced review from Copilot August 11, 2026 23:56
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
@bryanchen-d
Bryan Chen (bryanchen-d) force-pushed the copilot/vscode/idle-resize-observer-tracer branch from 4291909 to 1e42fa1 Compare August 12, 2026 00:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

src/vs/workbench/contrib/chat/test/browser/widget/chatWidget.test.ts:166

  • This test synthesizes onDidLayout itself, so it still passes if ChatWidget.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

@justschen Justin Chen (justschen) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just reviewed + tested, this looks good, thanks!

@justschen
Justin Chen (justschen) marked this pull request as ready for review August 12, 2026 19:36
@bryanchen-d
Bryan Chen (bryanchen-d) merged commit 17217a0 into main Aug 12, 2026
27 checks passed
@bryanchen-d
Bryan Chen (bryanchen-d) deleted the copilot/vscode/idle-resize-observer-tracer branch August 12, 2026 20:37
@vs-code-engineering vs-code-engineering Bot added this to the 1.134.0 milestone Aug 12, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Sep 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Error] unhandlederror-[DisposableResizeObserver(ChatPetWidget.dragBounds)] ResizeObserver loop completed wi...

3 participants