Skip to content

Commit f20e451

Browse files
fix(ui): add partial output to cancelled shell UI (#21178)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 0228c2b commit f20e451

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

packages/cli/src/ui/components/messages/ShellToolMessage.test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ describe('<ShellToolMessage />', () => {
137137
{ status: CoreToolCallStatus.Error, resultDisplay: 'Error output' },
138138
undefined,
139139
],
140+
[
141+
'renders in Cancelled state with partial output',
142+
{
143+
status: CoreToolCallStatus.Cancelled,
144+
resultDisplay: 'Partial output before cancellation',
145+
},
146+
undefined,
147+
],
140148
[
141149
'renders in Alternate Buffer mode while focused',
142150
{

packages/cli/src/ui/components/messages/__snapshots__/ShellToolMessage.test.tsx.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ exports[`<ShellToolMessage /> > Snapshots > renders in Alternate Buffer mode whi
309309
"
310310
`;
311311

312+
exports[`<ShellToolMessage /> > Snapshots > renders in Cancelled state with partial output 1`] = `
313+
"╭──────────────────────────────────────────────────────────────────────────────╮
314+
│ - Shell Command A shell command │
315+
│ │
316+
│ Partial output before cancellation │
317+
"
318+
`;
319+
312320
exports[`<ShellToolMessage /> > Snapshots > renders in Error state 1`] = `
313321
"╭──────────────────────────────────────────────────────────────────────────────╮
314322
│ x Shell Command A shell command │

packages/core/src/scheduler/state-manager.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,24 @@ export class SchedulerStateManager {
477477
}
478478
}
479479

480+
// Capture any existing live output so it isn't lost when forcing cancellation.
481+
let existingOutput: ToolResultDisplay | undefined = undefined;
482+
if (call.status === CoreToolCallStatus.Executing && call.liveOutput) {
483+
existingOutput = call.liveOutput;
484+
}
485+
480486
if (isToolCallResponseInfo(reason)) {
487+
const finalResponse = { ...reason };
488+
if (!finalResponse.resultDisplay) {
489+
finalResponse.resultDisplay = resultDisplay ?? existingOutput;
490+
}
491+
481492
return {
482493
request: call.request,
483494
tool: call.tool,
484495
invocation: call.invocation,
485496
status: CoreToolCallStatus.Cancelled,
486-
response: reason,
497+
response: finalResponse,
487498
durationMs: startTime ? Date.now() - startTime : undefined,
488499
outcome: call.outcome,
489500
schedulerId: call.schedulerId,
@@ -508,7 +519,7 @@ export class SchedulerStateManager {
508519
},
509520
},
510521
],
511-
resultDisplay,
522+
resultDisplay: resultDisplay ?? existingOutput,
512523
error: undefined,
513524
errorType: undefined,
514525
contentLength: errorMessage.length,

0 commit comments

Comments
 (0)