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

47 lines
1019 B
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';
import Spinner from 'ink-spinner';
2025-04-19 12:38:09 -04:00
import { Colors } from '../colors.js';
2025-04-15 21:41:08 -07:00
interface LoadingIndicatorProps {
2025-04-17 18:06:21 -04:00
isLoading: boolean;
showSpinner: boolean;
2025-04-17 18:06:21 -04:00
currentLoadingPhrase: string;
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
isLoading,
showSpinner,
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
}) => {
2025-04-17 18:06:21 -04:00
if (!isLoading) {
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}>
{showSpinner && (
<Box marginRight={1}>
<Spinner type="dots" />
</Box>
)}
2025-04-19 12:38:09 -04:00
<Text color={Colors.AccentPurple}>
{currentLoadingPhrase}
{isLoading && ` (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
};