Provides slash-command autocomplete capabilities via a stateless fetch helper, a debounced React hook, and a cached registry hook for deduped session-scoped command lookups. ## Key Components | Export | Kind | Description | |---|---|---| | `fetchSlashCommands` | `async function` | Stateless fetch wrapper. Resolves `commandsUrl` against `window.location.origin`, appends `?q=prefix`, uses `embedAuthedFetch` for bearer/cookie auth. Returns `SlashCommandSummary[]` or `[]` on non-2xx; re-throws `AbortError` so react-query treats cancellation correctly. | | `useSlashCommands` | React hook | Debounced (150 ms), cancellable hook. Returns `{ commands, loading }`. Clears state when `prefix` is `null`; aborts in-flight requests on dependency change or unmount. | | `useSlashCommandRegistry` | React hook | Full registry fetch (empty prefix) backed by react-query with `staleTime`/`gcTime: Infinity`. All consumers in one chat surface share a single cache entry. Accepts `{ enabled }` to gate the fetch (e.g. skip in Mingo mode). Returns `{ commands, loading, loaded }`. | | `SlashCommandSummary` | Re-exported type | Canonical type from `component.types`; re-exported so callers avoid reaching into the internal types path. | | `SlashCommandSummaryAction` | Re-exported type | Action shape within a `SlashCommandSummary`. | | `SlashCommandActionId` | Re-exported type | Discriminated identifier for a command action. | ## Usage Example ```typescript import { useSlashCommands, useSlashCommandRegistry, fetchSlashCommands, } from "@flamingo-stack/openframe-frontend-core/components/chat/hooks"; // 1. Debounced autocomplete — renders as the user types "/…" function SlashAutocomplete({ prefix }: { prefix: string | null }) { const { commandsUrl } = useChatRuntime().endpoints; const { commands, loading } = useSlashCommands(prefix, commandsUrl); if (loading) return ; return ; } // 2. Session-scoped registry — deduped across all consumers function WelcomePanel() { const { commandsUrl } = useChatRuntime().endpoints; const { commands, loaded } = useSlashCommandRegistry(commandsUrl, { enabled: activeMode === "guide", }); if (!loaded) return ; return ; } // 3. One-shot fetch (e.g. SSE adapter, outside React) const ac = new AbortController(); const cmds = await fetchSlashCommands("dep", ac.signal, commandsUrl); ``` ## Notes - `commandsUrl` is **always required** — sourced from `useChatRuntime().endpoints.commandsUrl`. No default exists. - Auth is handled transparently by [`embedAuthedFetch`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/utils/embed-authed-fetch.ts); no host-side `fetch` patching needed. - Any non-abort failure degrades silently to an empty list — a flaky commands endpoint never breaks chat or blocks the welcome UI in a loading state.