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

53 lines
1.4 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, 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;
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,
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
2025-04-17 18:06:21 -04:00
return (
<Box marginTop={1} paddingLeft={0}>
<Box marginRight={1}>
<GeminiRespondingSpinner
nonRespondingDisplay={
streamingState === StreamingState.WaitingForConfirmation ? '⠏' : ''
}
/>
</Box>
{currentLoadingPhrase && (
<Text color={Colors.AccentPurple}>{currentLoadingPhrase}</Text>
)}
2025-06-05 14:35:47 -07:00
<Text color={Colors.Gray}>
{streamingState === StreamingState.WaitingForConfirmation
? ''
: ` (esc to cancel, ${elapsedTime}s)`}
2025-04-17 18:06:21 -04:00
</Text>
<Box flexGrow={1}>{/* Spacer */}</Box>
2025-05-17 21:25:28 -07:00
{rightContent && <Box>{rightContent}</Box>}
2025-04-17 18:06:21 -04:00
</Box>
);
2025-04-15 21:41:08 -07:00
};