MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / PathPicker

Function PathPicker

graph-ui/src/galaxy/ScopePathControls.tsx:18–48  ·  view source on GitHub ↗
({ nodes, onPick }: { nodes: readonly GraphNode[]; onPick: (node: GraphNode) => void })

Source from the content-addressed store, hash-verified

16
17/** A searchable list of the nodes already loaded in this scope; nothing is fetched. */
18export function PathPicker({ nodes, onPick }: { nodes: readonly GraphNode[]; onPick: (node: GraphNode) => void }) {
19 const [query, setQuery] = useState('');
20 const details = useRef<HTMLDetailsElement>(null);
21 const matches = useMemo(() => {
22 const needle = query.trim().toLocaleLowerCase();
23 // Name matches first, as in the node search: exact, prefix, anywhere, then path or qualified name.
24 // A Branch node is found by its shown name and by its name in the index (round 4, N1).
25 const rank = (node: GraphNode) => Math.min(...[graphNodeName(node), node.name].map(value => {
26 const name = value.toLocaleLowerCase();
27 return name === needle ? 0 : name.startsWith(needle) ? 1 : name.includes(needle) ? 2 : 3;
28 }));
29 return nodes.filter(node => !needle || [graphNodeName(node), node.name, node.qualified_name, nodeFilePath(node)]
30 .some(value => value?.toLocaleLowerCase().includes(needle)))
31 .sort((a, b) => rank(a) - rank(b) || graphNodeName(a).localeCompare(graphNodeName(b)) || a.id - b.id);
32 }, [nodes, query]);
33 return <details ref={details} className="atlas-graph-path-picker" onKeyDown={closeOnEscape}>
34 <summary title={text.pathToTitle}><FitLabel wide={text.pathTo} narrow={text.pathToNarrow} /></summary>
35 <div className="atlas-graph-path-menu" role="group" aria-label={text.pathToTitle}>
36 <input type="search" aria-label={text.pathSearch} placeholder={text.pathSearchPlaceholder}
37 value={query} onChange={event => setQuery(event.target.value)} />
38 <ul>{matches.slice(0, PICKER_LIMIT).map(node => <li key={node.id}>
39 <button type="button" onClick={() => {
40 onPick(node);
41 if (details.current) details.current.open = false;
42 }} title={graphNodeTitle(node)}><strong>{graphNodeName(node)}</strong><span>{nodeFilePath(node) ?? node.qualified_name ?? node.label}</span></button>
43 </li>)}</ul>
44 {matches.length === 0 && <small>{text.pathNoMatch}</small>}
45 {matches.length > PICKER_LIMIT && <small>{text.pathMore(matches.length - PICKER_LIMIT)}</small>}
46 </div>
47 </details>;
48}
49
50/** The compact step list: one line per hop or call site, stepping moves the highlight. */
51export function PathSteps({ heading, note, steps, active, nameOf, lines, onStep, onClear }: {

Callers

nothing calls this directly

Calls 4

graphNodeNameFunction · 0.90
nodeFilePathFunction · 0.90
graphNodeTitleFunction · 0.90
rankFunction · 0.70

Tested by

no test coverage detected