Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ describe('<ShellToolMessage />', () => {
{ status: CoreToolCallStatus.Error, resultDisplay: 'Error output' },
undefined,
],
[
'renders in Cancelled state with partial output',
{
status: CoreToolCallStatus.Cancelled,
resultDisplay: 'Partial output before cancellation',
},
undefined,
],
[
'renders in Alternate Buffer mode while focused',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ exports[`<ShellToolMessage /> > Snapshots > renders in Alternate Buffer mode whi
"
`;

exports[`<ShellToolMessage /> > Snapshots > renders in Cancelled state with partial output 1`] = `
"╭──────────────────────────────────────────────────────────────────────────────╮
│ - Shell Command A shell command │
│ │
│ Partial output before cancellation │
"
`;

exports[`<ShellToolMessage /> > Snapshots > renders in Error state 1`] = `
"╭──────────────────────────────────────────────────────────────────────────────╮
│ x Shell Command A shell command │
Expand Down
15 changes: 13 additions & 2 deletions packages/core/src/scheduler/state-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,24 @@ export class SchedulerStateManager {
}
}

// Capture any existing live output so it isn't lost when forcing cancellation.
let existingOutput: ToolResultDisplay | undefined = undefined;
if (call.status === CoreToolCallStatus.Executing && call.liveOutput) {
existingOutput = call.liveOutput;
}

if (isToolCallResponseInfo(reason)) {
const finalResponse = { ...reason };
if (!finalResponse.resultDisplay && existingOutput) {
finalResponse.resultDisplay = existingOutput;
}

return {
request: call.request,
tool: call.tool,
invocation: call.invocation,
status: CoreToolCallStatus.Cancelled,
response: reason,
response: finalResponse,
durationMs: startTime ? Date.now() - startTime : undefined,
outcome: call.outcome,
schedulerId: call.schedulerId,
Expand All @@ -508,7 +519,7 @@ export class SchedulerStateManager {
},
},
],
resultDisplay,
resultDisplay: resultDisplay ?? existingOutput,
error: undefined,
errorType: undefined,
contentLength: errorMessage.length,
Expand Down
Loading