Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Align Assistant slash command empty state

rcourtmandb6694774f43
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 0a3385abbd..349c70a0b1 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -393,7 +393,7 @@ remain visible/inspectable.
icon controls or ambiguous short labels.
The slash command autocomplete is a command-discovery surface, not just a
text shortcut hint. The referenced OpenCode source at fetched `origin/dev`
- commit `e82542b8023a8374f29c23b70ec019c8f256354e` advertises session
+ commit `914a643` advertises session
commands such as `/models`, `/new`, `/sessions`, `/compact`, `/export`, and
`/connect` in `packages/tui/src/feature-plugins/home/tips-view.tsx` lines
179-192, while each command registration carries a command title, category,
@@ -402,7 +402,16 @@ remain visible/inspectable.
Assistant command set in the scrollable slash list instead of silently
capping discovery to the first few commands, and every listed command row
must carry a matching icon so `/compact`, `/undo`, `/redo`, and other
- lower-frequency actions do not appear as unfinished blank rows.
+ lower-frequency actions do not appear as unfinished blank rows. OpenCode's
+ current app prompt popover keeps unmatched slash searches inside the prompt
+ surface and renders an empty-command state in
+ `packages/app/src/components/prompt-input/slash-popover.tsx` (fetched
+ `origin/dev` commit `914a643`, lines 96-100); Pulse adapts that by keeping
+ genuinely unmatched `/...` drafts open with a clear empty state while still
+ hiding disabled-only command matches so manual Enter can explain why the local
+ command is unavailable. The slash list must avoid persistent visible keyboard
+ shortcut instruction footers; owned key handling is proven by behavior and
+ accessible command state instead of extra instructional chrome.
Slash autocomplete close semantics are owned by that same prompt command
surface. The referenced OpenCode source at fetched `origin/dev` commit
`4519a1da329c1a4fc384054e7203ba7d06928205` clears a transient slash
diff --git a/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx b/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx
index 3d751ed334..cffba9326a 100644
--- a/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx
+++ b/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx
@@ -63,6 +63,10 @@ export function SlashCommandAutocomplete(props: SlashCommandAutocompleteProps) {
availability: props.availability,
}),
);
+ const emptyMessage = createMemo(() => {
+ const query = props.query.trim();
+ return query ? `No Assistant commands match /${query}` : 'No Assistant commands available';
+ });
createEffect(() => {
props.query;
@@ -125,7 +129,7 @@ export function SlashCommandAutocomplete(props: SlashCommandAutocompleteProps) {
});
return (
- <Show when={props.visible && commands().length > 0}>
+ <Show when={props.visible}>
<div
class="absolute z-50 min-w-[280px] max-w-[420px] overflow-hidden rounded-md border border-border bg-surface shadow-sm"
style={{
@@ -137,54 +141,55 @@ export function SlashCommandAutocomplete(props: SlashCommandAutocompleteProps) {
>
<div class="border-b border-border px-3 py-2 text-xs font-medium text-muted">Commands</div>
<div class="max-h-[260px] overflow-y-auto" role="listbox" aria-label="Assistant commands">
- <For each={commands()}>
- {(command, index) => (
- <button
- type="button"
- role="option"
- aria-selected={index() === selectedIndex()}
- aria-label={`Run /${command.name}: ${command.description}`}
- class={`flex w-full items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-surface-hover ${
- index() === selectedIndex() ? 'bg-surface-hover' : ''
- }`}
- onClick={(event) => {
- event.stopPropagation();
- selectCommand(command);
- }}
- onMouseEnter={() => setSelectedIndex(index())}
- >
- <span class="mt-0.5 text-muted">
- <AssistantSlashCommandIcon action={command.action} />
- </span>
- <span class="min-w-0 flex-1">
- <span class="flex min-w-0 items-center gap-2">
- <span class="font-mono text-xs font-semibold text-base-content">
- /{command.name}
- </span>
- <Show when={command.aliases?.length}>
- <span class="truncate text-[10px] text-muted">
- {getAssistantSlashCommandTokens(command)
- .slice(1)
- .map((alias) => `/${alias}`)
- .join(', ')}
- </span>
- </Show>
+ <Show
+ when={commands().length > 0}
+ fallback={
+ <div class="px-3 py-3 text-xs text-muted" role="status">
+ {emptyMessage()}
+ </div>
+ }
+ >
+ <For each={commands()}>
+ {(command, index) => (
+ <button
+ type="button"
+ role="option"
+ aria-selected={index() === selectedIndex()}
+ aria-label={`Run /${command.name}: ${command.description}`}
+ class={`flex w-full items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-surface-hover ${
+ index() === selectedIndex() ? 'bg-surface-hover' : ''
+ }`}
+ onClick={(event) => {
+ event.stopPropagation();
+ selectCommand(command);
+ }}
+ onMouseEnter={() => setSelectedIndex(index())}
+ >
+ <span class="mt-0.5 text-muted">
+ <AssistantSlashCommandIcon action={command.action} />
</span>
- <span class="mt-0.5 block truncate text-xs text-muted">
- {command.description}
+ <span class="min-w-0 flex-1">
+ <span class="flex min-w-0 items-center gap-2">
+ <span class="font-mono text-xs font-semibold text-base-content">
+ /{command.name}
+ </span>
+ <Show when={command.aliases?.length}>
+ <span class="truncate text-[10px] text-muted">
+ {getAssistantSlashCommandTokens(command)
+ .slice(1)
+ .map((alias) => `/${alias}`)
+ .join(', ')}
+ </span>
+ </Show>
+ </span>
+ <span class="mt-0.5 block truncate text-xs text-muted">
+ {command.description}
+ </span>
</span>
- </span>
- </button>
- )}
- </For>
- </div>
- <div class="flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs text-muted">
- <span class="rounded bg-surface-hover px-1.5 py-0.5 text-[10px]">up/down</span>
- navigate
- <span class="rounded bg-surface-hover px-1.5 py-0.5 text-[10px]">enter</span>
- run
- <span class="rounded bg-surface-hover px-1.5 py-0.5 text-[10px]">esc</span>
- close
+ </button>
+ )}
+ </For>
+ </Show>
</div>
</div>
</Show>
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index e9ec447ce3..7350535603 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -1765,6 +1765,26 @@ describe('AIChat', () => {
expect(screen.queryByRole('option', { name: /Run \/compact/ })).not.toBeInTheDocument();
});
+ it('keeps unknown slash command searches open without sending a provider prompt', () => {
+ renderChat();
+ const textarea = screen.getByPlaceholderText(
+ 'Ask about your infrastructure...',
+ ) as HTMLTextAreaElement;
+
+ fireEvent.input(textarea, { target: { value: '/not-a-command' } });
+
+ expect(screen.getByRole('listbox', { name: 'Assistant commands' })).toBeInTheDocument();
+ expect(screen.getByRole('status')).toHaveTextContent(
+ 'No Assistant commands match /not-a-command',
+ );
+
+ fireEvent.keyDown(textarea, { key: 'Enter' });
+
+ expect(mockChat.sendMessage).not.toHaveBeenCalled();
+ expect(textarea.value).toBe('/not-a-command');
+ expect(screen.getByRole('listbox', { name: 'Assistant commands' })).toBeInTheDocument();
+ });
+
it('explains unavailable manual slash commands without sending a provider prompt', async () => {
renderChat();
const textarea = screen.getByPlaceholderText(
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsx
index bf486b1686..b3b79f731c 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsx
@@ -123,7 +123,7 @@ describe('SlashCommandAutocomplete', () => {
);
});
- it('omits disabled commands from prompt autocomplete', () => {
+ it('renders an empty state when visible command search has no enabled options', () => {
render(() => (
<SlashCommandAutocomplete
availability={{
@@ -140,7 +140,55 @@ describe('SlashCommandAutocomplete', () => {
/>
));
- expect(screen.queryByRole('listbox', { name: 'Assistant commands' })).not.toBeInTheDocument();
+ expect(screen.getByRole('listbox', { name: 'Assistant commands' })).toBeInTheDocument();
+ expect(screen.getByRole('status')).toHaveTextContent('No Assistant commands match /compact');
expect(screen.queryByRole('option', { name: /\/compact/ })).not.toBeInTheDocument();
});
+
+ it('consumes selection keys without selecting when no commands match', () => {
+ const onSelect = vi.fn();
+ render(() => (
+ <SlashCommandAutocomplete
+ query="not-a-command"
+ visible
+ position={{ top: 58, left: 0 }}
+ onClose={vi.fn()}
+ onSelect={onSelect}
+ />
+ ));
+ const laterDocumentHandler = vi.fn();
+ document.addEventListener('keydown', laterDocumentHandler);
+
+ const enterEvent = new KeyboardEvent('keydown', {
+ bubbles: true,
+ cancelable: true,
+ key: 'Enter',
+ });
+ document.dispatchEvent(enterEvent);
+
+ document.removeEventListener('keydown', laterDocumentHandler);
+ expect(enterEvent.defaultPrevented).toBe(true);
+ expect(laterDocumentHandler).not.toHaveBeenCalled();
+ expect(onSelect).not.toHaveBeenCalled();
+ expect(screen.getByRole('status')).toHaveTextContent(
+ 'No Assistant commands match /not-a-command',
+ );
+ });
+
+ it('does not render persistent keyboard shortcut hints', () => {
+ render(() => (
+ <SlashCommandAutocomplete
+ query=""
+ visible
+ position={{ top: 58, left: 0 }}
+ onClose={vi.fn()}
+ onSelect={vi.fn()}
+ />
+ ));
+
+ expect(screen.queryByText('up/down')).not.toBeInTheDocument();
+ expect(screen.queryByText('navigate')).not.toBeInTheDocument();
+ expect(screen.queryByText('enter')).not.toBeInTheDocument();
+ expect(screen.queryByText('run')).not.toBeInTheDocument();
+ });
});
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index 6e8c4e3915..c753b5f840 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -3112,15 +3112,21 @@ export const AIChat: Component<AIChatProps> = (props) => {
) {
const query = textBeforeCursor.slice(1);
setSlashCommandQuery(query);
- const hasMatches =
+ const hasEnabledMatches =
filterAssistantSlashCommands(query, 1, {
availability: assistantCommandAvailability(),
}).length > 0;
- setSlashCommandActive(hasMatches);
- if (hasMatches) {
+ const hasAnyMatches =
+ filterAssistantSlashCommands(query, 1, {
+ availability: assistantCommandAvailability(),
+ includeDisabled: true,
+ }).length > 0;
+ const shouldShowSlashCommands = hasEnabledMatches || !hasAnyMatches;
+ setSlashCommandActive(shouldShowSlashCommands);
+ if (shouldShowSlashCommands) {
setMentionActive(false);
}
- return hasMatches;
+ return shouldShowSlashCommands;
}
setSlashCommandActive(false);