Skip to content

Commit 54b7f42

Browse files
authored
Repopulate slash command when user submits query (microsoft#187514)
1 parent b49426d commit 54b7f42

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class InputEditorSlashCommandFollowups extends Disposable {
138138
@IChatService private readonly chatService: IChatService
139139
) {
140140
super();
141-
this._register(this.chatService.onDidCompleteSlashCommand(({ slashCommand, sessionId }) => this.repopulateSlashCommand(slashCommand, sessionId)));
141+
this._register(this.chatService.onDidSubmitSlashCommand(({ slashCommand, sessionId }) => this.repopulateSlashCommand(slashCommand, sessionId)));
142142
}
143143

144144
private async repopulateSlashCommand(slashCommand: string, sessionId: string) {

src/vs/workbench/contrib/chat/common/chatService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export interface IChatService {
178178
_serviceBrand: undefined;
179179
transferredSessionId: string | undefined;
180180

181-
onDidCompleteSlashCommand: Event<{ slashCommand: string; sessionId: string }>;
181+
onDidSubmitSlashCommand: Event<{ slashCommand: string; sessionId: string }>;
182182
registerProvider(provider: IChatProvider): IDisposable;
183183
registerSlashCommandProvider(provider: ISlashCommandProvider): IDisposable;
184184
getProviderInfos(): IChatProviderInfo[];

src/vs/workbench/contrib/chat/common/chatServiceImpl.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ export class ChatService extends Disposable implements IChatService {
135135
private readonly _onDidPerformUserAction = this._register(new Emitter<IChatUserActionEvent>());
136136
public readonly onDidPerformUserAction: Event<IChatUserActionEvent> = this._onDidPerformUserAction.event;
137137

138-
private readonly _onDidCompleteSlashCommand = this._register(new Emitter<{ slashCommand: string; sessionId: string }>());
139-
public readonly onDidCompleteSlashCommand = this._onDidCompleteSlashCommand.event;
138+
private readonly _onDidSubmitSlashCommand = this._register(new Emitter<{ slashCommand: string; sessionId: string }>());
139+
public readonly onDidSubmitSlashCommand = this._onDidSubmitSlashCommand.event;
140140

141141
constructor(
142142
@IStorageService private readonly storageService: IStorageService,
@@ -446,6 +446,9 @@ export class ChatService extends Disposable implements IChatService {
446446

447447
model.cancelRequest(request);
448448
});
449+
if (usedSlashCommand?.command) {
450+
this._onDidSubmitSlashCommand.fire({ slashCommand: usedSlashCommand.command, sessionId: model.sessionId });
451+
}
449452
let rawResponse = await provider.provideReply({ session: model.session!, message: resolvedCommand }, progressCallback, token);
450453
if (token.isCancellationRequested) {
451454
return;
@@ -475,15 +478,9 @@ export class ChatService extends Disposable implements IChatService {
475478
Promise.resolve(provider.provideFollowups(model.session!, CancellationToken.None)).then(followups => {
476479
model.setFollowups(request, withNullAsUndefined(followups));
477480
model.completeResponse(request);
478-
if (usedSlashCommand?.command) {
479-
this._onDidCompleteSlashCommand.fire({ slashCommand: usedSlashCommand.command, sessionId: model.sessionId });
480-
}
481481
});
482482
} else {
483483
model.completeResponse(request);
484-
if (usedSlashCommand?.command) {
485-
this._onDidCompleteSlashCommand.fire({ slashCommand: usedSlashCommand.command, sessionId: model.sessionId });
486-
}
487484
}
488485
}
489486
});

0 commit comments

Comments
 (0)