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

61 lines
1.7 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { ThoughtSummary } from '@gemini-cli/core';
2025-04-15 21:41:08 -07:00
import React from 'react';
import { Box, Text } from 'ink';
2025-04-19 12:38:09 -04:00
import { Colors } from '../colors.js';
import { useStreamingContext } from '../contexts/StreamingContext.js';
import { StreamingState } from '../types.js';
import { GeminiRespondingSpinner } from './GeminiRespondingSpinner.js';
2025-04-15 21:41:08 -07:00
interface LoadingIndicatorProps {
currentLoadingPhrase?: string;
2025-04-17 18:06:21 -04:00
elapsedTime: number;
2025-05-17 21:25:28 -07:00
rightContent?: React.ReactNode;
thought?: ThoughtSummary | null;
2025-04-15 21:41:08 -07:00
}
2025-04-18 19:09:41 -04:00
export const LoadingIndicator: React.FC<LoadingIndicatorProps> = ({
2025-04-17 18:06:21 -04:00
currentLoadingPhrase,
elapsedTime,
2025-05-17 21:25:28 -07:00
rightContent,
thought,
2025-04-15 21:41:08 -07:00
}) => {
const streamingState = useStreamingContext();
if (streamingState === StreamingState.Idle) {
return null;
2025-04-17 18:06:21 -04:00
}
2025-04-15 21:41:08 -07:00
const primaryText = thought?.subject || currentLoadingPhrase;
2025-04-17 18:06:21 -04:00
return (
<Box marginTop={1} paddingLeft={0} flexDirection="column">
{/* Main loading line */}
<Box>
<Box marginRight={1}>
<GeminiRespondingSpinner
nonRespondingDisplay={
streamingState === StreamingState.WaitingForConfirmation
? '⠏'
: ''
}
/>
</Box>
{primaryText && <Text color={Colors.AccentPurple}>{primaryText}</Text>}
<Text color={Colors.Gray}>
{streamingState === StreamingState.WaitingForConfirmation
? ''
: ` (esc to cancel, ${elapsedTime}s)`}
</Text>
<Box flexGrow={1}>{/* Spacer */}</Box>
{rightContent && <Box>{rightContent}</Box>}
</Box>
2025-04-17 18:06:21 -04:00
</Box>
);
2025-04-15 21:41:08 -07:00
};