mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
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>
This commit is contained in:
@@ -137,6 +137,14 @@ describe('<ShellToolMessage />', () => {
|
|||||||
{ status: CoreToolCallStatus.Error, resultDisplay: 'Error output' },
|
{ status: CoreToolCallStatus.Error, resultDisplay: 'Error output' },
|
||||||
undefined,
|
undefined,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'renders in Cancelled state with partial output',
|
||||||
|
{
|
||||||
|
status: CoreToolCallStatus.Cancelled,
|
||||||
|
resultDisplay: 'Partial output before cancellation',
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'renders in Alternate Buffer mode while focused',
|
'renders in Alternate Buffer mode while focused',
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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`] = `
|
exports[`<ShellToolMessage /> > Snapshots > renders in Error state 1`] = `
|
||||||
"╭──────────────────────────────────────────────────────────────────────────────╮
|
"╭──────────────────────────────────────────────────────────────────────────────╮
|
||||||
│ x Shell Command A shell command │
|
│ x Shell Command A shell command │
|
||||||
|
|||||||
@@ -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)) {
|
if (isToolCallResponseInfo(reason)) {
|
||||||
|
const finalResponse = { ...reason };
|
||||||
|
if (!finalResponse.resultDisplay) {
|
||||||
|
finalResponse.resultDisplay = resultDisplay ?? existingOutput;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
request: call.request,
|
request: call.request,
|
||||||
tool: call.tool,
|
tool: call.tool,
|
||||||
invocation: call.invocation,
|
invocation: call.invocation,
|
||||||
status: CoreToolCallStatus.Cancelled,
|
status: CoreToolCallStatus.Cancelled,
|
||||||
response: reason,
|
response: finalResponse,
|
||||||
durationMs: startTime ? Date.now() - startTime : undefined,
|
durationMs: startTime ? Date.now() - startTime : undefined,
|
||||||
outcome: call.outcome,
|
outcome: call.outcome,
|
||||||
schedulerId: call.schedulerId,
|
schedulerId: call.schedulerId,
|
||||||
@@ -508,7 +519,7 @@ export class SchedulerStateManager {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
resultDisplay,
|
resultDisplay: resultDisplay ?? existingOutput,
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorType: undefined,
|
errorType: undefined,
|
||||||
contentLength: errorMessage.length,
|
contentLength: errorMessage.length,
|
||||||
|
|||||||
Reference in New Issue
Block a user