Skip to content

fix: defer ChatInputPart carousel max-height update to next animation frame (#316509) - #316524

Merged
Bryan Chen (bryanchen-d) merged 1 commit into
mainfrom
brchen/fix-chat-input-resize-loop-316509
May 15, 2026
Merged

Bryan Chen (bryanchen-d) merged 1 commit into
mainfrom
brchen/fix-chat-input-resize-loop-316509

Conversation

@bryanchen-d

@bryanchen-d Bryan Chen (bryanchen-d) commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes the ResizeObserver loop completed with undelivered notifications warning attributed to [DisposableResizeObserver(ChatInputPart.containerHeight)] in error telemetry.

The ChatInputPart.containerHeight resize observer's callback called updateToolConfirmationCarouselMaxHeight() synchronously. That writes style.maxHeight on the tool-confirmation carousel — a descendant of the observed this.container. Under flexbox, the descendant's height change flexes back up into the observed container, causing the browser to re-queue a notification for the same observer. When external mutations (rapid type+Enter) keep arriving during the next observation phases, Chromium's loop algorithm exhausts its depth budget and emits the synthetic warning.

This change defers only the carousel max-height write to the next animation frame via AnimationFrameScheduler. Publishing this.height via the observable stays synchronous because its autorun consumers re-layout siblings/ancestors of the input container (the message list, welcome container, view pane), not the container itself, so they do not feed back into the same observation phase.

Fixes #316509

Trigger scenarios

  • A chat session with one or more pending tool confirmations queued in the carousel such that the carousel's natural height exceeds its budget (maxHeight - otherInputHeight).
  • A burst of input events that resize the chat input container (rapid typing, Enter to queue more steering items, attachment changes, toolbar reflows) arriving across consecutive resize-observation phases.
  • The combination causes setMaxHeight inside the RO callback to materially shrink the carousel, which propagates back up to this.container, which the browser flags as an undelivered notification.

Code flow diagram

sequenceDiagram
    participant User
    participant Browser
    participant Observer
    participant InputPart
    participant Carousel
    participant Flex

    User->>Browser: rapid type plus Enter
    Browser->>Browser: container resizes
    Browser->>Observer: deliver notification at depth D
    Observer->>InputPart: updateToolConfirmationCarouselMaxHeight
    InputPart->>Carousel: setMaxHeight budget minus otherInputHeight
    Carousel->>Flex: write style maxHeight and carousel shrinks
    Flex->>Browser: container offsetHeight changed at depth D
    Browser->>Browser: active observation pending at depth not greater than D
    Note over Browser: another external resize arrives before phase drains
    Browser->>User: dispatches ResizeObserver loop completed with undelivered notifications
Loading

How the fix works

  • src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts
    • Wrap updateToolConfirmationCarouselMaxHeight() in an AnimationFrameScheduler so the descendant write that flexes back up into the observed container happens outside the resize-observation phase.
    • Keep this.height.set(newHeight, undefined) synchronous so parent layout (message list, welcome container) tracks the input height with no perceptible 1-frame lag.
    • Bursts of resize events coalesce into a single rAF run via the scheduler's pending-runner guard, which also reduces layout thrash in the bug's repro path.

Manual validation steps

  1. Build VS Code (Run Dev task).
  2. Open Chat in agent mode and start a session that will queue several tool confirmations (e.g., a prompt that triggers multiple successive tool calls so the carousel fills with pending items).
  3. Open DevTools console.
  4. With pending confirmations visible, rapidly type into the chat input and press Enter several times in quick succession to queue more steering items.
  5. Before the fix: the console intermittently logs ResizeObserver loop completed with undelivered notifications, surfaced as an error-telemetry event with attribution [DisposableResizeObserver(ChatInputPart.containerHeight)].
  6. After the fix: the warning no longer appears under the same interaction, and there is no perceptible visual lag in the input or the message list above it.

Copilot AI review requested due to automatic review settings May 14, 2026 23:55

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

Fixes a Chromium ResizeObserver loop completed with undelivered notifications warning by deferring a descendant layout write (tool-confirmation carousel max-height) out of the ResizeObserver delivery phase, reducing re-entrant resize notifications under bursty input. The PR also includes a small terminal teardown/resizing hardening change to avoid re-entrant resizes during disposal.

Changes:

  • Defer ChatInputPart.updateToolConfirmationCarouselMaxHeight() to the next animation frame from the ChatInputPart.containerHeight ResizeObserver callback using dom.AnimationFrameScheduler.
  • Make TerminalProcessManager.setDimensions a no-op when the manager is already disposed, and throw a clearer error when called before ptyProcessReady is initialized.
  • Dispose TerminalInstance’s resize debouncer before disposing the process manager to prevent resize callbacks from running against torn-down process state.
Show a summary per file
File Description
src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts Guard setDimensions against disposal re-entrancy and add a clearer pre-init failure mode.
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts Dispose _resizeDebouncer earlier in dispose() to prevent late resize callbacks during teardown.
src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts Defer carousel max-height updates out of ResizeObserver callback via AnimationFrameScheduler.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

@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.

ah gotcha. thanks for giving this a look!

@bryanchen-d
Bryan Chen (bryanchen-d) merged commit c08a4bd into main May 15, 2026
25 checks passed
@bryanchen-d
Bryan Chen (bryanchen-d) deleted the brchen/fix-chat-input-resize-loop-316509 branch May 15, 2026 17:06
@vs-code-engineering vs-code-engineering Bot added this to the 1.121.0 milestone May 15, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jun 29, 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(ChatInputPart.containerHeight)] ResizeObserver loop complet...

3 participants