automagik-cli
Version:
Automagik CLI - A powerful command-line interface for interacting with Automagik Hive multi-agent AI systems
32 lines (31 loc) • 1.63 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import Spinner from 'ink-spinner';
import { StreamingState } from '../types.js';
import { appConfig } from '../../config/settings.js';
export const LoadingIndicator = ({ currentLoadingPhrase, elapsedTime, streamingState, }) => {
const isLoading = streamingState === StreamingState.Connecting ||
streamingState === StreamingState.Waiting ||
streamingState === StreamingState.Responding;
const isStreaming = streamingState === StreamingState.Responding;
if (!isLoading) {
return null;
}
const formatElapsedTime = (ms) => {
const seconds = Math.floor(ms / 1000);
return `${seconds}s`;
};
const getStreamingStateText = () => {
switch (streamingState) {
case StreamingState.Connecting:
return 'Connecting to API...';
case StreamingState.Waiting:
return 'Waiting for response...';
case StreamingState.Responding:
return 'Receiving response...';
default:
return currentLoadingPhrase;
}
};
return (_jsx(Box, { marginY: 1, children: _jsxs(Box, { alignItems: "center", children: [appConfig.enableSpinner && (_jsxs(_Fragment, { children: [_jsx(Spinner, { type: "dots" }), _jsx(Text, { children: " " })] })), _jsx(Text, { color: isStreaming ? 'green' : 'yellow', children: getStreamingStateText() }), elapsedTime > 0 && (_jsxs(Text, { color: "gray", children: [" (", formatElapsedTime(elapsedTime), ")"] }))] }) }));
};