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.

Keep disabled Assistant commands visible

rcourtman66028fae7775
diff --git a/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx b/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx
index 17889a2c62..1b6a870150 100644
--- a/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx
+++ b/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx
@@ -65,6 +65,7 @@ export function SlashCommandAutocomplete(props: SlashCommandAutocompleteProps) {
const commands = createMemo(() =>
filterAssistantSlashCommands(props.query, undefined, {
availability: props.availability,
+ includeDisabled: true,
}),
);
const groupedCommands = createMemo(() => groupAssistantSlashCommands(commands()));
@@ -174,10 +175,21 @@ export function SlashCommandAutocomplete(props: SlashCommandAutocompleteProps) {
type="button"
role="option"
aria-selected={item.index === selectedIndex()}
+ aria-disabled={command.disabled ? 'true' : undefined}
aria-label={`${
- command.insertText ? 'Insert' : '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 ${
+ command.disabled
+ ? 'Unavailable'
+ : command.insertText
+ ? 'Insert'
+ : 'Run'
+ } /${command.name}: ${command.description}${
+ command.disabledReason ? `. ${command.disabledReason}` : ''
+ }`}
+ class={`flex w-full items-start gap-3 px-3 py-2.5 text-left transition-colors ${
+ command.disabled
+ ? 'cursor-not-allowed opacity-60'
+ : 'hover:bg-surface-hover'
+ } ${
item.index === selectedIndex() ? 'bg-surface-hover' : ''
}`}
onClick={(event) => {
@@ -206,6 +218,11 @@ export function SlashCommandAutocomplete(props: SlashCommandAutocompleteProps) {
<span class="mt-0.5 block truncate text-xs text-muted">
{command.description}
</span>
+ <Show when={command.disabledReason}>
+ <span class="mt-1 block truncate text-[11px] text-warning">
+ {command.disabledReason}
+ </span>
+ </Show>
</span>
</button>
);
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 13d9695354..c311c31a17 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -1826,14 +1826,18 @@ describe('AIChat', () => {
});
});
- it('omits unavailable session commands from slash suggestions', () => {
+ it('shows unavailable session commands with their disabled reason', () => {
renderChat();
const textarea = screen.getByPlaceholderText('Ask about your infrastructure...');
fireEvent.input(textarea, { target: { value: '/compact' } });
- expect(screen.queryByRole('listbox', { name: 'Assistant commands' })).not.toBeInTheDocument();
- expect(screen.queryByRole('option', { name: /Run \/compact/ })).not.toBeInTheDocument();
+ expect(screen.getByRole('listbox', { name: 'Assistant commands' })).toBeInTheDocument();
+ const option = screen.getByRole('option', {
+ name: /Unavailable \/compact: Summarize older turns and keep this session moving\. Requires a saved Assistant session\./,
+ });
+ expect(option).toHaveAttribute('aria-disabled', 'true');
+ expect(option).toHaveTextContent('Requires a saved Assistant session.');
});
it('keeps unknown slash command searches open without sending a provider prompt', () => {
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 79649059f0..1fcded1e1d 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsx
@@ -160,7 +160,7 @@ describe('SlashCommandAutocomplete', () => {
).toBeInTheDocument();
});
- it('renders an empty state when visible command search has no enabled options', () => {
+ it('renders disabled matching commands with the unavailable reason', () => {
render(() => (
<SlashCommandAutocomplete
availability={{
@@ -178,8 +178,12 @@ describe('SlashCommandAutocomplete', () => {
));
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();
+ const option = screen.getByRole('option', {
+ name: /Unavailable \/compact: Summarize older turns and keep this session moving\. Requires transcript content\./,
+ });
+ expect(option).toHaveAttribute('aria-disabled', 'true');
+ expect(option).toHaveTextContent('Requires transcript content.');
+ expect(screen.queryByRole('status')).not.toBeInTheDocument();
});
it('consumes selection keys without selecting when no commands match', () => {
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index 776547decf..7a273bee28 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -168,7 +168,6 @@ import {
} from './assistantModelRoutes';
import {
type AssistantSlashCommandAvailability,
- filterAssistantSlashCommands,
parseAssistantSlashCommandInput,
type AssistantSlashCommand,
type AssistantSlashCommandAction,
@@ -3203,21 +3202,9 @@ export const AIChat: Component<AIChatProps> = (props) => {
) {
const query = textBeforeCursor.slice(1);
setSlashCommandQuery(query);
- const hasEnabledMatches =
- filterAssistantSlashCommands(query, 1, {
- availability: assistantCommandAvailability(),
- }).length > 0;
- const hasAnyMatches =
- filterAssistantSlashCommands(query, 1, {
- availability: assistantCommandAvailability(),
- includeDisabled: true,
- }).length > 0;
- const shouldShowSlashCommands = hasEnabledMatches || !hasAnyMatches;
- setSlashCommandActive(shouldShowSlashCommands);
- if (shouldShowSlashCommands) {
- setMentionActive(false);
- }
- return shouldShowSlashCommands;
+ setSlashCommandActive(true);
+ setMentionActive(false);
+ return true;
}
setSlashCommandActive(false);