mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
refactor: centralize tool status symbols in constants (#7054)
This commit is contained in:
@@ -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})
|
||||
|
||||
@@ -13,6 +13,7 @@ import { Colors } from '../../colors.js';
|
||||
import { MarkdownDisplay } from '../../utils/MarkdownDisplay.js';
|
||||
import { GeminiRespondingSpinner } from '../GeminiRespondingSpinner.js';
|
||||
import { MaxSizedBox } from '../shared/MaxSizedBox.js';
|
||||
import { TOOL_STATUS } from '../../constants.js';
|
||||
|
||||
const STATIC_HEIGHT = 1;
|
||||
const RESERVED_LINE_COUNT = 5; // for tool name, status, padding etc.
|
||||
@@ -119,28 +120,28 @@ const ToolStatusIndicator: React.FC<ToolStatusIndicatorProps> = ({
|
||||
}) => (
|
||||
<Box minWidth={STATUS_INDICATOR_WIDTH}>
|
||||
{status === ToolCallStatus.Pending && (
|
||||
<Text color={Colors.AccentGreen}>o</Text>
|
||||
<Text color={Colors.AccentGreen}>{TOOL_STATUS.PENDING}</Text>
|
||||
)}
|
||||
{status === ToolCallStatus.Executing && (
|
||||
<GeminiRespondingSpinner
|
||||
spinnerType="toggle"
|
||||
nonRespondingDisplay={'⊷'}
|
||||
nonRespondingDisplay={TOOL_STATUS.EXECUTING}
|
||||
/>
|
||||
)}
|
||||
{status === ToolCallStatus.Success && (
|
||||
<Text color={Colors.AccentGreen}>✓</Text>
|
||||
<Text color={Colors.AccentGreen}>{TOOL_STATUS.SUCCESS}</Text>
|
||||
)}
|
||||
{status === ToolCallStatus.Confirming && (
|
||||
<Text color={Colors.AccentYellow}>?</Text>
|
||||
<Text color={Colors.AccentYellow}>{TOOL_STATUS.CONFIRMING}</Text>
|
||||
)}
|
||||
{status === ToolCallStatus.Canceled && (
|
||||
<Text color={Colors.AccentYellow} bold>
|
||||
-
|
||||
{TOOL_STATUS.CANCELED}
|
||||
</Text>
|
||||
)}
|
||||
{status === ToolCallStatus.Error && (
|
||||
<Text color={Colors.AccentRed} bold>
|
||||
x
|
||||
{TOOL_STATUS.ERROR}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -19,3 +19,13 @@ export const SHELL_COMMAND_NAME = 'Shell Command';
|
||||
export const SCREEN_READER_USER_PREFIX = 'User: ';
|
||||
|
||||
export const SCREEN_READER_MODEL_PREFIX = 'Model: ';
|
||||
|
||||
// Tool status symbols used in ToolMessage component
|
||||
export const TOOL_STATUS = {
|
||||
SUCCESS: '✓',
|
||||
PENDING: 'o',
|
||||
EXECUTING: '⊷',
|
||||
CONFIRMING: '?',
|
||||
CANCELED: '-',
|
||||
ERROR: 'x',
|
||||
} as const;
|
||||
|
||||
Reference in New Issue
Block a user