MCPcopy Create free account
hub / github.com/agent-tower/core / SlashCommandList

Function SlashCommandList

packages/web/src/components/task/SlashCommandList.tsx:17–76  ·  view source on GitHub ↗
({
  commands,
  selectedIndex,
  query,
  hasCatalog,
  title = 'Slash Commands',
  queryPrefix = '/',
  emptyCatalogMessage = 'No slash commands catalog for this agent yet.',
  emptyQueryMessage,
  insertionHint = 'Enter / Tab to insert',
  compact = false,
  onSelect,
}: SlashCommandListProps)

Source from the content-addressed store, hash-verified

15}
16
17export function SlashCommandList({
18 commands,
19 selectedIndex,
20 query,
21 hasCatalog,
22 title = 'Slash Commands',
23 queryPrefix = '/',
24 emptyCatalogMessage = 'No slash commands catalog for this agent yet.',
25 emptyQueryMessage,
26 insertionHint = 'Enter / Tab to insert',
27 compact = false,
28 onSelect,
29}: SlashCommandListProps) {
30 const listPadding = compact ? 'px-1.5 pb-1.5' : 'px-2 pb-2'
31 const itemPadding = compact ? 'px-2 py-1.5' : 'px-2.5 py-2'
32 const maxHeight = compact ? 'max-h-36' : 'max-h-48'
33
34 return (
35 <div className={compact ? 'pt-1.5' : 'pt-2'}>
36 <div className={`mb-1 flex items-center justify-between ${compact ? 'px-2 pt-0.5' : 'px-3 pt-1'}`}>
37 <span className="text-xs font-medium text-muted-foreground">{title}</span>
38 <span className="text-xs text-muted-foreground">{insertionHint}</span>
39 </div>
40
41 {commands.length === 0 ? (
42 <div className={`${compact ? 'px-2 pb-2 pt-1.5 text-xs' : 'px-3 pb-3 pt-2 text-xs'} text-muted-foreground`}>
43 {hasCatalog ? (emptyQueryMessage ?? `No matches for ${queryPrefix}${query}`) : emptyCatalogMessage}
44 </div>
45 ) : (
46 <div className={`${listPadding} ${maxHeight} overflow-y-auto`}>
47 {commands.map((command, index) => (
48 <button
49 key={command.command}
50 type="button"
51 onMouseDown={(event) => event.preventDefault()}
52 onClick={() => onSelect(command)}
53 className={`w-full rounded-lg border text-left transition-colors ${
54 index === selectedIndex
55 ? 'border-border bg-muted/50'
56 : 'border-transparent hover:border-border hover:bg-accent'
57 } ${itemPadding}`}
58 >
59 <div className="flex items-center gap-2">
60 <div className="font-mono text-[13px] text-foreground">{command.command}</div>
61 {command.kind && command.kind !== 'builtin' ? (
62 <span className="rounded-full border border-border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.12em] text-muted-foreground">
63 {command.scope ? `${command.scope} ${command.kind}` : command.kind}
64 </span>
65 ) : null}
66 </div>
67 <div className={`${compact ? 'mt-0.5 text-xs' : 'mt-1 text-xs'} text-muted-foreground`}>
68 {command.description}
69 </div>
70 </button>
71 ))}
72 </div>
73 )}
74 </div>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected