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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Improve Assistant autocomplete keyboard flow
rcourtman459ac0b1eee4
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex a2ce6464a6..4f314b25df 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -293,6 +293,9 @@ runtime cost control, and shared AI transport surfaces.another executable command token behind for the next Enter press.Prompt-owned popups must consume their local keyboard commands before globaldrawer handlers can reinterpret them. The same OpenCode autocomplete source+ wraps previous/next selection at list boundaries in+ `packages/tui/src/component/prompt/autocomplete.tsx` lines 552-559 at fetched+ `origin/dev` commit `31c099be435d59bd6749ace7a9f2bb2245e6d3fa`, andregisters prompt-scoped previous/next/hide/select/complete commands in`packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx`(lines 600-658), and OpenCode's help dialog binds Escape as a dialog-local@@ -301,8 +304,11 @@ runtime cost control, and shared AI transport surfaces.Pulse adapts that by having slash autocomplete, resource mentionautocomplete, and Assistant command help prevent default handling and stoplater document-level keyboard handlers for their owned navigation,- selection, and close keys. Escape inside those local surfaces must close the- local popup/dialog only; it must not also close the Assistant drawer.+ selection, and close keys. Slash and resource mention autocomplete must wrap+ up/down movement across the visible options, and resource mentions must expose+ the same selected-row state as a labelled listbox rather than only a visual+ hover fill. Escape inside those local surfaces must close the local+ popup/dialog only; it must not also close the Assistant drawer.Failed-turn retry is part of that same local chat-runtime boundary: aretryable in-memory assistant error may replay the original user turn'sstructured mentions, finding id, approval override, handoff resources,diff --git a/frontend-modern/src/components/AI/Chat/MentionAutocomplete.tsx b/frontend-modern/src/components/AI/Chat/MentionAutocomplete.tsxindex adf4449adb..8421f50395 100644--- a/frontend-modern/src/components/AI/Chat/MentionAutocomplete.tsx+++ b/frontend-modern/src/components/AI/Chat/MentionAutocomplete.tsx@@ -27,9 +27,7 @@ export function MentionAutocomplete(props: MentionAutocompleteProps) {const q = props.query.toLowerCase();if (!q) return props.resources.slice(0, 10); // Show first 10 if no query- return props.resources- .filter((r) => r.label.toLowerCase().includes(q))- .slice(0, 10); // Limit to 10 results+ return props.resources.filter((r) => r.label.toLowerCase().includes(q)).slice(0, 10); // Limit to 10 results};// Reset selection when query changes@@ -44,6 +42,16 @@ export function MentionAutocomplete(props: MentionAutocompleteProps) {e.stopImmediatePropagation();};+ const moveSelection = (direction: -1 | 1, total: number) => {+ if (total <= 0) return;+ setSelectedIndex((index) => {+ const next = index + direction;+ if (next < 0) return total - 1;+ if (next >= total) return 0;+ return next;+ });+ };+// Handle keyboard navigationconst handleKeyDown = (e: KeyboardEvent) => {if (!props.visible) return;@@ -53,11 +61,11 @@ export function MentionAutocomplete(props: MentionAutocompleteProps) {switch (e.key) {case 'ArrowDown':consumeMentionKey(e);- setSelectedIndex((i) => Math.min(i + 1, resources.length - 1));+ moveSelection(1, resources.length);break;case 'ArrowUp':consumeMentionKey(e);- setSelectedIndex((i) => Math.max(i - 1, 0));+ moveSelection(-1, resources.length);break;case 'Enter':case 'Tab':@@ -156,20 +164,32 @@ export function MentionAutocomplete(props: MentionAutocompleteProps) {bottom: `${props.position.top}px`,left: `${props.position.left}px`,}}+ data-mention-autocomplete+ onClick={(event) => event.stopPropagation()}><div class="px-3 py-2 border-b border-border text-xs font-medium text-muted">Resources</div>- <div class="max-h-[240px] overflow-y-auto">+ <div class="max-h-[240px] overflow-y-auto" role="listbox" aria-label="Assistant resources"><For each={filteredResources()}>{(resource, index) => (<buttontype="button"+ role="option"+ aria-selected={index() === selectedIndex()}+ aria-label={`Mention ${resource.label}: ${resource.type}${+ resource.node ? ` on ${resource.node}` : ''+ }${resource.status ? `, ${resource.status}` : ''}`}class={`w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-surface-hover transition-colors ${index() === selectedIndex() ? 'bg-surface-hover' : ''}`}- onClick={() => props.onSelect(resource)}+ onClick={(event) => {+ event.stopPropagation();+ props.onSelect(resource);+ }}onMouseEnter={() => setSelectedIndex(index())}>- <span class="text-muted">{getTypeIcon(resource.type)}</span>+ <span class="text-muted" aria-hidden="true">+ {getTypeIcon(resource.type)}+ </span><div class="flex-1 min-w-0"><div class="flex items-center gap-2"><span class="font-medium text-base-content truncate">{resource.label}</span>diff --git a/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx b/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsxindex e74a44df10..01957ac6ad 100644--- a/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx+++ b/frontend-modern/src/components/AI/Chat/SlashCommandAutocomplete.tsx@@ -71,6 +71,16 @@ export function SlashCommandAutocomplete(props: SlashCommandAutocompleteProps) {event.stopImmediatePropagation();};+ const moveSelection = (direction: -1 | 1, total: number) => {+ if (total <= 0) return;+ setSelectedIndex((index) => {+ const next = index + direction;+ if (next < 0) return total - 1;+ if (next >= total) return 0;+ return next;+ });+ };+const handleKeyDown = (event: KeyboardEvent) => {if (!props.visible) return;@@ -78,11 +88,11 @@ export function SlashCommandAutocomplete(props: SlashCommandAutocompleteProps) {switch (event.key) {case 'ArrowDown':consumeCommandKey(event);- setSelectedIndex((index) => Math.min(index + 1, Math.max(0, options.length - 1)));+ moveSelection(1, options.length);break;case 'ArrowUp':consumeCommandKey(event);- setSelectedIndex((index) => Math.max(index - 1, 0));+ moveSelection(-1, options.length);break;case 'Enter':consumeCommandKey(event);diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MentionAutocomplete.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MentionAutocomplete.test.tsxindex bd9855355c..954095862f 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/MentionAutocomplete.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/MentionAutocomplete.test.tsx@@ -173,6 +173,27 @@ describe('MentionAutocomplete', () => {const statusDot = resourceBtn.querySelector('.bg-red-500');expect(statusDot).not.toBeNull();});++ it('exposes resources as a named listbox with selected option state', () => {+ renderAutocomplete();++ const listbox = screen.getByRole('listbox', { name: 'Assistant resources' });+ expect(listbox).toBeInTheDocument();++ const firstOption = screen.getByRole('option', {+ name: 'Mention web-server: vm on pve1, running',+ });+ expect(firstOption).toHaveAttribute('aria-selected', 'true');++ fireEvent.keyDown(document, { key: 'ArrowDown' });++ expect(firstOption).toHaveAttribute('aria-selected', 'false');+ expect(+ screen.getByRole('option', {+ name: 'Mention db-container: system-container on pve2, running',+ }),+ ).toHaveAttribute('aria-selected', 'true');+ });});describe('click interaction', () => {@@ -220,29 +241,26 @@ describe('MentionAutocomplete', () => {expect(onSelect).toHaveBeenCalledWith(defaultResources[1]);});- it('does not go below 0 on ArrowUp at the top', () => {+ it('wraps from the first item to the last item on ArrowUp', () => {const onSelect = vi.fn();renderAutocomplete({ onSelect });- // ArrowUp at index 0 should stay at 0fireEvent.keyDown(document, { key: 'ArrowUp' });fireEvent.keyDown(document, { key: 'Enter' });- expect(onSelect).toHaveBeenCalledWith(defaultResources[0]);+ expect(onSelect).toHaveBeenCalledWith(defaultResources[defaultResources.length - 1]);});- it('does not go past last item on ArrowDown', () => {+ it('wraps from the last item to the first item on ArrowDown', () => {const onSelect = vi.fn();const twoResources = defaultResources.slice(0, 2);renderAutocomplete({ onSelect, resources: twoResources });- // ArrowDown 5 times should cap at index 1- for (let i = 0; i < 5; i++) {- fireEvent.keyDown(document, { key: 'ArrowDown' });- }+ fireEvent.keyDown(document, { key: 'ArrowUp' });+ fireEvent.keyDown(document, { key: 'ArrowDown' });fireEvent.keyDown(document, { key: 'Enter' });- expect(onSelect).toHaveBeenCalledWith(twoResources[1]);+ expect(onSelect).toHaveBeenCalledWith(twoResources[0]);});it('selects on Tab key', () => {diff --git a/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsxindex 5b10db0a7b..7e5e871e28 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/SlashCommandAutocomplete.test.tsx@@ -65,4 +65,39 @@ describe('SlashCommandAutocomplete', () => {}),);});++ it('wraps keyboard selection from the first command to the last visible command', () => {+ const onSelect = vi.fn();+ render(() => (+ <SlashCommandAutocomplete+ query=""+ visible+ position={{ top: 58, left: 0 }}+ onClose={vi.fn()}+ onSelect={onSelect}+ />+ ));++ document.dispatchEvent(+ new KeyboardEvent('keydown', {+ bubbles: true,+ cancelable: true,+ key: 'ArrowUp',+ }),+ );+ document.dispatchEvent(+ new KeyboardEvent('keydown', {+ bubbles: true,+ cancelable: true,+ key: 'Enter',+ }),+ );++ expect(onSelect).toHaveBeenCalledWith(+ expect.objectContaining({+ action: 'export',+ name: 'export',+ }),+ );+ });});