-
e. This feature may be a bit like show in memory inspactor with reference. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
cc @sdirix |
Beta Was this translation helpful? Give feedback.
-
Hi @lqd1434, to submit a request in the chat programmatically, you can use the @injectable()
export class SampleCommandContribution implements CommandContribution {
@inject(ChatService)
protected readonly chatService: ChatService;
registerCommands(commands: CommandRegistry): void {
commands.registerCommand(SampleCommand, {
execute: async () => {
// creates a clean session
const session = this.chatService.createSession(ChatAgentLocation.Panel, { focus: true });
// submit a request
await this.chatService.sendRequest(session.id, { text: 'Hello World!' });
}
});
}
} Peek.2025-02-26.15-48.webmIt is of course optional to create a new session first. You can also just submit a request in an existing session. You can obtain all existing sessions from the chat service ( You can then use this command in a context menu, see the documentation for more information. |
Beta Was this translation helpful? Give feedback.
-
@planger Thank you very much for your answer, I found the solution according to your answer, but I also found a problem: override createSession(location?: ChatAgentLocation, options?: SessionOptions): ChatSession {
const session = super.createSession(location, options);
session.model.onDidChange(event => {
const changeSet = (event as { changeSet?: ChangeSet }).changeSet;
if (event.kind === 'removeChangeSet') {
this.changeSetFileService.closeDiffsForSession(session.id);
} else if (changeSet) {
this.changeSetFileService.closeDiffsForSession(session.id, changeSet.getElements().map(({ uri }) => uri));
}
});
return session;
} |
Beta Was this translation helpful? Give feedback.
Hi @lqd1434,
to submit a request in the chat programmatically, you can use the
ChatService
. Below at the example of creating a new session and submitting a new request from a command handler.