blob: 5fb9b32f841bce90d8961c3c49caefeae2f60732 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import React from 'react';
import type { HistoryItem } from '../types.js';
import { UserMessage } from './messages/UserMessage.js';
import { GeminiMessage } from './messages/GeminiMessage.js';
import { InfoMessage } from './messages/InfoMessage.js';
import { ErrorMessage } from './messages/ErrorMessage.js';
import { ToolGroupMessage } from './messages/ToolGroupMessage.js';
import { PartListUnion } from '@google/genai';
import { GeminiMessageContent } from './messages/GeminiMessageContent.js';
import { Box } from 'ink';
interface HistoryItemDisplayProps {
item: HistoryItem;
onSubmit: (value: PartListUnion) => void;
}
export const HistoryItemDisplay: React.FC<HistoryItemDisplayProps> = ({
item,
onSubmit,
}) => (
<Box flexDirection="column" key={item.id}>
{/* Render standard message types */}
{item.type === 'user' && <UserMessage text={item.text} />}
{item.type === 'gemini' && <GeminiMessage text={item.text} />}
{item.type === 'gemini_content' && (
<GeminiMessageContent text={item.text} />
)}
{item.type === 'info' && <InfoMessage text={item.text} />}
{item.type === 'error' && <ErrorMessage text={item.text} />}
{item.type === 'tool_group' && (
<ToolGroupMessage
toolCalls={item.tools}
groupId={item.id}
onSubmit={onSubmit}
/>
)}
</Box>
);
|