MCPcopy Index your code
hub / github.com/anomalyco/opencode / useCommandSlashes

Function useCommandSlashes

packages/tui/src/keymap.tsx:260–290  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

258}
259
260export function useCommandSlashes(): Accessor<readonly CommandSlashEntry[]> {
261 const keymap = useOpencodeKeymap()
262 const entries = useKeymapSelector((keymap: OpenTuiKeymap) =>
263 keymap.getCommandEntries({
264 visibility: "reachable",
265 namespace: "palette",
266 filter: isVisiblePaletteCommand,
267 }),
268 )
269
270 return createMemo<CommandSlashEntry[]>(() =>
271 entries().flatMap((entry) => {
272 const slashName = entry.command.slashName
273 if (typeof slashName !== "string" || !slashName) return []
274 const slashAliases = entry.command.slashAliases
275 return {
276 display: `/${slashName}`,
277 description:
278 typeof entry.command.desc === "string"
279 ? entry.command.desc
280 : typeof entry.command.title === "string"
281 ? entry.command.title
282 : undefined,
283 aliases: Array.isArray(slashAliases)
284 ? slashAliases.filter((alias): alias is string => typeof alias === "string").map((alias) => `/${alias}`)
285 : undefined,
286 onSelect: () => keymap.dispatchCommand(entry.command.name),
287 }
288 }),
289 )
290}

Callers 1

AutocompleteFunction · 0.90

Calls 1

entriesFunction · 0.50

Tested by

no test coverage detected