You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Error] unhandlederror-Cannot read properties of undefined (reading 'currentModeKind') #310356
ai-analyzedAI automation workflow has run an analysis of this issue and provided a comment.ai-generatedGenerated by AI automation workflowsbugIssue identified by VS Code Team member as probable bugerror-telemetryVS Code - Issues generated by telemetryinsiders-releasedPatch has been released in VS Code Insidersrecent-regression
TypeError: Cannot read properties of undefined (reading 'currentModeKind') at cC.renderWelcomeViewContentIfNeeded (out/vs/sessions/sessions.desktop.main.js:2372:45741) at cC.lockToCodingAgent (out/vs/sessions/sessions.desktop.main.js:2372:69162) at Bx.updateWidgetLockState (out/vs/sessions/sessions.desktop.main.js:3093:75968) at async Bx.showModel (out/vs/sessions/sessions.desktop.main.js:3093:75248) at async r (out/vs/sessions/sessions.desktop.main.js:1328:15530)
renderWelcomeViewContentIfNeeded() accesses this.input.currentModeKind (line 1006 of chatWidget.ts) without a null guard. The input getter returns this.inputPartDisposable.value! — a non-null assertion that fails at runtime when the ChatInputPart hasn't been created yet (widget not rendered) or has been disposed. This is triggered through the async showModel() → updateWidgetLockState() → lockToCodingAgent()/unlockFromCodingAgent() call chain, where the widget lifecycle can change during awaited session loading. 205 hits across 135 users spanning versions 1.113–1.117 indicate a persistent async lifecycle race.
Culprit Commit
No specific culprit commit was identified. The issue body has no commit range analysis, and the error telemetry shows hits across 5+ insider versions since v1.113 (2026-03-31), indicating a pre-existing race condition in the widget lifecycle rather than a single regression commit. The lockToCodingAgent / unlockFromCodingAgent methods have always called renderWelcomeViewContentIfNeeded() without guarding for an uninitialized input part.
Code Flow
sequenceDiagram
participant VP as ChatViewPane
participant SM as showModel()
participant CS as ChatService
participant CW as ChatWidget
participant RW as renderWelcomeViewContentIfNeeded()
VP->>SM: showModel(token, modelRef)
SM->>CS: await acquireOrLoadSession()
Note over CS: ⚠️ Async gap: widget<br/>may be disposed or<br/>not yet rendered
CS-->>SM: session reference
SM->>VP: updateWidgetLockState(sessionType)
VP->>CW: lockToCodingAgent(name, displayName, agentId)
CW->>RW: renderWelcomeViewContentIfNeeded()
RW->>CW: this.input.currentModeKind
Note over CW: 💥 this.input is undefined<br/>(inputPartDisposable.value is null)
Crash site (line 1006) and root cause — renderWelcomeViewContentIfNeeded() accesses this.input without null guard; lockToCodingAgent() (line 2161) and unlockFromCodingAgent() (line 2181) call it unsafely
Approach: Add an early return guard at the top of renderWelcomeViewContentIfNeeded() to check whether the input part has been initialized:
if(!this.inputPartDisposable.value){return;}
This is consistent with the existing defensive pattern already used elsewhere in the widget — for example, unlockFromCodingAgent() uses this.inputEditor?.updateOptions(...) (line 2187) with optional chaining. The same safety should apply to renderWelcomeViewContentIfNeeded().
Additionally, lockToCodingAgent() and unlockFromCodingAgent() could check this._isDisposed before proceeding, since these methods may be called from an async context after the widget has been disposed.
Recommended Owner
@roblourens — already assigned; active maintainer of the chat widget and sessions infrastructure (most recent commits to both affected files)
ai-analyzedAI automation workflow has run an analysis of this issue and provided a comment.ai-generatedGenerated by AI automation workflowsbugIssue identified by VS Code Team member as probable bugerror-telemetryVS Code - Issues generated by telemetryinsiders-releasedPatch has been released in VS Code Insidersrecent-regression
Activity
vs-code-engineering commentedon Apr 16, 2026
🔍 Error Investigation
Summary
renderWelcomeViewContentIfNeeded()accessesthis.input.currentModeKind(line 1006 ofchatWidget.ts) without a null guard. Theinputgetter returnsthis.inputPartDisposable.value!— a non-null assertion that fails at runtime when theChatInputParthasn't been created yet (widget not rendered) or has been disposed. This is triggered through the asyncshowModel()→updateWidgetLockState()→lockToCodingAgent()/unlockFromCodingAgent()call chain, where the widget lifecycle can change during awaited session loading. 205 hits across 135 users spanning versions 1.113–1.117 indicate a persistent async lifecycle race.Culprit Commit
No specific culprit commit was identified. The issue body has no commit range analysis, and the error telemetry shows hits across 5+ insider versions since v1.113 (2026-03-31), indicating a pre-existing race condition in the widget lifecycle rather than a single regression commit. The
lockToCodingAgent/unlockFromCodingAgentmethods have always calledrenderWelcomeViewContentIfNeeded()without guarding for an uninitialized input part.Code Flow
sequenceDiagram participant VP as ChatViewPane participant SM as showModel() participant CS as ChatService participant CW as ChatWidget participant RW as renderWelcomeViewContentIfNeeded() VP->>SM: showModel(token, modelRef) SM->>CS: await acquireOrLoadSession() Note over CS: ⚠️ Async gap: widget<br/>may be disposed or<br/>not yet rendered CS-->>SM: session reference SM->>VP: updateWidgetLockState(sessionType) VP->>CW: lockToCodingAgent(name, displayName, agentId) CW->>RW: renderWelcomeViewContentIfNeeded() RW->>CW: this.input.currentModeKind Note over CW: 💥 this.input is undefined<br/>(inputPartDisposable.value is null)Affected Files
src/vs/workbench/contrib/chat/browser/widget/chatWidget.tsrenderWelcomeViewContentIfNeeded()accessesthis.inputwithout null guard;lockToCodingAgent()(line 2161) andunlockFromCodingAgent()(line 2181) call it unsafelysrc/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewPane.tsshowModel()(line 745) awaits async session loading then callsupdateWidgetLockState()which invokes lock/unlock on the widgetRepro Steps
showModel()starts loading a session, the widget gets disposed during the await, andlockToCodingAgentruns on the stale widgetFix Proposal
Fix location:
src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts→renderWelcomeViewContentIfNeeded()Approach: Add an early return guard at the top of
renderWelcomeViewContentIfNeeded()to check whether the input part has been initialized:This is consistent with the existing defensive pattern already used elsewhere in the widget — for example,
unlockFromCodingAgent()usesthis.inputEditor?.updateOptions(...)(line 2187) with optional chaining. The same safety should apply torenderWelcomeViewContentIfNeeded().Additionally,
lockToCodingAgent()andunlockFromCodingAgent()could checkthis._isDisposedbefore proceeding, since these methods may be called from an async context after the widget has been disposed.Recommended Owner
@roblourens— already assigned; active maintainer of the chat widget and sessions infrastructure (most recent commits to both affected files)fix(chat): guard renderWelcomeViewContentIfNeeded against undisposed …
fix(chat): guard renderWelcomeViewContentIfNeeded against undisposed …