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

Function SuggestionsDisplay

packages/cli/src/ui/components/SuggestionsDisplay.tsx:28–103  ·  view source on GitHub ↗
({
  suggestions,
  activeIndex,
  isLoading,
  width,
  scrollOffset,
  userInput,
}: SuggestionsDisplayProps)

Source from the content-addressed store, hash-verified

26export const MAX_SUGGESTIONS_TO_SHOW = 8;
27
28export function SuggestionsDisplay({
29 suggestions,
30 activeIndex,
31 isLoading,
32 width,
33 scrollOffset,
34 userInput,
35}: SuggestionsDisplayProps) {
36 if (isLoading) {
37 return (
38 <Box paddingX={1} width={width}>
39 <Text color="gray">Loading suggestions...</Text>
40 </Box>
41 );
42 }
43
44 if (suggestions.length === 0) {
45 return null; // Don't render anything if there are no suggestions
46 }
47
48 // Calculate the visible slice based on scrollOffset
49 const startIndex = scrollOffset;
50 const endIndex = Math.min(
51 scrollOffset + MAX_SUGGESTIONS_TO_SHOW,
52 suggestions.length,
53 );
54 const visibleSuggestions = suggestions.slice(startIndex, endIndex);
55
56 return (
57 <Box flexDirection="column" paddingX={1} width={width}>
58 {scrollOffset > 0 && <Text color={Colors.Foreground}>▲</Text>}
59
60 {visibleSuggestions.map((suggestion, index) => {
61 const originalIndex = startIndex + index;
62 const isActive = originalIndex === activeIndex;
63 const textColor = isActive ? Colors.AccentPurple : Colors.Gray;
64 const labelElement = (
65 <PrepareLabel
66 label={suggestion.label}
67 matchedIndex={suggestion.matchedIndex}
68 userInput={userInput}
69 textColor={textColor}
70 />
71 );
72
73 return (
74 <Box key={`${suggestion.value}-${originalIndex}`} width={width}>
75 <Box flexDirection="row">
76 {userInput.startsWith('/') ? (
77 // only use box model for (/) command mode
78 <Box width={20} flexShrink={0}>
79 {labelElement}
80 </Box>
81 ) : (
82 labelElement
83 )}
84 {suggestion.description ? (
85 <Box flexGrow={1}>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected