mirror of https://github.com/microsoft/vscode.git
Set title for contributed chat session (#259108)
* setCustomTitle for contributedChatSession * Add preferredTitle to allow setting * tidy up * extract out to get types happy
This commit is contained in:
parent
f58a56ea03
commit
6724a5fb36
|
@ -31,6 +31,7 @@ import { ChatWidget, IChatViewState } from './chatWidget.js';
|
|||
|
||||
export interface IChatEditorOptions extends IEditorOptions {
|
||||
target?: { sessionId: string } | { data: IExportableChatData | ISerializableChatData };
|
||||
preferredTitle?: string;
|
||||
}
|
||||
|
||||
export class ChatEditor extends EditorPane {
|
||||
|
@ -125,6 +126,7 @@ export class ChatEditor extends EditorPane {
|
|||
throw new Error('ChatEditor lifecycle issue: no editor widget');
|
||||
}
|
||||
|
||||
let isContributedChatSession = false;
|
||||
if (input.resource.scheme === Schemas.vscodeChatSession) {
|
||||
const identifier = ChatSessionUri.parse(input.resource);
|
||||
if (identifier) {
|
||||
|
@ -132,6 +134,7 @@ export class ChatEditor extends EditorPane {
|
|||
const contribution = contributions.find(c => c.type === identifier.chatSessionType);
|
||||
if (contribution) {
|
||||
this.widget.lockToCodingAgent(contribution.name, contribution.displayName);
|
||||
isContributedChatSession = true;
|
||||
} else {
|
||||
this.widget.unlockFromCodingAgent();
|
||||
}
|
||||
|
@ -148,6 +151,10 @@ export class ChatEditor extends EditorPane {
|
|||
}
|
||||
const viewState = options?.viewState ?? input.options.viewState;
|
||||
this.updateModel(editorModel.model, viewState);
|
||||
|
||||
if (isContributedChatSession && options?.preferredTitle) {
|
||||
editorModel.model.setCustomTitle(options?.preferredTitle);
|
||||
}
|
||||
}
|
||||
|
||||
private updateModel(model: IChatModel, viewState?: IChatViewState): void {
|
||||
|
|
|
@ -909,9 +909,14 @@ class SessionsViewPane extends ViewPane {
|
|||
const ckey = this.contextKeyService.createKey('chatSessionType', element.provider.chatSessionType);
|
||||
ckey.reset();
|
||||
|
||||
const options: IChatEditorOptions = {
|
||||
pinned: true,
|
||||
preferredTitle: element.label
|
||||
};
|
||||
|
||||
await this.editorService.openEditor({
|
||||
resource: ChatSessionUri.forSession(element.provider.chatSessionType, element.id),
|
||||
options: { pinned: true } satisfies IChatEditorOptions
|
||||
options,
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -936,6 +936,7 @@ export interface IChatModel extends IDisposable {
|
|||
acceptResponseProgress(request: IChatRequestModel, progress: IChatProgress, quiet?: boolean): void;
|
||||
setResponse(request: IChatRequestModel, result: IChatAgentResult): void;
|
||||
completeResponse(request: IChatRequestModel): void;
|
||||
setCustomTitle(title: string): void;
|
||||
toExport(): IExportableChatData;
|
||||
toJSON(): ISerializableChatData;
|
||||
}
|
||||
|
@ -1105,6 +1106,7 @@ export type IChatChangeEvent =
|
|||
| IChatSetHiddenEvent
|
||||
| IChatCompletedRequestEvent
|
||||
| IChatSetCheckpointEvent
|
||||
| IChatSetCustomTitleEvent
|
||||
;
|
||||
|
||||
export interface IChatAddRequestEvent {
|
||||
|
@ -1174,6 +1176,11 @@ export interface IChatSetAgentEvent {
|
|||
command?: IChatAgentCommand;
|
||||
}
|
||||
|
||||
export interface IChatSetCustomTitleEvent {
|
||||
kind: 'setCustomTitle';
|
||||
title: string;
|
||||
}
|
||||
|
||||
export interface IChatInitEvent {
|
||||
kind: 'initialize';
|
||||
}
|
||||
|
@ -1556,8 +1563,9 @@ export class ChatModel extends Disposable implements IChatModel {
|
|||
return request;
|
||||
}
|
||||
|
||||
setCustomTitle(title: string): void {
|
||||
public setCustomTitle(title: string): void {
|
||||
this._customTitle = title;
|
||||
this._onDidChange.fire({ kind: 'setCustomTitle', title });
|
||||
}
|
||||
|
||||
updateRequest(request: ChatRequestModel, variableData: IChatRequestVariableData) {
|
||||
|
|
Loading…
Reference in New Issue