Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(model-hub): keep route actions and identity fully visible (#1904)
Call White85fe96897248
diff --git a/docs/plans/model-hub-routing-modes.md b/docs/plans/model-hub-routing-modes.mdindex c4c071f2c..3885b5c32 100644--- a/docs/plans/model-hub-routing-modes.md+++ b/docs/plans/model-hub-routing-modes.md@@ -394,6 +394,46 @@ without reverting unrelated edits. Deploy through the LOCAL Incus runner withoutresetting master state; coordinate the shared regression instance before update.Final success requires merged-head end-to-end acceptance, not mocked peer suites.+## Post-Merge Visual Closure++Real local acceptance exposed a persistent mobile footer clipping defect. Route+dialog actions must remain entirely inside the footer, dialog and viewport when+they wrap. The route footer has a minimum height, not a fixed mobile height; its+content determines its height and the existing scrollable body yields space.+Do not hide Restore, shrink action text, remove the dialog's clipping boundary,+or change the global Button component to make this pass.++Route details expose the complete source identity and exact model id as visible+text, including stale/missing source fallback identities. These detail fields+wrap at constrained widths, with long unbroken identifiers allowed to break;+hop rows retain their existing minimum height and grow with their content.+This applies to editable, inherited read-only and restore-preview rows, including+manual sources outside defaults. It does not replace the approved compact+ellipsis behavior in overview/provider cards. Two values sharing a long prefix+must remain distinguishable without requiring hover, title text, or editing.++The existing AgentCard collection owns one active route-origin help across all+its backend/model rows. A new mouse hover, focus or tap activation replaces the+previous help, including a focused or pinned help. The prior close timer may+close only its own help; it cannot close a newly activated one. Preserve the+existing pointer bridge delay, focus behavior, pin/unpin, Escape and outside+dismissal. Do not use a module-global event bus or a second page-level overlay+owner. Noninteractive route-dialog badges do not participate in this state.++Capture helpers must remove their own incidental pointer/focus state and await+the absence of prior help before a new scenario. The target badge's aria-controls+identifies its help, while a retryable global count confirms no second help.+Do not use first-match selection, forced DOM removal, or repeated Escape to hide+a stuck overlay. Separately exercise focus-A/hover-B, pin-A/hover-B, quick A-to-B+movement and movement across the trigger/content gap at the real common owner.++Visual acceptance checks each actionable control against clipping ancestors,+the viewport and actual hit testing, not just the dialog's outer rectangle or+text width. At narrow and short viewports, all footer controls remain reachable+after long-body scrolling and Save performs the intended mutation. Verify EN/ZH,+light/dark and manual/restore-preview states. Existing required case identities,+baseline gaps and screenshot stages do not change; add assertions within them.+## Delivery OwnershipOne feature PR is intentional: executable schema/type/mirror closure needs alldiff --git a/ui/src/components/settings/models/AgentCard.test.tsx b/ui/src/components/settings/models/AgentCard.test.tsxindex 7295dcf26..c709af0fb 100644--- a/ui/src/components/settings/models/AgentCard.test.tsx+++ b/ui/src/components/settings/models/AgentCard.test.tsx@@ -1,6 +1,6 @@// @vitest-environment jsdomimport type { ComponentProps } from 'react';-import { cleanup, render, screen, within } from '@testing-library/react';+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';import { createInstance } from 'i18next';import userEvent from '@testing-library/user-event';import { I18nextProvider, initReactI18next } from 'react-i18next';@@ -70,6 +70,154 @@ const openCodeAgent: AgentSupply = {afterEach(cleanup);+describe('AgentCard origin help ownership', () => {+ const agents: AgentSupply[] = ['claude', 'codex'].map((backend) => ({+ ...hubAgent,+ backend: backend as AgentSupply['backend'],+ catalog_models: ['shared-model', 'second-model'].map((id) => ({+ id, display_name: null, origin: 'manual', models_dev_id: null, context_window: null, max_output_tokens: null,+ input_modalities: ['text'], output_modalities: ['text'], supports_tools: true, supports_reasoning: false,+ reasoning_efforts: [], locked: false, routeable: true,+ })),+ model_supply: ['shared-model', 'second-model'].map((model_id) => ({+ model_id, route_origin: 'automatic', chain_length: 1, has_runnable_hop: true,+ })),+ }));+ const setup = () => {+ const onOpenRoute = vi.fn();+ const collection = (nextAgents = agents) => <I18nextProvider i18n={i18n}><AgentCard+ agents={nextAgents} sources={[]} chains={{}} pendingBackends={new Set()}+ switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()}+ onSwitchDirect={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={onOpenRoute} onProbeSettled={vi.fn()}+ /></I18nextProvider>;+ const view = render(collection());+ const badge = (backend: string, model = 'shared-model') => within(+ document.querySelector<HTMLElement>(`[data-route-backend="${backend}"][data-route-model="${model}"]`)!,+ ).getByRole('button', { name: 'Automatic' });+ return { ...view, collection, badge, onOpenRoute };+ };+ const onlyHelpFor = (trigger: HTMLElement) => {+ const help = document.getElementById(trigger.getAttribute('aria-controls')!);+ expect(help).not.toBeNull();+ expect([...document.querySelectorAll('.model-hub-origin-help')]).toEqual([help]);+ expect(trigger.getAttribute('aria-expanded')).toBe('true');+ return help!;+ };+ const mouse = (target: HTMLElement, type: 'pointerover' | 'pointerout') => {+ const event = new MouseEvent(type, { bubbles: true });+ Object.defineProperty(event, 'pointerType', { value: 'mouse' });+ fireEvent(target, event);+ };+ afterEach(() => { vi.useRealTimers(); });++ it.each(['focus', 'pin'] as const)('a new backend hover replaces the old %s even while its trigger stays focused', async (activation) => {+ const user = userEvent.setup();+ const { badge, onOpenRoute } = setup();+ const first = badge('claude');+ const second = badge('codex');+ if (activation === 'pin') await user.click(first);+ else act(() => first.focus());+ onlyHelpFor(first);+ await user.hover(second);+ expect(document.activeElement).toBe(first);+ await waitFor(() => onlyHelpFor(second));+ expect(first.getAttribute('aria-expanded')).toBe('false');+ // A late blur from the replaced trigger must not dismiss the new help.+ act(() => first.blur());+ onlyHelpFor(second);+ expect(onOpenRoute).not.toHaveBeenCalled();+ });++ it('focus and touch replace pinned help across rows, then unpin, Escape and outside dismiss normally', async () => {+ const user = userEvent.setup();+ const { badge, onOpenRoute } = setup();+ const first = badge('claude');+ const second = badge('claude', 'second-model');+ const third = badge('codex');+ await user.click(first);+ act(() => second.focus());+ await waitFor(() => onlyHelpFor(second));+ await user.pointer([{ keys: '[TouchA>]', target: third }, { keys: '[/TouchA]' }]);+ await waitFor(() => onlyHelpFor(third));+ await user.pointer([{ keys: '[TouchA>]', target: third }, { keys: '[/TouchA]' }]);+ await waitFor(() => expect(document.querySelector('.model-hub-origin-help')).toBeNull());+ act(() => first.focus());+ onlyHelpFor(first);+ await user.keyboard('{Escape}');+ expect(document.querySelector('.model-hub-origin-help')).toBeNull();+ await user.click(second);+ onlyHelpFor(second);+ await user.click(document.body);+ expect(document.querySelector('.model-hub-origin-help')).toBeNull();+ expect(onOpenRoute).not.toHaveBeenCalled();+ });++ it('old leave timers cannot close the newly active backend help', () => {+ vi.useFakeTimers();+ const { badge } = setup();+ const first = badge('claude');+ const second = badge('codex');+ mouse(first, 'pointerover');+ mouse(first, 'pointerout');+ mouse(second, 'pointerover');+ onlyHelpFor(second);+ // Even a queued leave event delivered after replacement is key-scoped.+ mouse(first, 'pointerout');+ act(() => vi.advanceTimersByTime(121));+ onlyHelpFor(second);+ });++ it('keeps the 120ms pointer bridge and content hover, then closes after leaving both', () => {+ vi.useFakeTimers();+ const { badge } = setup();+ const trigger = badge('claude');+ mouse(trigger, 'pointerover');+ const help = onlyHelpFor(trigger);+ mouse(trigger, 'pointerout');+ act(() => vi.advanceTimersByTime(119));+ onlyHelpFor(trigger);+ mouse(help, 'pointerover');+ act(() => vi.advanceTimersByTime(121));+ onlyHelpFor(trigger);+ mouse(help, 'pointerout');+ act(() => vi.advanceTimersByTime(120));+ expect(document.querySelector('.model-hub-origin-help')).toBeNull();+ });++ it('clears a removed active row without reviving its pin when it returns', async () => {+ const user = userEvent.setup();+ const { badge, rerender, collection } = setup();+ await user.click(badge('claude'));+ rerender(collection([{ ...agents[0], catalog_models: agents[0].catalog_models!.slice(1) }, agents[1]]));+ expect(document.querySelector('.model-hub-origin-help')).toBeNull();+ rerender(collection());+ expect(document.querySelector('.model-hub-origin-help')).toBeNull();+ await user.hover(badge('claude'));+ onlyHelpFor(badge('claude'));+ await user.hover(badge('codex'));+ await waitFor(() => onlyHelpFor(badge('codex')));+ rerender(collection([agents[1]]));+ onlyHelpFor(badge('codex'));+ });++ it('cancels pending help on collection unmount and keeps row opening independent', () => {+ vi.useFakeTimers();+ const { badge, unmount, onOpenRoute } = setup();+ const trigger = badge('claude');+ fireEvent.click(trigger);+ expect(onOpenRoute).not.toHaveBeenCalled();+ const row = trigger.closest<HTMLElement>('.model-hub-model-row')!;+ fireEvent.click(within(row).getByRole('button', { name: /route chain/ }));+ expect(onOpenRoute).toHaveBeenCalledWith(agents[0], 'shared-model', row.querySelector('.model-hub-model-open'));+ fireEvent.click(trigger);+ mouse(badge('codex'), 'pointerover');+ mouse(badge('codex'), 'pointerout');+ unmount();+ act(() => vi.advanceTimersByTime(121));+ expect(document.querySelector('.model-hub-origin-help')).toBeNull();+ });+});+describe('AgentCard', () => {it('renders an empty OpenCode selection as configurable rather than as missing backend supply', async () => {const onOpenModels = vi.fn();diff --git a/ui/src/components/settings/models/AgentCard.tsx b/ui/src/components/settings/models/AgentCard.tsxindex 299ce6f98..813f4b9ff 100644--- a/ui/src/components/settings/models/AgentCard.tsx+++ b/ui/src/components/settings/models/AgentCard.tsx@@ -62,9 +62,13 @@ const ModelRow: React.FC<{modelId: string;sources: Source[];read: ModelChainRead | undefined;+ originHelpOpen: boolean;+ onOriginHelpChange: (key: string, open: boolean) => void;onOpenRoute: (agent: AgentSupply, modelId: string, opener: HTMLElement) => void;-}> = ({ agent, modelId, sources, read, onOpenRoute }) => {+}> = ({ agent, modelId, sources, read, originHelpOpen, onOriginHelpChange, onOpenRoute }) => {const { t } = useTranslation();+ const helpKey = modelChainKey(agent.backend, modelId);+ const onHelpOpenChange = React.useCallback((open: boolean) => onOriginHelpChange(helpKey, open), [helpKey, onOriginHelpChange]);const current = currentLink(read);const takeover = isTakeoverRead(read);const supplyState = modelSupplyState(agent, modelId);@@ -95,7 +99,7 @@ const ModelRow: React.FC<{<span className="pointer-events-none flex min-w-0 flex-1 items-center justify-between gap-2.5"><span className="min-w-0 flex-1 truncate font-mono text-[12px] font-medium text-foreground" title={modelId}>{modelId}</span><span className="flex min-w-0 flex-1 items-center justify-end gap-[7px]">- <span className="pointer-events-auto relative shrink-0"><RouteOriginBadge origin={routeOrigin} backend={agent.backend} /></span>+ <span className="pointer-events-auto relative shrink-0"><RouteOriginBadge origin={routeOrigin} backend={agent.backend} open={originHelpOpen} onOpenChange={onHelpOpenChange} /></span>{hasCurrentMapping ? (<spanclassName={cn('model-hub-model-current min-w-0 flex-1 truncate text-right text-[10.5px]', takeover && 'model-hub-model-current--takeover')}@@ -122,13 +126,15 @@ const AgentModelCard: React.FC<{pending: boolean;connecting: boolean;switchFailed: boolean;+ activeOriginHelp: string | null;+ onOriginHelpChange: (key: string, open: boolean) => void;onConnectHub: (agent: AgentSupply) => void;onSwitchDirect: (agent: AgentSupply) => void;onOpenModels: (agent: AgentSupply) => void;onOpenOrder: (agent: AgentSupply) => void;onOpenRoute: (agent: AgentSupply, modelId: string, opener: HTMLElement) => void;onProbeSettled: (agent: AgentSupply) => void;-}> = ({ agent, runtime, sources, chains, pending, connecting, switchFailed, onConnectHub, onSwitchDirect, onOpenModels, onOpenOrder, onOpenRoute, onProbeSettled }) => {+}> = ({ agent, runtime, sources, chains, pending, connecting, switchFailed, activeOriginHelp, onOriginHelpChange, onConnectHub, onSwitchDirect, onOpenModels, onOpenOrder, onOpenRoute, onProbeSettled }) => {const { t } = useTranslation();const { Icon, accent } = backendVisual(agent.backend);const [expanded, setExpanded] = React.useState(false);@@ -255,7 +261,7 @@ const AgentModelCard: React.FC<{) : <Button variant="default" size="xs" className="model-hub-agent-head-action shrink-0 self-start rounded-md px-2.5 text-[11px] font-semibold sm:self-auto" onClick={() => onConnectHub(agent)} disabled={connecting}><PlugZap aria-hidden="true" />{t('settings.models.gateway.switchToGateway')}</Button>}</div></div>- {agent.mode === 'hub' && (models.length === 0 ? <div className="flex flex-col items-center gap-3 px-4 py-10 text-center sm:px-5"><p className="text-[12.5px] text-muted">{t('settings.models.gateway.group.emptyModels')}</p><ManageModelsButton disabled={pending} onClick={() => onOpenModels(agent)} /></div> : <div className="space-y-2 p-2">{noUsableSource && <p className="px-3 py-1 text-[11px] font-semibold text-muted">{t('settings.models.gateway.supply.none')}</p>}{models.map((modelId) => <ModelRow key={modelId} agent={agent} modelId={modelId} sources={sources} read={chainProjectionLive ? chains[modelChainKey(agent.backend, modelId)] : undefined} onOpenRoute={onOpenRoute} />)}{canCollapse ? <button type="button" onClick={toggleCollapsed} className="model-hub-model-collapse flex h-6 w-full items-center gap-1.5 hover:text-foreground">{expanded ? <ChevronUp /> : <ChevronDown />}{expanded ? t('settings.models.gateway.collapse') : t('settings.models.gateway.moreModels', { count: collapsed.hidden.length })}</button> : needsChainRepair ? <button type="button" onClick={retryChains} className="model-hub-model-collapse flex h-6 w-full items-center gap-1.5 hover:text-foreground"><RefreshCw />{t('settings.models.gateway.retry')}</button> : null}</div>)}+ {agent.mode === 'hub' && (models.length === 0 ? <div className="flex flex-col items-center gap-3 px-4 py-10 text-center sm:px-5"><p className="text-[12.5px] text-muted">{t('settings.models.gateway.group.emptyModels')}</p><ManageModelsButton disabled={pending} onClick={() => onOpenModels(agent)} /></div> : <div className="space-y-2 p-2">{noUsableSource && <p className="px-3 py-1 text-[11px] font-semibold text-muted">{t('settings.models.gateway.supply.none')}</p>}{models.map((modelId) => <ModelRow key={modelId} agent={agent} modelId={modelId} sources={sources} read={chainProjectionLive ? chains[modelChainKey(agent.backend, modelId)] : undefined} originHelpOpen={activeOriginHelp === modelChainKey(agent.backend, modelId)} onOriginHelpChange={onOriginHelpChange} onOpenRoute={onOpenRoute} />)}{canCollapse ? <button type="button" onClick={toggleCollapsed} className="model-hub-model-collapse flex h-6 w-full items-center gap-1.5 hover:text-foreground">{expanded ? <ChevronUp /> : <ChevronDown />}{expanded ? t('settings.models.gateway.collapse') : t('settings.models.gateway.moreModels', { count: collapsed.hidden.length })}</button> : needsChainRepair ? <button type="button" onClick={retryChains} className="model-hub-model-collapse flex h-6 w-full items-center gap-1.5 hover:text-foreground"><RefreshCw />{t('settings.models.gateway.retry')}</button> : null}</div>)}</section>);};@@ -274,4 +280,11 @@ export const AgentCard: React.FC<{onOpenRoute: (agent: AgentSupply, modelId: string, opener: HTMLElement) => void;onProbeSettled: (agent: AgentSupply) => void;connectingBackend: string | null;-}> = ({ agents, pendingBackends, switchFailures, connectingBackend, ...props }) => <div className="flex flex-col gap-2.5">{agents.map((agent) => <AgentModelCard key={agent.backend} agent={agent} {...props} pending={pendingBackends.has(agent.backend)} switchFailed={switchFailures.has(agent.backend)} connecting={connectingBackend === agent.backend} />)}</div>;+}> = ({ agents, pendingBackends, switchFailures, connectingBackend, ...props }) => {+ const [activeOriginHelp, setActiveOriginHelp] = React.useState<string | null>(null);+ const onOriginHelpChange = React.useCallback((key: string, open: boolean) => {+ // Late blur, leave timers and row cleanup can dismiss only their own help.+ setActiveOriginHelp((current) => open ? key : current === key ? null : current);+ }, []);+ return <div className="flex flex-col gap-2.5">{agents.map((agent) => <AgentModelCard key={agent.backend} agent={agent} {...props} activeOriginHelp={activeOriginHelp} onOriginHelpChange={onOriginHelpChange} pending={pendingBackends.has(agent.backend)} switchFailed={switchFailures.has(agent.backend)} connecting={connectingBackend === agent.backend} />)}</div>;+};diff --git a/ui/src/components/settings/models/RouteChainDialog.test.tsx b/ui/src/components/settings/models/RouteChainDialog.test.tsxindex 46f352cc8..98648a92f 100644--- a/ui/src/components/settings/models/RouteChainDialog.test.tsx+++ b/ui/src/components/settings/models/RouteChainDialog.test.tsx@@ -187,6 +187,60 @@ afterEach(() => {});describe("RouteChainDialog", () => {+ it.each(['manual', 'inherited', 'preview', 'missing', 'stale'] as const)(+ 'exposes complete same-prefix source/model identities as wrapping detail text in %s state', async (state) => {+ const user = userEvent.setup();+ const prefix = 'exact-identity-with-a-very-long-shared-prefix-';+ const identities = ['alpha', 'omega'].map((suffix) => ({+ source_id: `${prefix}source-${suffix}`, model_id: `${prefix}model-${suffix}`,+ }));+ const detailedSources = identities.map((hop) => ({ ...sources[0], id: hop.source_id, display_name: hop.source_id }));+ const detailedAgent: AgentSupply = { ...agent, sources: {+ order: [], eligibility: identities.map((hop) => ({ source_id: hop.source_id, eligible: true })),+ } };+ const projection: AgentChain = {+ ...chain,+ route_origin: state === 'inherited' ? 'automatic' : 'manual',+ manual_override: state === 'inherited' ? null : { hops: identities },+ current: identities[0],+ chain: identities.map((hop) => ({+ ...chain.chain[1], ...hop,+ reason: state === 'missing' ? 'source_missing' : null,+ runnable: state !== 'missing',+ })),+ };+ const inherited: AgentChain = { ...projection, manual_override: null, route_origin: 'automatic' };+ vi.spyOn(modelsApi, 'getAgentChain').mockResolvedValue(projection);+ vi.spyOn(modelsApi, 'previewAgentChain').mockResolvedValue(inherited);+ render(<I18nextProvider i18n={i18n}><RouteChainDialog+ selection={{ agent: detailedAgent, modelId: 'opus-5', read: readyRegion(projection) }}+ sources={state === 'missing' || state === 'stale' ? [] : detailedSources}+ onClose={vi.fn()} readAgents={vi.fn()} readSources={vi.fn()}+ /></I18nextProvider>);+ await waitFor(() => expect(document.querySelectorAll('.model-hub-route-hop-name')).toHaveLength(2));+ if (state === 'preview') {+ await user.click(screen.getByRole('button', { name: 'Restore automatic' }));+ await screen.findByRole('button', { name: 'Undo restore' });+ }+ const names = [...document.querySelectorAll('.model-hub-route-hop-name')];+ const models = [...document.querySelectorAll('.model-hub-route-hop-model')];+ identities.forEach((hop, index) => {+ expect(names[index].textContent).toContain(hop.source_id);+ expect(models[index].textContent).toBe(hop.model_id);+ for (const field of [names[index], models[index]]) {+ expect(field.classList.contains('truncate')).toBe(false);+ expect(field.closest('.model-hub-route-hop-copy')?.classList.contains('min-w-0')).toBe(true);+ }+ });+ const footer = within(document.querySelector<HTMLElement>('.model-hub-route-foot')!);+ const labels = state === 'inherited' ? ['Close', 'Edit route']+ : [state === 'preview' ? 'Undo restore' : 'Restore automatic', 'Cancel', 'Save'];+ expect(footer.getAllByRole('button').map((button) => button.textContent)).toEqual(labels);+ for (const label of labels) expect(footer.getByRole('button', { name: label }).hasAttribute('hidden')).toBe(false);+ expect(screen.getByRole('dialog').classList.contains('overflow-hidden')).toBe(true);+ },+ );+it('closes inherited inspection with visible Close, not the icon-only Cancel command', async () => {const user = userEvent.setup();const inherited: AgentChain = { ...chain, manual_override: null, route_origin: 'automatic' };diff --git a/ui/src/components/settings/models/RouteChainDialog.tsx b/ui/src/components/settings/models/RouteChainDialog.tsxindex 33b98bf7f..e4b46983c 100644--- a/ui/src/components/settings/models/RouteChainDialog.tsx+++ b/ui/src/components/settings/models/RouteChainDialog.tsx@@ -776,7 +776,7 @@ export const RouteChainDialog: React.FC<{</span><span className="model-hub-route-hop-copy flex min-w-0 flex-1 flex-col"><span- className="model-hub-route-hop-name truncate font-semibold text-foreground"+ className="model-hub-route-hop-name font-semibold text-foreground"title={displayedSource}>{missing ? (@@ -791,7 +791,7 @@ export const RouteChainDialog: React.FC<{)}</span><span- className="model-hub-route-hop-model model-hub-ink-muted-b3 truncate font-mono"+ className="model-hub-route-hop-model model-hub-ink-muted-b3 font-mono"title={hop.model_id}>{hop.model_id}@@ -1039,8 +1039,8 @@ export const RouteChainDialog: React.FC<{<div key={`${hop.source_id}:${hop.model_id}`} className="model-hub-route-hop model-hub-fill-08 flex items-center border border-border"><span className="model-hub-route-ordinal grid shrink-0 place-items-center font-mono" data-origin={draftOrigin ?? 'unconfigured'}>{index + 1}</span><span className="model-hub-route-hop-copy flex min-w-0 flex-1 flex-col">- <span className="model-hub-route-hop-name truncate font-semibold" title={sourceName(sources, hop.source_id)}>{sourceName(sources, hop.source_id)}</span>- <span className="model-hub-route-hop-model truncate font-mono text-muted" title={hop.model_id}>{hop.model_id}</span>+ <span className="model-hub-route-hop-name font-semibold" title={sourceName(sources, hop.source_id)}>{sourceName(sources, hop.source_id)}</span>+ <span className="model-hub-route-hop-model font-mono text-muted" title={hop.model_id}>{hop.model_id}</span></span></div>))diff --git a/ui/src/components/settings/models/RouteOriginBadge.test.tsx b/ui/src/components/settings/models/RouteOriginBadge.test.tsxindex 388a0bf8f..a068fd2f8 100644--- a/ui/src/components/settings/models/RouteOriginBadge.test.tsx+++ b/ui/src/components/settings/models/RouteOriginBadge.test.tsx@@ -5,13 +5,26 @@ import { I18nextProvider } from 'react-i18next';import { afterEach, describe, expect, it, vi } from 'vitest';import i18n from '@/i18n';import { RouteOriginBadge } from './RouteOriginBadge';+import { useState } from 'react';++const ControlledBadge = () => {+ const [open, setOpen] = useState(false);+ return <RouteOriginBadge origin="passthrough" backend="codex" open={open} onOpenChange={setOpen} />;+};afterEach(cleanup);describe('route origin help', () => {+ it('keeps dialog provenance noninteractive and outside the collection help state', () => {+ render(<I18nextProvider i18n={i18n}><RouteOriginBadge origin="manual" backend="codex" interactive={false} /></I18nextProvider>);+ expect(screen.getByText('Manual').tagName).toBe('SPAN');+ expect(screen.queryByRole('button')).toBeNull();+ expect(document.querySelector('.model-hub-origin-help')).toBeNull();+ });+it('opens on focus, dismisses on Escape, and touch does not open the route', async () => {const user = userEvent.setup();const route = vi.fn();- render(<I18nextProvider i18n={i18n}><div onClick={route}><RouteOriginBadge origin="passthrough" backend="codex" /></div></I18nextProvider>);+ render(<I18nextProvider i18n={i18n}><div onClick={route}><ControlledBadge /></div></I18nextProvider>);await user.tab();expect(await screen.findByText(/eligible API-key providers/)).toBeTruthy();await user.keyboard('{Escape}');diff --git a/ui/src/components/settings/models/RouteOriginBadge.tsx b/ui/src/components/settings/models/RouteOriginBadge.tsxindex 43f01280c..6ca2a5656 100644--- a/ui/src/components/settings/models/RouteOriginBadge.tsx+++ b/ui/src/components/settings/models/RouteOriginBadge.tsx@@ -3,13 +3,17 @@ import { useTranslation } from 'react-i18next';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';import type { AgentBackend, RouteOrigin } from './types';-export function RouteOriginBadge({ origin, backend, interactive = true }: {+type RouteOriginBadgeProps = {origin: RouteOrigin;backend: AgentBackend;- interactive?: boolean;-}) {+} & ({ interactive: false; open?: never; onOpenChange?: never } | {+ interactive?: true;+ open: boolean;+ onOpenChange: (open: boolean) => void;+});++export function RouteOriginBadge({ origin, backend, interactive = true, open = false, onOpenChange }: RouteOriginBadgeProps) {const { t } = useTranslation();- const [open, setOpen] = React.useState(false);const pinned = React.useRef(false);const dismissal = React.useRef<ReturnType<typeof setTimeout> | null>(null);const trigger = React.useRef<HTMLButtonElement>(null);@@ -17,25 +21,38 @@ export function RouteOriginBadge({ origin, backend, interactive = true }: {const key = origin ?? 'unconfigured';const label = t(`settings.models.routing.origin.${key}`);const className = `model-hub-route-origin model-hub-route-origin--${key}`;- const cancelDismissal = () => { if (dismissal.current) clearTimeout(dismissal.current); };- React.useEffect(() => () => { if (dismissal.current) clearTimeout(dismissal.current); }, []);+ const cancelDismissal = React.useCallback(() => {+ if (dismissal.current !== null) clearTimeout(dismissal.current);+ dismissal.current = null;+ }, []);+ React.useEffect(() => {+ if (!open) { cancelDismissal(); pinned.current = false; }+ }, [open, cancelDismissal]);+ React.useEffect(() => () => {+ cancelDismissal();+ onOpenChange?.(false);+ }, [cancelDismissal, onOpenChange]);if (!interactive) return <span className={className}>{label}</span>;- const close = () => { cancelDismissal(); pinned.current = false; setOpen(false); };+ const close = () => { cancelDismissal(); pinned.current = false; onOpenChange?.(false); };+ const activate = () => { cancelDismissal(); onOpenChange?.(true); };const leave = (event: React.PointerEvent) => {if (event.pointerType !== 'mouse' || pinned.current) return;const target = event.relatedTarget;if (target instanceof Node && (trigger.current?.contains(target) || content.current?.contains(target))) return;- if (document.activeElement !== trigger.current) dismissal.current = setTimeout(() => setOpen(false), 120);+ if (document.activeElement !== trigger.current) {+ cancelDismissal();+ dismissal.current = setTimeout(close, 120);+ }};return (<Popover open={open} onOpenChange={(next) => { if (!next) close(); }}><PopoverTrigger asChild><button ref={trigger} type="button" className={className} aria-label={label}- onPointerEnter={(event) => { if (event.pointerType === 'mouse') { cancelDismissal(); setOpen(true); } }}+ onPointerEnter={(event) => { if (event.pointerType === 'mouse') activate(); }}onPointerLeave={leave}- onFocus={() => setOpen(true)}- onBlur={() => { if (!pinned.current) setOpen(false); }}- onClick={(event) => { event.preventDefault(); event.stopPropagation(); pinned.current = !pinned.current; setOpen(pinned.current); }}+ onFocus={activate}+ onBlur={() => { if (!pinned.current) close(); }}+ onClick={(event) => { event.preventDefault(); event.stopPropagation(); cancelDismissal(); pinned.current = !pinned.current; onOpenChange?.(pinned.current); }}>{label}</button></PopoverTrigger><PopoverContent ref={content} className="model-hub-origin-help" sideOffset={6}diff --git a/ui/src/components/settings/models/modelHubStylePolicy.test.ts b/ui/src/components/settings/models/modelHubStylePolicy.test.tsindex 04147e43d..3346a6322 100644--- a/ui/src/components/settings/models/modelHubStylePolicy.test.ts+++ b/ui/src/components/settings/models/modelHubStylePolicy.test.ts@@ -1,5 +1,6 @@import { readdirSync, readFileSync } from 'node:fs';import { join } from 'node:path';+import postcss from 'postcss';import { describe, expect, it } from 'vitest';@@ -36,6 +37,45 @@ describe('Model Hub theme token policy', () => {});describe('Model Hub visual token policy', () => {+ it('lets the actual narrow footer grow after the complete surface cascade while preserving body scroll', () => {+ // This checks CSS ownership and source order, not browser geometry.+ const root = postcss.parse(surfaceCss);+ const footer: Record<string, string> = {};+ root.walkRules('.model-hub-route-foot', (rule) => {+ expect(rule.parent?.type === 'root' || (rule.parent?.type === 'atrule'+ && rule.parent.name === 'media' && rule.parent.params === '(max-width: 640px)')).toBe(true);+ rule.walkDecls((decl) => { footer[decl.prop] = decl.value; });+ });+ expect(footer).toMatchObject({+ height: 'auto', 'min-height': 'var(--model-hub-dialog-foot-height)',+ 'flex-wrap': 'wrap', 'flex-shrink': '0',+ });+ root.walkRules('.model-hub-route-body', (rule) => {+ const body: Record<string, string> = {};+ rule.walkDecls((decl) => { body[decl.prop] = decl.value; });+ expect(body).toMatchObject({ 'min-height': '0', flex: '0 1 auto', 'overflow-y': 'auto' });+ });+ });++ it('grows detail rows from their approved minimum and wraps exact unbroken identities', () => {+ const root = postcss.parse(surfaceCss);+ const declarations = (selector: string) => {+ const values: Record<string, string> = {};+ root.walkRules((rule) => {+ if (rule.parent?.type === 'root' && rule.selectors.includes(selector)) {+ rule.walkDecls((decl) => { values[decl.prop] = decl.value; });+ }+ });+ return values;+ };+ expect(declarations('.model-hub-route-hop')).toMatchObject({+ 'min-height': 'var(--model-hub-route-hop-height)', height: 'auto', padding: '6px 10px',+ });+ for (const selector of ['.model-hub-route-hop-name', '.model-hub-route-hop-model']) {+ expect(declarations(selector)).toMatchObject({ 'overflow-wrap': 'anywhere', 'white-space': 'normal' });+ }+ });+it('lets the settings route pane own overview scrolling', () => {const overviewGrid = surfaceCss.match(/\.model-hub-overview-grid\s*\{([^}]*)\}/)?.[1] ?? '';const overviewBody = surfaceCss.match(/\.model-hub-overview-body\s*\{([^}]*)\}/)?.[1] ?? '';diff --git a/ui/src/components/settings/models/modelHubSurface.css b/ui/src/components/settings/models/modelHubSurface.cssindex f9c997b9c..c5a5d1802 100644--- a/ui/src/components/settings/models/modelHubSurface.css+++ b/ui/src/components/settings/models/modelHubSurface.css@@ -549,7 +549,6 @@.model-hub-model-row > span { flex-wrap: wrap; padding-bottom: 24px; }.model-hub-model-row > span > span:first-child { flex: 1; }.model-hub-model-row .model-hub-model-current { position: absolute; left: 12px; right: 32px; bottom: 10px; text-align: left; }- .model-hub-route-foot { flex-wrap: wrap; min-height: var(--model-hub-dialog-foot-height); height: auto; }}.model-hub-model-row {border-radius: 8px;@@ -1066,8 +1065,9 @@.model-hub-route-hop {--model-hub-route-hop-gap: 10px;--model-hub-route-hop-height: 52px;- height: var(--model-hub-route-hop-height);- padding-inline: 10px;+ min-height: var(--model-hub-route-hop-height);+ height: auto;+ padding: 6px 10px;gap: var(--model-hub-route-hop-gap);border-radius: var(--model-hub-route-hop-radius);}@@ -1080,6 +1080,8 @@font-size: 11px;}.model-hub-route-hop-copy { gap: 3px; }+.model-hub-route-hop-name,+.model-hub-route-hop-model { white-space: normal; overflow-wrap: anywhere; }.model-hub-route-hop-name { font-size: 12px; }.model-hub-route-hop-model { font-size: 10.5px; }.model-hub-route-grip { width: 14px; height: 14px; color: var(--model-hub-ink-4d); }@@ -1180,6 +1182,9 @@.model-hub-route-hint > svg { width: 13px; height: 13px; }.model-hub-route-hint-copy { width: 420px; max-width: calc(100% - 20px); }.model-hub-route-foot { height: var(--model-hub-dialog-foot-height); flex-shrink: 0; padding: 14px 20px; border-color: var(--model-hub-wash-14); }+@media (max-width: 640px) {+ .model-hub-route-foot { flex-wrap: wrap; min-height: var(--model-hub-dialog-foot-height); height: auto; }+}.model-hub-source-detail {--model-hub-source-gap: 0px;