refactor: centralize tool status symbols in constants (#7054)

This commit is contained in:
Arya Gummadi 2025-08-27 07:54:32 -07:00 committed by GitHub
parent 83a40ff9d4
commit 4c3ec1f0cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 14 deletions

View file

@ -13,6 +13,7 @@ import type {
Config,
ToolCallConfirmationDetails,
} from '@google/gemini-cli-core';
import { TOOL_STATUS } from '../../constants.js';
// Mock child components to isolate ToolGroupMessage behavior
vi.mock('./ToolMessage.js', () => ({
@ -29,14 +30,16 @@ vi.mock('./ToolMessage.js', () => ({
status: ToolCallStatus;
emphasis: string;
}) {
const statusSymbol = {
[ToolCallStatus.Success]: '✓',
[ToolCallStatus.Pending]: 'o',
[ToolCallStatus.Executing]: '⊷',
[ToolCallStatus.Confirming]: '?',
[ToolCallStatus.Canceled]: '-',
[ToolCallStatus.Error]: 'x',
}[status];
// Use the same constants as the real component
const statusSymbolMap: Record<ToolCallStatus, string> = {
[ToolCallStatus.Success]: TOOL_STATUS.SUCCESS,
[ToolCallStatus.Pending]: TOOL_STATUS.PENDING,
[ToolCallStatus.Executing]: TOOL_STATUS.EXECUTING,
[ToolCallStatus.Confirming]: TOOL_STATUS.CONFIRMING,
[ToolCallStatus.Canceled]: TOOL_STATUS.CANCELED,
[ToolCallStatus.Error]: TOOL_STATUS.ERROR,
};
const statusSymbol = statusSymbolMap[status] || '?';
return (
<Text>
MockTool[{callId}]: {statusSymbol} {name} - {description} ({emphasis})