Skip to content

Commit 6640ea9

Browse files
committed
fix for exiting fastly from cancellation
1 parent 7074cd8 commit 6640ea9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ export class ChatController {
787787
}
788788

789789
const output = await ToolUtils.invoke(tool, chatStream, triggerID)
790+
console.log('output', output)
790791
ToolUtils.validateOutput(output, tool.type)
791792

792793
let status: ToolResultStatus = ToolResultStatus.SUCCESS
@@ -804,13 +805,21 @@ export class ChatController {
804805
status,
805806
})
806807
} catch (e: any) {
808+
if (this.isTriggerCancelled(triggerID)) {
809+
getLogger().debug(`Tool execution cancelled before invoke for tabID: ${tabID}`)
810+
return
811+
}
807812
toolResults.push({
808813
content: [{ text: e.message }],
809814
toolUseId: toolUse.toolUseId,
810815
status: ToolResultStatus.ERROR,
811816
})
812817
}
813818
} else {
819+
if (this.isTriggerCancelled(triggerID)) {
820+
getLogger().debug(`Tool execution cancelled before invoke for tabID: ${tabID}`)
821+
return
822+
}
814823
const toolResult: ToolResult = result
815824
toolResults.push(toolResult)
816825
}

packages/core/src/codewhispererChat/tools/executeBash.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ exec bash -c "
382382
if (checkCancellationInterval) {
383383
clearInterval(checkCancellationInterval)
384384
}
385+
386+
// Return from the function after cancellation
387+
reject(new Error('Command execution cancelled'))
388+
console.log('exiting the cancellation')
389+
return
385390
}
386391
}, 100) // Check every 100ms
387392
}

0 commit comments

Comments
 (0)