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
Constrain AI model picker on mobile
rcourtman5f4c07a70121
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 605295f1ed..ad8a88faba 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -548,7 +548,9 @@ work extends shared components instead of creating new local variants.searchable, notable-first model picker pattern, and`AIModelSelectionSection.tsx` must feed it configured-provider models plusthe current manual selection instead of rendering raw provider catalogs as- plain select options.+ plain select options. The picker must also constrain its dropdown and+ internal result list to the available viewport height so settings model+ catalogs remain usable on mobile and tablet layouts with bottom navigation.## Forbidden Pathsdiff --git a/frontend-modern/src/components/shared/AIModelPicker.tsx b/frontend-modern/src/components/shared/AIModelPicker.tsxindex c427ebeadb..42d5cb2e6a 100644--- a/frontend-modern/src/components/shared/AIModelPicker.tsx+++ b/frontend-modern/src/components/shared/AIModelPicker.tsx@@ -38,6 +38,13 @@ const DEFAULT_BUTTON_CLASS =const DEFAULT_LABEL_CLASS = 'max-w-[90px] truncate font-medium sm:max-w-[180px]';const DEFAULT_DROPDOWN_CLASS = 'w-80';const DEFAULT_EMPTY_STATE = AI_CHAT_MODEL_SELECTOR_EMPTY_STATE;+const DEFAULT_DROPDOWN_MAX_HEIGHT = 384;+const DEFAULT_LIST_MAX_HEIGHT = 288;+const MIN_DROPDOWN_MAX_HEIGHT = 120;+const MOBILE_BOTTOM_CLEARANCE = 88;+const DESKTOP_BOTTOM_CLEARANCE = 16;+const SEARCH_HEADER_HEIGHT = 52;+const ERROR_ROW_HEIGHT = 36;function groupModelsByProvider(models: ModelInfo[]): Map<string, ModelInfo[]> {const grouped = new Map<string, ModelInfo[]>();@@ -56,7 +63,13 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {const [isOpen, setIsOpen] = createSignal(false);const [showAllModels, setShowAllModels] = createSignal(false);const [searchQuery, setSearchQuery] = createSignal('');- const [dropdownPosition, setDropdownPosition] = createSignal({ top: 0, left: 0, right: 0 });+ const [dropdownPosition, setDropdownPosition] = createSignal({+ top: 0,+ left: 0,+ right: 0,+ maxHeight: DEFAULT_DROPDOWN_MAX_HEIGHT,+ listMaxHeight: DEFAULT_LIST_MAX_HEIGHT,+ });let containerRef: HTMLDivElement | undefined;let buttonRef: HTMLButtonElement | undefined;@@ -133,10 +146,11 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {const dropdownStyle = createMemo(() => {const position = dropdownPosition();+ const base = { top: `${position.top}px`, 'max-height': `${position.maxHeight}px` };if (props.align === 'left') {- return { top: `${position.top}px`, left: `${position.left}px` };+ return { ...base, left: `${position.left}px` };}- return { top: `${position.top}px`, right: `${position.right}px` };+ return { ...base, right: `${position.right}px` };});const updateDropdownPosition = () => {@@ -144,10 +158,20 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {return;}const rect = buttonRef.getBoundingClientRect();+ const bottomClearance =+ window.innerWidth < 1024 ? MOBILE_BOTTOM_CLEARANCE : DESKTOP_BOTTOM_CLEARANCE;+ const availableHeight = window.innerHeight - rect.bottom - bottomClearance;+ const maxHeight = Math.max(+ MIN_DROPDOWN_MAX_HEIGHT,+ Math.min(DEFAULT_DROPDOWN_MAX_HEIGHT, availableHeight),+ );+ const nonListHeight = SEARCH_HEADER_HEIGHT + (props.error ? ERROR_ROW_HEIGHT : 0);setDropdownPosition({top: rect.bottom + 4,left: rect.left,right: window.innerWidth - rect.right,+ maxHeight,+ listMaxHeight: Math.max(80, maxHeight - nonListHeight),});};@@ -188,8 +212,17 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {closePicker();}};+ const handleViewportChange = () => {+ if (isOpen()) {+ updateDropdownPosition();+ }+ };document.addEventListener('mousedown', handlePointerDown);- onCleanup(() => document.removeEventListener('mousedown', handlePointerDown));+ window.addEventListener('resize', handleViewportChange);+ onCleanup(() => {+ document.removeEventListener('mousedown', handlePointerDown);+ window.removeEventListener('resize', handleViewportChange);+ });});return (@@ -214,7 +247,7 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {<Show when={isOpen()}><div- class={`fixed max-h-96 overflow-hidden rounded-md border border-border bg-surface shadow-sm z-[9999] ${props.dropdownClass || DEFAULT_DROPDOWN_CLASS}`}+ class={`fixed overflow-hidden rounded-md border border-border bg-surface shadow-sm z-[9999] ${props.dropdownClass || DEFAULT_DROPDOWN_CLASS}`}style={dropdownStyle()}><div class="flex items-center gap-2 border-b border-border px-3 py-2">@@ -245,7 +278,11 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {</div></Show>- <div class="max-h-72 overflow-y-auto py-1" role="listbox">+ <div+ class="overflow-y-auto py-1"+ role="listbox"+ style={{ 'max-height': `${dropdownPosition().listMaxHeight}px` }}+ ><Show when={props.defaultOption}><buttontype="button"diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.tsindex 949c677305..4561b9403b 100644--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts@@ -228,6 +228,11 @@ describe('shared primitive guardrails', () => {expect(aiModelPickerSource).toContain('return props.models.filter((model) => !model.notable');expect(aiModelPickerSource).toContain('Show ${hiddenModelCount()} older models');expect(aiModelPickerSource).toContain("if (!candidate.includes(':'))");+ expect(aiModelPickerSource).toContain('MOBILE_BOTTOM_CLEARANCE');+ expect(aiModelPickerSource).toContain('availableHeight = window.innerHeight');+ expect(aiModelPickerSource).toContain(+ "style={{ 'max-height': `${dropdownPosition().listMaxHeight}px` }}",+ );expect(aiModelPickerSource).not.toContain('No matching models.');expect(aiModelPickerSource).not.toContain('<select');});diff --git a/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx b/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsxindex fd2cb98e85..b956e2b91c 100644--- a/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx@@ -3,7 +3,10 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import { AIModelPicker } from '@/components/shared/AIModelPicker';import type { ModelInfo } from '@/types/ai';-afterEach(cleanup);+afterEach(() => {+ vi.restoreAllMocks();+ cleanup();+});const models: ModelInfo[] = [{@@ -44,6 +47,38 @@ describe('AIModelPicker', () => {expect(screen.getByText('Show 1 older models')).toBeInTheDocument();});+ it('constrains the dropdown to the available mobile viewport height', () => {+ vi.spyOn(window, 'innerWidth', 'get').mockReturnValue(760);+ vi.spyOn(window, 'innerHeight', 'get').mockReturnValue(850);+ 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');+ vi.spyOn(button, 'getBoundingClientRect').mockReturnValue({+ bottom: 470,+ height: 40,+ left: 24,+ right: 624,+ top: 430,+ width: 600,+ x: 24,+ y: 430,+ toJSON: () => ({}),+ } as DOMRect);++ fireEvent.click(button);++ const dropdown = document.querySelector('[data-ai-model-picker] .fixed') as HTMLElement;+ expect(dropdown.style.maxHeight).toBe('292px');+ expect(screen.getByRole('listbox').style.maxHeight).toBe('240px');+ });+it('searches the full catalog without requiring the older-model disclosure first', () => {render(() => (<AIModelPicker