Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ export class LocalAgentsSessionsProvider extends Disposable implements IChatSess
this._onDidChangeChatSessionItems.fire();
}
}));

this._register(this.chatService.onDidChangeSessionTitle(e => {
if (getChatSessionType(e.sessionResource) === this.chatSessionType) {
this._onDidChangeChatSessionItems.fire();
}
}));
}

async provideChatSessionItems(token: CancellationToken): Promise<IChatSessionItem[]> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,8 @@ export interface IChatService {

readonly onDidDisposeSession: Event<{ readonly sessionResource: URI[]; readonly reason: 'cleared' }>;

readonly onDidChangeSessionTitle: Event<{ readonly sessionResource: URI; readonly title: string }>;

transferChatSession(transferredSessionResource: URI, toWorkspace: URI): Promise<void>;

activateDefaultAgent(location: ChatAgentLocation): Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ export class ChatService extends Disposable implements IChatService {
private readonly _onDidDisposeSession = this._register(new Emitter<{ readonly sessionResource: URI[]; reason: 'cleared' }>());
public readonly onDidDisposeSession = this._onDidDisposeSession.event;

private readonly _onDidChangeSessionTitle = this._register(new Emitter<{ readonly sessionResource: URI; readonly title: string }>());
public readonly onDidChangeSessionTitle = this._onDidChangeSessionTitle.event;

private readonly _sessionFollowupCancelTokens = this._register(new DisposableResourceMap<CancellationTokenSource>());
private readonly _chatServiceTelemetry: ChatServiceTelemetry;
private readonly _chatSessionStore: ChatSessionStore;
Expand Down Expand Up @@ -253,14 +256,17 @@ export class ChatService extends Disposable implements IChatService {
const model = this._sessionModels.get(sessionResource);
if (model) {
model.setCustomTitle(title);
}
} else {

// Update the title in the file storage
const localSessionId = LocalChatSessionUri.parseLocalSessionId(sessionResource);
if (localSessionId) {
await this._chatSessionStore.setSessionTitle(localSessionId, title);
// Trigger immediate save to ensure consistency
this.saveState();
// Update the title in the file storage
const localSessionId = LocalChatSessionUri.parseLocalSessionId(sessionResource);
if (localSessionId) {
await this._chatSessionStore.setSessionTitle(localSessionId, title);
// Trigger immediate save to ensure consistency
this.saveState();
}

this._onDidChangeSessionTitle.fire({ sessionResource, title });
}
}

Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/chat/common/model/chatModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,7 @@ export interface IChatModel extends IDisposable {
readonly initialLocation: ChatAgentLocation;
readonly title: string;
readonly hasCustomTitle: boolean;
setCustomTitle(title: string): void;
readonly responderUsername: string;
/** True whenever a request is currently running */
readonly requestInProgress: IObservable<boolean>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class MockChatService implements IChatService {
private readonly _onDidDisposeSession = new Emitter<{ sessionResource: URI[]; reason: 'cleared' }>();
readonly onDidDisposeSession = this._onDidDisposeSession.event;

private readonly _onDidChangeSessionTitle = new Emitter<{ sessionResource: URI; title: string }>();
readonly onDidChangeSessionTitle = this._onDidChangeSessionTitle.event;

fireDidDisposeSession(sessionResource: URI[]): void {
this._onDidDisposeSession.fire({ sessionResource, reason: 'cleared' });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export class MockChatService implements IChatService {
}
readonly onDidDisposeSession: Event<{ sessionResource: URI[]; reason: 'cleared' }> = undefined!;

readonly onDidChangeSessionTitle: Event<{ readonly sessionResource: URI; readonly title: string }> = undefined!;

async transferChatSession(transferredSessionResource: URI, toWorkspace: URI): Promise<void> {
throw new Error('Method not implemented.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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 { }
Expand Down
Loading