Skip to content

Commit 1ac9f61

Browse files
authored
pass in token to prompt function (microsoft#259058)
1 parent 66f7670 commit 1ac9f61

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/bufferOutputPolling.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ export async function pollForOutputAndIdle(
152152
return { terminalExecutionIdleBeforeTimeout: false, output: buffer, pollDurationMs: Date.now() - pollStartTime + (extendedPolling ? PollingConsts.FirstPollingMaxDuration : 0) };
153153
}
154154

155-
export function promptForMorePolling(command: string, context: IToolInvocationContext, chatService: IChatService): { promise: Promise<boolean>; part?: ChatElicitationRequestPart } {
155+
export function promptForMorePolling(command: string, token: CancellationToken, context: IToolInvocationContext, chatService: IChatService): { promise: Promise<boolean>; part?: ChatElicitationRequestPart } {
156+
if (token.isCancellationRequested) {
157+
return { promise: Promise.resolve(false) };
158+
}
156159
const chatModel = chatService.getSession(context.sessionId);
157160
if (chatModel instanceof ChatModel) {
158161
const request = chatModel.getRequests().at(-1);

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
331331
if (!outputAndIdle.terminalExecutionIdleBeforeTimeout) {
332332
outputAndIdle = await racePollingOrPrompt(
333333
() => pollForOutputAndIdle(execution, true, token, this._languageModelsService),
334-
() => promptForMorePolling(command, invocation.context!, this._chatService),
334+
() => promptForMorePolling(command, token, invocation.context!, this._chatService),
335335
outputAndIdle,
336336
token,
337337
this._languageModelsService,

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/createAndRunTaskTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class CreateAndRunTaskTool implements IToolImpl {
122122
if (!outputAndIdle.terminalExecutionIdleBeforeTimeout) {
123123
outputAndIdle = await racePollingOrPrompt(
124124
() => pollForOutputAndIdle({ getOutput: () => getOutput(terminal), isActive: () => this._isTaskActive(task) }, true, token, this._languageModelsService),
125-
() => promptForMorePolling(args.task.label, invocation.context!, this._chatService),
125+
() => promptForMorePolling(args.task.label, token, invocation.context!, this._chatService),
126126
outputAndIdle,
127127
token,
128128
this._languageModelsService,

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/runTaskTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class RunTaskTool implements IToolImpl {
7979
if (!outputAndIdle.terminalExecutionIdleBeforeTimeout) {
8080
outputAndIdle = await racePollingOrPrompt(
8181
() => pollForOutputAndIdle({ getOutput: () => getOutput(terminal), isActive: () => this._isTaskActive(task) }, true, token, this._languageModelsService),
82-
() => promptForMorePolling(taskLabel, invocation.context!, this._chatService),
82+
() => promptForMorePolling(taskLabel, token, invocation.context!, this._chatService),
8383
outputAndIdle,
8484
token,
8585
this._languageModelsService,

0 commit comments

Comments
 (0)