automagik-cli
Version:
Automagik CLI - A powerful command-line interface for interacting with Automagik Hive multi-agent AI systems
37 lines (36 loc) • 2.02 kB
JavaScript
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import Spinner from 'ink-spinner';
import { StreamingState } from '../types.js';
import { Colors } from '../colors.js';
export const LoadingIndicator = ({ currentLoadingPhrase, elapsedTime, thought, streamingState, }) => {
// Show loading if we have a current phrase or if we're not idle
const isLoading = streamingState !== StreamingState.Idle && (currentLoadingPhrase ||
streamingState === StreamingState.Connecting ||
streamingState === StreamingState.Waiting ||
streamingState === StreamingState.Responding);
const isStreaming = streamingState === StreamingState.Responding;
if (!isLoading && !thought) {
return null;
}
const formatElapsedTime = (ms) => {
const seconds = Math.floor(ms / 1000);
return `${seconds}s`;
};
const getStreamingStateText = () => {
if (currentLoadingPhrase) {
return currentLoadingPhrase;
}
switch (streamingState) {
case StreamingState.Connecting:
return '🔗 Connecting to automagik...';
case StreamingState.Waiting:
return '⏳ Waiting for response...';
case StreamingState.Responding:
return '📥 Receiving response...';
default:
return '🤔 Thinking...';
}
};
return (_jsxs(Box, { marginY: 1, flexDirection: "column", children: [thought && (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { color: Colors.Comment, italic: true, children: ["\uD83D\uDCAD ", thought] }) })), isLoading && (_jsxs(Box, { alignItems: "center", children: [_jsx(Spinner, { type: "dots" }), _jsx(Text, { children: " " }), _jsx(Text, { color: isStreaming ? Colors.AccentGreen : Colors.AccentYellow, children: getStreamingStateText() }), elapsedTime > 0 && (_jsxs(Text, { color: Colors.Gray, children: [" (", formatElapsedTime(elapsedTime), ")"] }))] }))] }));
};