refactor: use CoreToolCallStatus in the the history data model (#19033)

This commit is contained in:
Jerop Kipruto
2026-02-13 17:20:14 -05:00
committed by GitHub
parent e7e4c68c5c
commit f87468c644
40 changed files with 322 additions and 268 deletions

View File

@@ -9,12 +9,15 @@ import {
ShellToolMessage,
type ShellToolMessageProps,
} from './ShellToolMessage.js';
import { StreamingState, ToolCallStatus } from '../../types.js';
import type { Config } from '@google/gemini-cli-core';
import { StreamingState } from '../../types.js';
import {
type Config,
SHELL_TOOL_NAME,
CoreToolCallStatus,
} from '@google/gemini-cli-core';
import { renderWithProviders } from '../../../test-utils/render.js';
import { waitFor } from '../../../test-utils/async.js';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { SHELL_TOOL_NAME } from '@google/gemini-cli-core';
import { SHELL_COMMAND_NAME, ACTIVE_SHELL_MAX_LINES } from '../../constants.js';
describe('<ShellToolMessage />', () => {
@@ -23,7 +26,7 @@ describe('<ShellToolMessage />', () => {
name: SHELL_COMMAND_NAME,
description: 'A shell command',
resultDisplay: 'Test result',
status: ToolCallStatus.Executing,
status: CoreToolCallStatus.Executing,
terminalWidth: 80,
confirmationDetails: undefined,
emphasis: 'medium',
@@ -78,10 +81,12 @@ describe('<ShellToolMessage />', () => {
});
});
it('resets focus when shell finishes', async () => {
let updateStatus: (s: ToolCallStatus) => void = () => {};
let updateStatus: (s: CoreToolCallStatus) => void = () => {};
const Wrapper = () => {
const [status, setStatus] = React.useState(ToolCallStatus.Executing);
const [status, setStatus] = React.useState(
CoreToolCallStatus.Executing,
);
updateStatus = setStatus;
return (
<ShellToolMessage
@@ -106,7 +111,7 @@ describe('<ShellToolMessage />', () => {
// Now update status to Success
await act(async () => {
updateStatus(ToolCallStatus.Success);
updateStatus(CoreToolCallStatus.Success);
});
// Should call setEmbeddedShellFocused(false) because isThisShellFocused became false
@@ -121,23 +126,23 @@ describe('<ShellToolMessage />', () => {
it.each([
[
'renders in Executing state',
{ status: ToolCallStatus.Executing },
{ status: CoreToolCallStatus.Executing },
undefined,
],
[
'renders in Success state (history mode)',
{ status: ToolCallStatus.Success },
{ status: CoreToolCallStatus.Success },
undefined,
],
[
'renders in Error state',
{ status: ToolCallStatus.Error, resultDisplay: 'Error output' },
{ status: CoreToolCallStatus.Error, resultDisplay: 'Error output' },
undefined,
],
[
'renders in Alternate Buffer mode while focused',
{
status: ToolCallStatus.Executing,
status: CoreToolCallStatus.Executing,
embeddedShellFocused: true,
activeShellPtyId: 1,
ptyId: 1,
@@ -147,7 +152,7 @@ describe('<ShellToolMessage />', () => {
[
'renders in Alternate Buffer mode while unfocused',
{
status: ToolCallStatus.Executing,
status: CoreToolCallStatus.Executing,
embeddedShellFocused: false,
activeShellPtyId: 1,
ptyId: 1,
@@ -196,7 +201,7 @@ describe('<ShellToolMessage />', () => {
availableTerminalHeight,
activeShellPtyId: 1,
ptyId: focused ? 1 : 2,
status: ToolCallStatus.Executing,
status: CoreToolCallStatus.Executing,
embeddedShellFocused: focused,
},
{ useAlternateBuffer: true },