Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 13 additions & 12 deletions packages/cli/src/nonInteractiveCli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
uiTelemetryService,
FatalInputError,
CoreEvent,
CoreToolCallStatus,
} from '@google/gemini-cli-core';
import type { Part } from '@google/genai';
import { runNonInteractive } from './nonInteractiveCli.js';
Expand Down Expand Up @@ -327,7 +328,7 @@ describe('runNonInteractive', () => {
const toolResponse: Part[] = [{ text: 'Tool response' }];
mockSchedulerSchedule.mockResolvedValue([
{
status: 'success',
status: CoreToolCallStatus.Success,
request: {
callId: 'tool-1',
name: 'testTool',
Expand Down Expand Up @@ -403,7 +404,7 @@ describe('runNonInteractive', () => {
// 2. Mock the execution of the tools. We just need them to succeed.
mockSchedulerSchedule.mockResolvedValue([
{
status: 'success',
status: CoreToolCallStatus.Success,
request: toolCallEvent.value, // This is generic enough for both calls
tool: {} as AnyDeclarativeTool,
invocation: {} as AnyToolInvocation,
Expand Down Expand Up @@ -469,7 +470,7 @@ describe('runNonInteractive', () => {
};
mockSchedulerSchedule.mockResolvedValue([
{
status: 'error',
status: CoreToolCallStatus.Error,
request: {
callId: 'tool-1',
name: 'errorTool',
Expand Down Expand Up @@ -573,7 +574,7 @@ describe('runNonInteractive', () => {
};
mockSchedulerSchedule.mockResolvedValue([
{
status: 'error',
status: CoreToolCallStatus.Error,
request: {
callId: 'tool-1',
name: 'nonexistentTool',
Expand Down Expand Up @@ -748,7 +749,7 @@ describe('runNonInteractive', () => {
const toolResponse: Part[] = [{ text: 'Tool executed successfully' }];
mockSchedulerSchedule.mockResolvedValue([
{
status: 'success',
status: CoreToolCallStatus.Success,
request: {
callId: 'tool-1',
name: 'testTool',
Expand Down Expand Up @@ -1344,7 +1345,7 @@ describe('runNonInteractive', () => {
const toolResponse: Part[] = [{ text: 'file.txt' }];
mockSchedulerSchedule.mockResolvedValue([
{
status: 'success',
status: CoreToolCallStatus.Success,
request: {
callId: 'tool-shell-1',
name: 'ShellTool',
Expand Down Expand Up @@ -1543,7 +1544,7 @@ describe('runNonInteractive', () => {

mockSchedulerSchedule.mockResolvedValue([
{
status: 'success',
status: CoreToolCallStatus.Success,
request: toolCallEvent.value,
tool: {} as AnyDeclarativeTool,
invocation: {} as AnyToolInvocation,
Expand Down Expand Up @@ -1735,7 +1736,7 @@ describe('runNonInteractive', () => {
};
mockSchedulerSchedule.mockResolvedValue([
{
status: 'success',
status: CoreToolCallStatus.Success,
request: toolCallEvent.value,
tool: {} as AnyDeclarativeTool,
invocation: {} as AnyToolInvocation,
Expand Down Expand Up @@ -1818,7 +1819,7 @@ describe('runNonInteractive', () => {
// Mock tool execution returning STOP_EXECUTION
mockSchedulerSchedule.mockResolvedValue([
{
status: 'error',
status: CoreToolCallStatus.Error,
request: toolCallEvent.value,
tool: {} as AnyDeclarativeTool,
invocation: {} as AnyToolInvocation,
Expand Down Expand Up @@ -1880,7 +1881,7 @@ describe('runNonInteractive', () => {

mockSchedulerSchedule.mockResolvedValue([
{
status: 'error',
status: CoreToolCallStatus.Error,
request: toolCallEvent.value,
tool: {} as AnyDeclarativeTool,
invocation: {} as AnyToolInvocation,
Expand Down Expand Up @@ -1944,7 +1945,7 @@ describe('runNonInteractive', () => {

mockSchedulerSchedule.mockResolvedValue([
{
status: 'error',
status: CoreToolCallStatus.Error,
request: toolCallEvent.value,
tool: {} as AnyDeclarativeTool,
invocation: {} as AnyToolInvocation,
Expand Down Expand Up @@ -2187,7 +2188,7 @@ describe('runNonInteractive', () => {
// Mock the scheduler to return a cancelled status
mockSchedulerSchedule.mockResolvedValue([
{
status: 'cancelled',
status: CoreToolCallStatus.Cancelled,
request: toolCallEvent.value,
tool: {} as AnyDeclarativeTool,
invocation: {} as AnyToolInvocation,
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/ui/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { renderWithProviders } from '../test-utils/render.js';
import { Text, useIsScreenReaderEnabled, type DOMElement } from 'ink';
import { App } from './App.js';
import { type UIState } from './contexts/UIStateContext.js';
import { StreamingState, ToolCallStatus } from './types.js';
import { makeFakeConfig } from '@google/gemini-cli-core';
import { StreamingState } from './types.js';
import { makeFakeConfig, CoreToolCallStatus } from '@google/gemini-cli-core';

vi.mock('ink', async (importOriginal) => {
const original = await importOriginal<typeof import('ink')>();
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('App', () => {
callId: 'call-1',
name: 'ls',
description: 'list directory',
status: ToolCallStatus.Confirming,
status: CoreToolCallStatus.AwaitingApproval,
resultDisplay: '',
confirmationDetails: {
type: 'exec' as const,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/ui/AppContainer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
type ResumedSessionData,
AuthType,
type AgentDefinition,
CoreToolCallStatus,
} from '@google/gemini-cli-core';

// Mock coreEvents
Expand Down Expand Up @@ -1412,7 +1413,7 @@ describe('AppContainer State Management', () => {
name: 'run_shell_command',
args: { command: 'ls > out' },
},
status: 'executing',
status: CoreToolCallStatus.Executing,
} as unknown as TrackedToolCall,
],
activePtyId: 'pty-1',
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/src/ui/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
import { ConfigContext } from './contexts/ConfigContext.js';
import {
type HistoryItem,
ToolCallStatus,
type HistoryItemWithoutId,
type HistoryItemToolGroup,
AuthState,
Expand Down Expand Up @@ -79,6 +78,7 @@ import {
type ConsentRequestPayload,
type AgentsDiscoveredPayload,
ChangeAuthRequestedError,
CoreToolCallStatus,
} from '@google/gemini-cli-core';
import { validateAuthMethod } from '../config/auth.js';
import process from 'node:process';
Expand Down Expand Up @@ -161,7 +161,7 @@ function isToolExecuting(pendingHistoryItems: HistoryItemWithoutId[]) {
return pendingHistoryItems.some((item) => {
if (item && item.type === 'tool_group') {
return item.tools.some(
(tool) => ToolCallStatus.Executing === tool.status,
(tool) => CoreToolCallStatus.Executing === tool.status,
);
}
return false;
Expand All @@ -174,7 +174,9 @@ function isToolAwaitingConfirmation(
return pendingHistoryItems
.filter((item): item is HistoryItemToolGroup => item.type === 'tool_group')
.some((item) =>
item.tools.some((tool) => ToolCallStatus.Confirming === tool.status),
item.tools.some(
(tool) => CoreToolCallStatus.AwaitingApproval === tool.status,
),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
} from '../../test-utils/render.js';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { AlternateBufferQuittingDisplay } from './AlternateBufferQuittingDisplay.js';
import { ToolCallStatus } from '../types.js';
import type { HistoryItem, HistoryItemWithoutId } from '../types.js';
import { Text } from 'ink';
import { CoreToolCallStatus } from '@google/gemini-cli-core';

vi.mock('../utils/terminalSetup.js', () => ({
getTerminalProgram: () => null,
Expand Down Expand Up @@ -51,7 +51,7 @@ const mockHistory: HistoryItem[] = [
callId: 'call1',
name: 'tool1',
description: 'Description for tool 1',
status: ToolCallStatus.Success,
status: CoreToolCallStatus.Success,
resultDisplay: undefined,
confirmationDetails: undefined,
},
Expand All @@ -65,7 +65,7 @@ const mockHistory: HistoryItem[] = [
callId: 'call2',
name: 'tool2',
description: 'Description for tool 2',
status: ToolCallStatus.Success,
status: CoreToolCallStatus.Success,
resultDisplay: undefined,
confirmationDetails: undefined,
},
Expand All @@ -81,7 +81,7 @@ const mockPendingHistoryItems: HistoryItemWithoutId[] = [
callId: 'call3',
name: 'tool3',
description: 'Description for tool 3',
status: ToolCallStatus.Pending,
status: CoreToolCallStatus.Scheduled,
resultDisplay: undefined,
confirmationDetails: undefined,
},
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('AlternateBufferQuittingDisplay', () => {
callId: 'call4',
name: 'confirming_tool',
description: 'Confirming tool description',
status: ToolCallStatus.Confirming,
status: CoreToolCallStatus.AwaitingApproval,
resultDisplay: undefined,
confirmationDetails: {
type: 'info',
Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/ui/components/Composer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ vi.mock('../contexts/VimModeContext.js', () => ({
vimMode: 'INSERT',
})),
}));
import { ApprovalMode, tokenLimit } from '@google/gemini-cli-core';
import {
ApprovalMode,
tokenLimit,
CoreToolCallStatus,
} from '@google/gemini-cli-core';
import type { Config } from '@google/gemini-cli-core';
import { StreamingState, ToolCallStatus } from '../types.js';
import { StreamingState } from '../types.js';
import { TransientMessageType } from '../../utils/events.js';
import type { LoadedSettings } from '../../config/settings.js';
import type { SessionMetrics } from '../contexts/SessionContext.js';
Expand Down Expand Up @@ -426,7 +430,7 @@ describe('Composer', () => {
callId: 'call-1',
name: 'edit',
description: 'edit file',
status: ToolCallStatus.Confirming,
status: CoreToolCallStatus.AwaitingApproval,
resultDisplay: undefined,
confirmationDetails: undefined,
},
Expand Down
16 changes: 9 additions & 7 deletions packages/cli/src/ui/components/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

import { useState, useEffect, useMemo } from 'react';
import { Box, Text, useIsScreenReaderEnabled } from 'ink';
import { ApprovalMode, tokenLimit } from '@google/gemini-cli-core';
import {
ApprovalMode,
tokenLimit,
CoreToolCallStatus,
} from '@google/gemini-cli-core';
import { LoadingIndicator } from './LoadingIndicator.js';
import { StatusDisplay } from './StatusDisplay.js';
import { ToastDisplay, shouldShowToast } from './ToastDisplay.js';
Expand All @@ -30,11 +34,7 @@ import { useVimMode } from '../contexts/VimModeContext.js';
import { useConfig } from '../contexts/ConfigContext.js';
import { useSettings } from '../contexts/SettingsContext.js';
import { useAlternateBuffer } from '../hooks/useAlternateBuffer.js';
import {
StreamingState,
type HistoryItemToolGroup,
ToolCallStatus,
} from '../types.js';
import { StreamingState, type HistoryItemToolGroup } from '../types.js';
import { ConfigInitDisplay } from '../components/ConfigInitDisplay.js';
import { TodoTray } from './messages/Todo.js';
import { getInlineThinkingMode } from '../utils/inlineThinkingMode.js';
Expand Down Expand Up @@ -67,7 +67,9 @@ export const Composer = ({ isFocused = true }: { isFocused?: boolean }) => {
(item): item is HistoryItemToolGroup => item.type === 'tool_group',
)
.some((item) =>
item.tools.some((tool) => tool.status === ToolCallStatus.Confirming),
item.tools.some(
(tool) => tool.status === CoreToolCallStatus.AwaitingApproval,
),
),
[uiState.pendingHistoryItems],
);
Expand Down
11 changes: 6 additions & 5 deletions packages/cli/src/ui/components/HistoryItemDisplay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

import { describe, it, expect, vi } from 'vitest';
import { HistoryItemDisplay } from './HistoryItemDisplay.js';
import { type HistoryItem, ToolCallStatus } from '../types.js';
import { type HistoryItem } from '../types.js';
import { MessageType } from '../types.js';
import { SessionStatsProvider } from '../contexts/SessionContext.js';
import type {
Config,
ToolExecuteConfirmationDetails,
import {
type Config,
type ToolExecuteConfirmationDetails,
CoreToolCallStatus,
} from '@google/gemini-cli-core';
import { ToolGroupMessage } from './messages/ToolGroupMessage.js';
import { renderWithProviders } from '../../test-utils/render.js';
Expand Down Expand Up @@ -203,7 +204,7 @@ describe('<HistoryItemDisplay />', () => {
name: 'run_shell_command',
description: 'Run a shell command',
resultDisplay: 'blank',
status: ToolCallStatus.Confirming,
status: CoreToolCallStatus.AwaitingApproval,
confirmationDetails: {
type: 'exec',
title: 'Run Shell Command',
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/ui/components/MainContent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import { Box, Text } from 'ink';
import { act, useState, type JSX } from 'react';
import { useAlternateBuffer } from '../hooks/useAlternateBuffer.js';
import { ToolCallStatus } from '../types.js';
import { SHELL_COMMAND_NAME } from '../constants.js';
import {
UIStateContext,
useUIState,
type UIState,
} from '../contexts/UIStateContext.js';
import { CoreToolCallStatus } from '@google/gemini-cli-core';

// Mock dependencies
vi.mock('../contexts/SettingsContext.js', async () => {
Expand Down Expand Up @@ -264,7 +264,7 @@ describe('MainContent', () => {
{
callId: 'call_1',
name: SHELL_COMMAND_NAME,
status: ToolCallStatus.Executing,
status: CoreToolCallStatus.Executing,
description: 'Running a long command...',
// 20 lines of output.
// Default max is 15, so Line 1-5 will be truncated/scrolled out if not expanded.
Expand Down
Loading
Loading