Skip to content

fix(chat): guard renderWelcomeViewContentIfNeeded against undisposed input part (#310356)#310822

Merged
roblourens merged 1 commit intomicrosoft:mainfrom
maruthang:fix/issue-310356-welcome-view-null-guard
Apr 16, 2026
Merged

fix(chat): guard renderWelcomeViewContentIfNeeded against undisposed input part (#310356)#310822
roblourens merged 1 commit intomicrosoft:mainfrom
maruthang:fix/issue-310356-welcome-view-null-guard

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

What — Add an early-return in ChatWidget.renderWelcomeViewContentIfNeeded() when the input part has not been rendered (or was already disposed).

Why — The method dereferences this.input.currentModeKind, which hits a non-null assertion on this.inputPartDisposable.value!. Invocations from the async showModelupdateWidgetLockStatelockToCodingAgent/unlockFromCodingAgent chain could land while no input part was live, throwing unhandled errors (205 hits / 135 users reported in #310356).

How — Early-return guard if (!this.inputPartDisposable.value) { return; } at the top of renderWelcomeViewContentIfNeeded(). Mirrors the existing defensive pattern in the sibling renderGettingStartedTipIfNeeded() (line ~1040) and the optional-chain at line 1026.

Test plan — Manual repro via the agent-session flow that triggers lockToCodingAgent/unlockFromCodingAgent before the input part renders; pre-fix this throws on inputPartDisposable.value!, post-fix it returns early. No unit test added (no existing chatWidget.test.ts harness).

Fixes #310356

Copy link
Copy Markdown
Member

@roblourens roblourens left a comment

Choose a reason for hiding this comment

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

Sure, thanks

@roblourens roblourens merged commit 437414d into microsoft:main Apr 16, 2026
26 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.117.0 milestone Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Error] unhandlederror-Cannot read properties of undefined (reading 'currentModeKind')

3 participants