Files
gemini-cli/packages/cli/src/ui/components/messages/ToolGroupMessage.tsx
T

55 lines
1.9 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
2025-04-15 21:41:08 -07:00
import React from 'react';
import { Box } from 'ink';
import { IndividualToolCallDisplay, ToolCallStatus } from '../../types.js';
2025-04-18 19:09:41 -04:00
import { ToolMessage } from './ToolMessage.js';
2025-04-15 21:41:08 -07:00
import { PartListUnion } from '@google/genai';
2025-04-18 19:09:41 -04:00
import { ToolConfirmationMessage } from './ToolConfirmationMessage.js';
2025-04-15 21:41:08 -07:00
interface ToolGroupMessageProps {
2025-04-17 18:06:21 -04:00
toolCalls: IndividualToolCallDisplay[];
onSubmit: (value: PartListUnion) => void;
2025-04-15 21:41:08 -07:00
}
// Main component renders the border and maps the tools using ToolMessage
2025-04-18 19:09:41 -04:00
export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({
2025-04-17 18:06:21 -04:00
toolCalls,
onSubmit,
}) => {
const hasPending = toolCalls.some((t) => t.status === ToolCallStatus.Pending);
const borderColor = hasPending ? 'yellow' : 'blue';
2025-04-15 21:41:08 -07:00
2025-04-17 18:06:21 -04:00
return (
<Box flexDirection="column" borderStyle="round" borderColor={borderColor}>
2025-04-18 10:53:16 -04:00
{toolCalls.map((tool) => (
2025-04-18 18:08:43 -04:00
<React.Fragment key={tool.callId}>
<ToolMessage
key={tool.callId} // Use callId as the key
callId={tool.callId} // Pass callId
2025-04-18 18:08:43 -04:00
name={tool.name}
description={tool.description}
resultDisplay={tool.resultDisplay}
status={tool.status}
confirmationDetails={tool.confirmationDetails} // Pass confirmationDetails
2025-04-18 18:08:43 -04:00
/>
{tool.status === ToolCallStatus.Confirming &&
tool.confirmationDetails && (
<ToolConfirmationMessage
confirmationDetails={tool.confirmationDetails}
onSubmit={onSubmit}
></ToolConfirmationMessage>
)}
</React.Fragment>
))}
2025-04-17 18:06:21 -04:00
{/* Optional: Add padding below the last item if needed,
2025-04-15 21:41:08 -07:00
though ToolMessage already has some vertical space implicitly */}
2025-04-17 18:06:21 -04:00
{/* {tools.length > 0 && <Box height={1} />} */}
</Box>
);
2025-04-15 21:41:08 -07:00
};