MCPcopy Create free account
hub / github.com/code-with-antonio/nightcode / FileMentionMenu

Function FileMentionMenu

packages/cli/src/components/input-bar.tsx:208–258  ·  view source on GitHub ↗
({
  candidates,
  selectedIndex,
  scrollRef,
  onSelect,
  onExecute,
}: FileMentionMenuProps)

Source from the content-addressed store, hash-verified

206};
207
208function FileMentionMenu({
209 candidates,
210 selectedIndex,
211 scrollRef,
212 onSelect,
213 onExecute,
214}: FileMentionMenuProps) {
215 const { colors } = useTheme();
216 const visibleHeight = Math.min(candidates.length, MAX_VISIBLE_MENTIONS);
217
218 if (candidates.length === 0) {
219 return (
220 <box paddingX={1}>
221 <text attributes={TextAttributes.DIM}>No matching files or folders</text>
222 </box>
223 );
224 }
225
226 return (
227 <scrollbox ref={scrollRef} height={visibleHeight}>
228 {candidates.map((candidate, index) => {
229 const isSelected = index === selectedIndex;
230
231 return (
232 <box
233 key={candidate.path}
234 flexDirection="row"
235 paddingX={1}
236 height={1}
237 overflow="hidden"
238 backgroundColor={isSelected ? colors.selection : undefined}
239 onMouseMove={() => onSelect(index)}
240 onMouseDown={() => onExecute(index)}
241 >
242 <box flexGrow={1} flexShrink={1} overflow="hidden">
243 <text selectable={false} fg={isSelected ? "black" : "white"}>
244 {candidate.path}
245 </text>
246 </box>
247
248 <box width={8} alignItems="flex-end" flexShrink={0}>
249 <text selectable={false} fg={isSelected ? "black" : "gray"}>
250 {candidate.kind === "directory" ? "Folder" : "File"}
251 </text>
252 </box>
253 </box>
254 );
255 })}
256 </scrollbox>
257 );
258};
259
260type Props = {
261 onSubmit: (text: string) => void;

Callers

nothing calls this directly

Calls 1

useThemeFunction · 0.90

Tested by

no test coverage detected