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
Keyboard model picker navigation
rcourtmanc26839bca3fa
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 941daa77a0..2bef3945c9 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -123,7 +123,14 @@ runtime cost control, and shared AI transport surfaces.selected models as structured `{ providerID, modelID }` values in`packages/opencode/src/cli/cmd/tui/component/dialog-model.tsx` and`packages/opencode/src/provider/provider.ts`, so Pulse must preserve the- equivalent route identity for queued and retried turns. Stop is the explicit+ equivalent route identity for queued and retried turns. OpenCode's+ `DialogModel` feeds current, recent, favorite, and provider model rows into+ `DialogSelect`, while `DialogSelect` maintains a selected row and handles+ up/down/page/home/end/return navigation; Pulse's browser model picker must+ expose the same route identity as a labelled search/listbox surface, focus+ search on open, move keyboard focus from search into the current or filtered+ model row, and keep list navigation available without requiring mouse+ clicks. Stop is the explicitinterruption path: it must abort the active stream, clear queued follow-upsand pending tool/approval/question affordances, preserve any partial modeltext, return focus to the composer, and render a neutral transcript markerdiff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 53154f3505..07453c0cc4 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -1020,7 +1020,12 @@ not a replacement status card, CTA band, or page-local nested card.routes. The shared picker must also mark the selected catalog, recent,override, custom, or inherited-default route as the current row withvisible `Current` metadata and `aria-selected`; selected model state must- not be communicated by background color alone.+ not be communicated by background color alone. The model picker dropdown is+ a named search/listbox surface: opening it must focus search, the trigger+ must expose its owned listbox while expanded, and keyboard movement from+ search through the option rows must support current-row focus,+ filtered-result focus, up/down, page, home/end, and Escape return to the+ trigger so model choice does not depend on mouse interaction.Gateway-routed model choices must not look like direct-provider choices:the shared picker, System AI settings status strip, and per-surfaceinherited-default descriptions must render OpenRouter-hosted providerdiff --git a/frontend-modern/src/components/shared/AIModelPicker.tsx b/frontend-modern/src/components/shared/AIModelPicker.tsxindex 94a4eeefe1..5a7f664eeb 100644--- a/frontend-modern/src/components/shared/AIModelPicker.tsx+++ b/frontend-modern/src/components/shared/AIModelPicker.tsx@@ -4,6 +4,7 @@ import {Show,createEffect,createMemo,+ createUniqueId,createSignal,onCleanup,onMount,@@ -78,6 +79,7 @@ const ERROR_ROW_HEIGHT = 36;const CUSTOM_RECENT_MODEL_DESCRIPTION = 'Recent custom model route';const MODEL_ROUTE_PROVIDER_RE = /^[a-z][a-z0-9_-]*$/i;const CURRENT_SELECTION_LABEL = 'Current';+const DEFAULT_OPTION_KEY = '__default__';type ResolvedModelRoute = {id: string;@@ -159,6 +161,8 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {let containerRef: HTMLDivElement | undefined;let buttonRef: HTMLButtonElement | undefined;let searchInputRef: HTMLInputElement | undefined;+ const pickerId = createUniqueId();+ const optionRefs = new Map<string, HTMLButtonElement>();let lastOpenRequest = props.openRequest || 0;const selectedModel = createMemo(() => props.selectedModel?.trim() || '');@@ -253,6 +257,48 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {}return !props.models.some((model) => model.id === candidate);});+ const optionKeyForModel = (modelId: string) => `model:${modelId}`;+ const optionKeyForExtra = (optionId: string) => `extra:${optionId}`;+ const optionKeyForCustom = (modelId: string) => `custom:${modelId}`;+ const displayedOptionKeys = createMemo(() => {+ const keys: string[] = [];+ if (props.defaultOption) {+ keys.push(DEFAULT_OPTION_KEY);+ }+ for (const option of extraOptions()) {+ keys.push(optionKeyForExtra(option.id));+ }+ if (showCustomModelOption()) {+ keys.push(optionKeyForCustom(customModelCandidate()));+ }+ if (!searchQuery().trim()) {+ for (const section of modelSections()) {+ for (const entry of section.models) {+ keys.push(optionKeyForModel(entry.id));+ }+ }+ }+ for (const [, providerModels] of groupModelsByProvider(filteredModels()).entries()) {+ for (const model of providerModels) {+ keys.push(optionKeyForModel(model.id));+ }+ }+ return keys;+ });+ const currentOptionKey = createMemo(() => {+ const selected = selectedModel();+ if (!selected) {+ return props.defaultOption ? DEFAULT_OPTION_KEY : '';+ }+ if (extraOptions().some((option) => option.id === selected)) {+ return optionKeyForExtra(selected);+ }+ if (showCustomModelOption() && customModelCandidate() === selected) {+ return optionKeyForCustom(selected);+ }+ const modelKey = optionKeyForModel(selected);+ return displayedOptionKeys().includes(modelKey) ? modelKey : '';+ });const selectedLabel = createMemo(() => {const selected = selectedModel();@@ -353,15 +399,106 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {isSelected ? 'bg-blue-50 dark:bg-blue-900' : ''}`;- const handleKeyDown = (event: KeyboardEvent) => {- if (event.key !== 'Enter') {+ createEffect(() => {+ const visibleKeys = new Set(displayedOptionKeys());+ for (const key of optionRefs.keys()) {+ if (!visibleKeys.has(key)) {+ optionRefs.delete(key);+ }+ }+ });++ const focusOptionAtIndex = (index: number) => {+ const keys = displayedOptionKeys();+ if (keys.length === 0) return false;+ const nextIndex = ((index % keys.length) + keys.length) % keys.length;+ const target = optionRefs.get(keys[nextIndex]);+ if (!target) return false;+ target.focus();+ return true;+ };++ const focusInitialOption = () => {+ const keys = displayedOptionKeys();+ if (keys.length === 0) return false;+ const currentKey = currentOptionKey();+ const currentIndex = !searchQuery().trim() && currentKey ? keys.indexOf(currentKey) : -1;+ return focusOptionAtIndex(currentIndex >= 0 ? currentIndex : 0);+ };++ const focusOptionRelativeTo = (optionKey: string, offset: number) => {+ const keys = displayedOptionKeys();+ const currentIndex = keys.indexOf(optionKey);+ if (currentIndex < 0) return false;+ let nextIndex = currentIndex + offset;+ if (nextIndex < 0) nextIndex = keys.length - 1;+ if (nextIndex >= keys.length) nextIndex = 0;+ return focusOptionAtIndex(nextIndex);+ };++ const handleSearchKeyDown = (event: KeyboardEvent) => {+ if (event.altKey || event.ctrlKey || event.metaKey) return;+ if (event.key === 'ArrowDown' && focusInitialOption()) {+ event.preventDefault();return;}- event.preventDefault();- const candidate = customModelCandidate();- if (candidate && (exactCandidateModel() || showCustomModelOption())) {- handleSelect(candidate);+ if (event.key === 'ArrowUp' && focusOptionAtIndex(displayedOptionKeys().length - 1)) {+ event.preventDefault();+ return;}+ if (event.key === 'Enter') {+ event.preventDefault();+ const candidate = customModelCandidate();+ if (candidate && (exactCandidateModel() || showCustomModelOption())) {+ handleSelect(candidate);+ }+ }+ };++ const handleOptionKeyDown = (+ event: KeyboardEvent & { currentTarget: HTMLButtonElement },+ optionKey: string,+ ) => {+ if (event.altKey || event.ctrlKey || event.metaKey) return;++ if (event.key === 'ArrowDown' && focusOptionRelativeTo(optionKey, 1)) {+ event.preventDefault();+ return;+ }+ if (event.key === 'ArrowUp' && focusOptionRelativeTo(optionKey, -1)) {+ event.preventDefault();+ return;+ }+ if (event.key === 'PageDown' && focusOptionRelativeTo(optionKey, 10)) {+ event.preventDefault();+ return;+ }+ if (event.key === 'PageUp' && focusOptionRelativeTo(optionKey, -10)) {+ event.preventDefault();+ return;+ }+ if (event.key === 'Home' && focusOptionAtIndex(0)) {+ event.preventDefault();+ return;+ }+ if (event.key === 'End' && focusOptionAtIndex(displayedOptionKeys().length - 1)) {+ event.preventDefault();+ return;+ }+ if (event.key === 'Escape') {+ event.preventDefault();+ closePicker();+ buttonRef?.focus();+ }+ };++ const handleShowAllModelsKeyDown = (+ event: KeyboardEvent & { currentTarget: HTMLButtonElement },+ ) => {+ if (event.key !== 'Escape' || event.altKey || event.ctrlKey || event.metaKey) return;+ event.preventDefault();+ closePicker();+ buttonRef?.focus();};createEffect(() => {@@ -409,6 +546,7 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {disabled={props.disabled}aria-haspopup="listbox"aria-expanded={isOpen()}+ aria-controls={isOpen() ? `${pickerId}-listbox` : undefined}aria-label={selectedButtonLabel()}class={props.buttonClass || DEFAULT_BUTTON_CLASS}title={props.title || 'Select model'}@@ -435,13 +573,15 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {<Show when={isOpen()}><divclass={`fixed overflow-hidden rounded-md border border-border bg-surface shadow-sm z-[9999] ${props.dropdownClass || DEFAULT_DROPDOWN_CLASS}`}+ role="dialog"+ aria-label={props.title || 'Select model'}style={dropdownStyle()}><div class="flex items-center gap-2 border-b border-border px-3 py-2"><SearchFieldvalue={searchQuery()}onChange={setSearchQuery}- onKeyDown={handleKeyDown}+ onKeyDown={handleSearchKeyDown}placeholder={props.searchPlaceholder || 'Search or enter model ID'}class="flex-1"inputClass="py-1.5 text-xs focus:ring-blue-400"@@ -456,6 +596,7 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {disabled={props.isLoading}class="rounded-md p-1.5 text-muted hover:bg-surface-hover hover:text-base-content disabled:cursor-not-allowed disabled:opacity-50"title="Refresh models"+ aria-label="Refresh models"><RefreshCwIcon class={`h-3.5 w-3.5 ${props.isLoading ? 'animate-spin' : ''}`} /></button>@@ -469,14 +610,20 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {</Show><div+ id={`${pickerId}-listbox`}class="overflow-y-auto py-1"role="listbox"+ aria-label={props.title || 'Select model'}style={{ 'max-height': `${dropdownPosition().listMaxHeight}px` }}><Show when={props.defaultOption}><buttontype="button"+ ref={(button) => {+ optionRefs.set(DEFAULT_OPTION_KEY, button);+ }}onClick={() => handleSelect('')}+ onKeyDown={(event) => handleOptionKeyDown(event, DEFAULT_OPTION_KEY)}role="option"aria-selected={!selectedModel()}aria-label={optionAriaLabel(@@ -504,7 +651,11 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {{(option) => (<buttontype="button"+ ref={(button) => {+ optionRefs.set(optionKeyForExtra(option.id), button);+ }}onClick={() => handleSelect(option.id)}+ onKeyDown={(event) => handleOptionKeyDown(event, optionKeyForExtra(option.id))}role="option"aria-selected={isSelectedRoute(option.id)}aria-label={optionAriaLabel(option.label, isSelectedRoute(option.id), [@@ -530,7 +681,13 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {<Show when={showCustomModelOption()}><buttontype="button"+ ref={(button) => {+ optionRefs.set(optionKeyForCustom(customModelCandidate()), button);+ }}onClick={() => handleSelect(customModelCandidate())}+ onKeyDown={(event) =>+ handleOptionKeyDown(event, optionKeyForCustom(customModelCandidate()))+ }role="option"aria-selected={isSelectedRoute(customModelCandidate())}aria-label={optionAriaLabel(@@ -577,7 +734,13 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {{(entry) => (<buttontype="button"+ ref={(button) => {+ optionRefs.set(optionKeyForModel(entry.id), button);+ }}onClick={() => handleSelect(entry.id)}+ onKeyDown={(event) =>+ handleOptionKeyDown(event, optionKeyForModel(entry.id))+ }role="option"aria-selected={isSelectedRoute(entry.id)}aria-label={optionAriaLabel(@@ -621,7 +784,13 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {{(model) => (<buttontype="button"+ ref={(button) => {+ optionRefs.set(optionKeyForModel(model.id), button);+ }}onClick={() => handleSelect(model.id)}+ onKeyDown={(event) =>+ handleOptionKeyDown(event, optionKeyForModel(model.id))+ }role="option"aria-selected={isSelectedRoute(model.id)}aria-label={optionAriaLabel(@@ -660,6 +829,7 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {<buttontype="button"onClick={() => setShowAllModels(!showAllModels())}+ onKeyDown={handleShowAllModelsKeyDown}class="flex w-full items-center gap-1.5 px-3 py-2 text-left text-xs text-muted hover:bg-surface-hover hover:text-base-content"><ChevronDownIcondiff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.tsindex 6deefe80df..8439efb443 100644--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts@@ -258,6 +258,15 @@ describe('shared primitive guardrails', () => {expect(aiModelPickerSource).toContain("const CURRENT_SELECTION_LABEL = 'Current'");expect(aiModelPickerSource).toContain('const CurrentSelectionBadge');expect(aiModelPickerSource).toContain('const optionAriaLabel');+ expect(aiModelPickerSource).toContain('const displayedOptionKeys = createMemo');+ expect(aiModelPickerSource).toContain('const currentOptionKey = createMemo');+ expect(aiModelPickerSource).toContain('const focusInitialOption = () =>');+ expect(aiModelPickerSource).toContain('const handleSearchKeyDown = (event: KeyboardEvent)');+ expect(aiModelPickerSource).toContain('const handleOptionKeyDown = (');+ expect(aiModelPickerSource).toContain('role="dialog"');+ expect(aiModelPickerSource).toContain('role="listbox"');+ expect(aiModelPickerSource).toContain('aria-controls={isOpen() ? `${pickerId}-listbox` : undefined}');+ expect(aiModelPickerSource).toContain('onKeyDown={(event) => handleOptionKeyDown');expect(aiModelPickerSource).toContain('aria-selected={isSelectedRoute(model.id)}');expect(aiModelPickerSource).toContain('aria-label={optionAriaLabel(');expect(aiModelPickerSource).toContain('role="option"');diff --git a/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx b/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsxindex 50250fb77a..dde34efb2e 100644--- a/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx@@ -1,4 +1,4 @@-import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';+import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';import { afterEach, describe, expect, it, vi } from 'vitest';import { AIModelPicker } from '@/components/shared/AIModelPicker';import type { ModelInfo } from '@/types/ai';@@ -152,6 +152,119 @@ describe('AIModelPicker', () => {expect(currentOption).toHaveTextContent('Use configured default model');});+ it('labels the dropdown and listbox with the picker title', () => {+ render(() => (+ <AIModelPicker+ models={models}+ selectedModel="openrouter:minimax/minimax-m2.5"+ onModelSelect={vi.fn()}+ title="Select shared default model"+ />+ ));++ const button = screen.getByTitle('Select shared default model');+ fireEvent.click(button);++ expect(button.getAttribute('aria-controls')?.endsWith('-listbox')).toBe(true);+ expect(screen.getByRole('dialog', { name: 'Select shared default model' })).toBeInTheDocument();+ expect(screen.getByRole('listbox', { name: 'Select shared default model' })).toBeInTheDocument();+ });++ it('moves keyboard focus from search through model options', async () => {+ render(() => (+ <AIModelPicker+ models={models}+ selectedModel="openrouter:minimax/minimax-m2.5"+ onModelSelect={vi.fn()}+ title="Select shared default model"+ />+ ));++ fireEvent.click(screen.getByTitle('Select shared default model'));++ const searchInput = screen.getByPlaceholderText('Search or enter model ID');+ const currentOption = screen.getByRole('option', {+ name: 'MiniMax: MiniMax M2.5 via OpenRouter, Current. Current OpenRouter model. openrouter:minimax/minimax-m2.5',+ });+ const nextOption = screen.getByRole('option', {+ name: 'GPT-5.1 Mini. openai:gpt-5.1-mini',+ });++ await waitFor(() => {+ expect(document.activeElement).toBe(searchInput);+ });++ fireEvent.keyDown(searchInput, { key: 'ArrowDown' });+ expect(document.activeElement).toBe(currentOption);++ fireEvent.keyDown(currentOption, { key: 'ArrowDown' });+ expect(document.activeElement).toBe(nextOption);++ fireEvent.keyDown(nextOption, { key: 'ArrowUp' });+ expect(document.activeElement).toBe(currentOption);++ fireEvent.keyDown(currentOption, { key: 'End' });+ expect(document.activeElement).toBe(nextOption);++ fireEvent.keyDown(nextOption, { key: 'Home' });+ expect(document.activeElement).toBe(currentOption);+ });++ it('moves keyboard focus to the first filtered result while searching', async () => {+ render(() => (+ <AIModelPicker+ models={models}+ selectedModel="openrouter:minimax/minimax-m2.5"+ onModelSelect={vi.fn()}+ title="Select shared default model"+ />+ ));++ fireEvent.click(screen.getByTitle('Select shared default model'));++ const searchInput = screen.getByPlaceholderText('Search or enter model ID');+ fireEvent.input(searchInput, { target: { value: 'legacy' } });+ const legacyOption = screen.getByRole('option', {+ name: 'Legacy Model V1 via OpenRouter. Older provider catalog entry. openrouter:legacy/model-v1',+ });++ await waitFor(() => {+ expect(document.activeElement).toBe(searchInput);+ });++ fireEvent.keyDown(searchInput, { key: 'ArrowDown' });+ expect(document.activeElement).toBe(legacyOption);+ });++ it('closes the picker and returns focus to the trigger from option Escape', async () => {+ render(() => (+ <AIModelPicker+ models={models}+ selectedModel="openrouter:minimax/minimax-m2.5"+ onModelSelect={vi.fn()}+ title="Select shared default model"+ />+ ));++ const button = screen.getByTitle('Select shared default model');+ fireEvent.click(button);++ const searchInput = screen.getByPlaceholderText('Search or enter model ID');+ const currentOption = screen.getByRole('option', {+ name: 'MiniMax: MiniMax M2.5 via OpenRouter, Current. Current OpenRouter model. openrouter:minimax/minimax-m2.5',+ });+ await waitFor(() => {+ expect(document.activeElement).toBe(searchInput);+ });+ fireEvent.keyDown(searchInput, { key: 'ArrowDown' });++ expect(document.activeElement).toBe(currentOption);+ fireEvent.keyDown(currentOption, { key: 'Escape' });++ expect(screen.queryByPlaceholderText('Search or enter model ID')).not.toBeInTheDocument();+ expect(document.activeElement).toBe(button);+ });+it('constrains the dropdown to the available mobile viewport height', () => {vi.spyOn(window, 'innerWidth', 'get').mockReturnValue(760);vi.spyOn(window, 'innerHeight', 'get').mockReturnValue(850);