Skip to content

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

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

roblourens merged 1 commit into
microsoft: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 showModel → updateWidgetLockState → lockToCodingAgent/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

@roblourens roblourens left a comment

Copy link
Copy Markdown
Member

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
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators May 31, 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-Cannot read properties of undefined (reading 'currentModeKind')

3 participants