MCPcopy Create free account
hub / github.com/anus-dev/ANUS / LoadingIndicator

Function LoadingIndicator

packages/cli/src/ui/components/LoadingIndicator.tsx:26–82  ·  view source on GitHub ↗
({
  currentLoadingPhrase,
  elapsedTime,
  rightContent,
  thought,
})

Source from the content-addressed store, hash-verified

24}
25
26export const LoadingIndicator: React.FC<LoadingIndicatorProps> = ({
27 currentLoadingPhrase,
28 elapsedTime,
29 rightContent,
30 thought,
31}) => {
32 const streamingState = useStreamingContext();
33 const { columns: terminalWidth } = useTerminalSize();
34 const isNarrow = isNarrowWidth(terminalWidth);
35
36 if (streamingState === StreamingState.Idle) {
37 return null;
38 }
39
40 const primaryText = thought?.subject || currentLoadingPhrase;
41
42 const cancelAndTimerContent =
43 streamingState !== StreamingState.WaitingForConfirmation
44 ? `(esc to cancel, ${elapsedTime < 60 ? `${elapsedTime}s` : formatDuration(elapsedTime * 1000)})`
45 : null;
46
47 return (
48 <Box paddingLeft={0} flexDirection="column">
49 {/* Main loading line */}
50 <Box
51 width="100%"
52 flexDirection={isNarrow ? 'column' : 'row'}
53 alignItems={isNarrow ? 'flex-start' : 'center'}
54 >
55 <Box>
56 <Box marginRight={1}>
57 <AnusRespondingSpinner
58 spinnerType="anus"
59 nonRespondingDisplay={
60 streamingState === StreamingState.WaitingForConfirmation
61 ? '⠏'
62 : ''
63 }
64 />
65 </Box>
66 {primaryText && <Text color={Colors.LightBlue}>{primaryText}</Text>}
67 {!isNarrow && cancelAndTimerContent && (
68 <Text color={Colors.Gray}> {cancelAndTimerContent}</Text>
69 )}
70 </Box>
71 {!isNarrow && <Box flexGrow={1}>{/* Spacer */}</Box>}
72 {!isNarrow && rightContent && <Box>{rightContent}</Box>}
73 </Box>
74 {isNarrow && cancelAndTimerContent && (
75 <Box>
76 <Text color={Colors.Gray}>{cancelAndTimerContent}</Text>
77 </Box>
78 )}
79 {isNarrow && rightContent && <Box>{rightContent}</Box>}
80 </Box>
81 );
82};

Callers

nothing calls this directly

Calls 4

useStreamingContextFunction · 0.85
useTerminalSizeFunction · 0.85
isNarrowWidthFunction · 0.85
formatDurationFunction · 0.85

Tested by

no test coverage detected