From 0df3d0ae402ca64555894558ae9c069c0ada6aee Mon Sep 17 00:00:00 2001 From: Osvaldo Ortega Date: Wed, 7 Jan 2026 18:31:13 -0800 Subject: [PATCH 1/2] Rename fix for disposed models --- .../contrib/chat/common/chatService/chatServiceImpl.ts | 8 ++++++++ src/vs/workbench/contrib/chat/common/model/chatModel.ts | 1 + .../contrib/chat/test/common/model/mockChatModel.ts | 3 +++ 3 files changed, 12 insertions(+) diff --git a/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts b/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts index 5722b61e57000..67d5a8e9b2a87 100644 --- a/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts +++ b/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts @@ -243,6 +243,14 @@ export class ChatService extends Disposable implements IChatService { const model = this._sessionModels.get(sessionResource); if (model) { model.setCustomTitle(title); + } else { + let modelRef: IChatModelReference | undefined; + try { + modelRef = await this.getOrRestoreSession(sessionResource); + modelRef?.object.setCustomTitle(title); + } finally { + modelRef?.dispose(); + } } // Update the title in the file storage diff --git a/src/vs/workbench/contrib/chat/common/model/chatModel.ts b/src/vs/workbench/contrib/chat/common/model/chatModel.ts index a37c0e138ab19..0a32da92ffb3e 100644 --- a/src/vs/workbench/contrib/chat/common/model/chatModel.ts +++ b/src/vs/workbench/contrib/chat/common/model/chatModel.ts @@ -1211,6 +1211,7 @@ export interface IChatModel extends IDisposable { readonly initialLocation: ChatAgentLocation; readonly title: string; readonly hasCustomTitle: boolean; + setCustomTitle(title: string): void; /** True whenever a request is currently running */ readonly requestInProgress: IObservable; /** Provides session information when a request needs user interaction to continue */ diff --git a/src/vs/workbench/contrib/chat/test/common/model/mockChatModel.ts b/src/vs/workbench/contrib/chat/test/common/model/mockChatModel.ts index 35ae57d3cc5bd..7671f3f779f92 100644 --- a/src/vs/workbench/contrib/chat/test/common/model/mockChatModel.ts +++ b/src/vs/workbench/contrib/chat/test/common/model/mockChatModel.ts @@ -54,6 +54,9 @@ export class MockChatModel extends Disposable implements IChatModel { super.dispose(); } + setCustomTitle(title: string): void { + this.customTitle = title; + } startEditingSession(isGlobalEditingSession?: boolean, transferFromSession?: IChatEditingSession): void { } getRequests(): IChatRequestModel[] { return []; } setCheckpoint(requestId: string | undefined): void { } From 020cf603504b98a78d92f48399f6ad81a43477bd Mon Sep 17 00:00:00 2001 From: Osvaldo Ortega Date: Wed, 7 Jan 2026 18:32:42 -0800 Subject: [PATCH 2/2] catch --- .../contrib/chat/common/chatService/chatServiceImpl.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts b/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts index 67d5a8e9b2a87..ca2c905f8445c 100644 --- a/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts +++ b/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts @@ -248,6 +248,8 @@ export class ChatService extends Disposable implements IChatService { try { modelRef = await this.getOrRestoreSession(sessionResource); modelRef?.object.setCustomTitle(title); + } catch (e) { + this.error('setChatSessionTitle', `Failed to restore session ${sessionResource} to set title: ${toErrorMessage(e)}`); } finally { modelRef?.dispose(); }