Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(ui): keep model routes and gateway actions readable (#1988)

Call Whiteddf77d80bf31
diff --git a/ui/e2e/model-catalog/README.md b/ui/e2e/model-catalog/README.md
index 4562f08a9..06a8238b8 100644
--- a/ui/e2e/model-catalog/README.md
+++ b/ui/e2e/model-catalog/README.md
@@ -31,6 +31,12 @@ footer. Every localized route status fits the existing compact control, includin
a wider fallback-font check. These are browser layout contracts, not live routing
or backend acceptance.
+`gateway-layout.spec.ts` extends `MH-GATEWAY-STATUS-001` with fixed header rows:
+backend title/status above model count/two horizontal actions, and route mappings
+below model IDs. It checks all three backends in EN/ZH, narrow desktop columns
+and mobile viewports (320–418px), plus the unchanged direct-mode entry point.
+The fixture inherits the production overview action-size tokens.
+
`route-direct-edit.spec.ts` consumes `MH-ROUTING-007` through the production
route dialog. All backends and origins open directly editable without writing;
Cancel changes rereads saved intent in place, nested picker dismissal preserves
diff --git a/ui/e2e/model-catalog/gateway-layout.spec.ts b/ui/e2e/model-catalog/gateway-layout.spec.ts
new file mode 100644
index 000000000..1d8e6b13e
--- /dev/null
+++ b/ui/e2e/model-catalog/gateway-layout.spec.ts
@@ -0,0 +1,73 @@
+import { expect, test, type Locator } from '@playwright/test';
+import { hub } from '../support/copy';
+
+const box = async (locator: Locator) => {
+ await expect(locator).toBeVisible();
+ return (await locator.boundingBox())!;
+};
+const centerY = (bounds: Awaited<ReturnType<typeof box>>) => bounds.y + bounds.height / 2;
+
+for (const backend of ['claude', 'codex', 'opencode']) {
+ for (const lang of ['en', 'zh'] as const) {
+ test(`MH-GATEWAY-STATUS-001: fixed two-row header and separate model mapping (${backend}, ${lang})`, async ({ page }, testInfo) => {
+ await page.goto(`/e2e/model-catalog/fixture.html?view=gateway&backend=${backend}&lang=${lang}`);
+ const main = page.locator('main');
+ const card = page.locator(`[data-agent-backend="${backend}"]`);
+ const head = card.locator('[data-agent-group-head]');
+ const title = head.getByRole('heading', { level: 2 });
+ const status = head.locator('.model-hub-agent-mode-trigger');
+ const count = head.locator('.model-hub-pill');
+ const manage = head.getByRole('button', { name: hub('gateway.manageModels', {}, lang), exact: true });
+ const order = head.getByRole('button', { name: hub('gateway.sourceOrder', {}, lang), exact: true });
+
+ // A narrow desktop column is not a phone viewport. Exercise both.
+ const widths = testInfo.project.name === 'desktop' ? [418, 360, 320] : [390, 360, 320];
+ for (const width of widths) {
+ await test.step(`column ${width}px`, async () => {
+ if (testInfo.project.name === 'mobile') await page.setViewportSize({ width, height: 844 });
+ await main.evaluate((element, size) => { element.style.width = `${size}px`; }, width);
+ const [titleBox, statusBox, countBox, manageBox, orderBox, headBox] = await Promise.all(
+ [title, status, count, manage, order, head].map(box),
+ );
+ expect(Math.abs(centerY(titleBox) - centerY(statusBox))).toBeLessThanOrEqual(1);
+ expect(titleBox.x + titleBox.width).toBeLessThanOrEqual(statusBox.x);
+ expect(manageBox.y).toBeGreaterThanOrEqual(statusBox.y + statusBox.height);
+ expect(Math.abs(centerY(countBox) - centerY(manageBox))).toBeLessThanOrEqual(1);
+ expect(Math.abs(manageBox.y - orderBox.y)).toBeLessThanOrEqual(1);
+ expect(countBox.x + countBox.width).toBeLessThanOrEqual(manageBox.x);
+ expect(manageBox.x + manageBox.width).toBeLessThan(orderBox.x);
+ expect(orderBox.x + orderBox.width).toBeLessThan(headBox.x + headBox.width);
+ for (const action of [manage, order]) {
+ expect(await action.evaluate((element) => element.scrollWidth <= element.clientWidth + 1)).toBe(true);
+ }
+ if (width >= 360) {
+ for (const label of [title, count.locator('span'), status.locator('span').last()]) {
+ expect(await label.evaluate((element) => element.scrollWidth <= element.clientWidth + 1)).toBe(true);
+ }
+ }
+
+ const model = card.locator('[data-route-model="claude-fable-5-1"]');
+ const id = model.locator('[title="claude-fable-5-1"]');
+ const mapping = model.locator('[data-route-mapping]');
+ const [idBox, mappingBox] = await Promise.all([box(id), box(mapping)]);
+ await expect(mapping).toContainText('Primary');
+ expect(mappingBox.y).toBeGreaterThanOrEqual(idBox.y + idBox.height);
+ expect(Math.abs(mappingBox.x - idBox.x)).toBeLessThanOrEqual(1);
+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
+ if (width === widths[0]) {
+ await main.screenshot({ path: testInfo.outputPath('gateway-layout.png'), scale: 'css' });
+ }
+ });
+ }
+
+ await page.goto(`/e2e/model-catalog/fixture.html?view=gateway&backend=${backend}&lang=${lang}&mode=direct`);
+ const connect = head.getByRole('button', { name: hub('gateway.switchToGateway', {}, lang), exact: true });
+ await expect(status).toHaveCount(0);
+ await expect(card.locator('[data-route-model]')).toHaveCount(0);
+ const [directTitle, directCount, connectBox] = await Promise.all([box(title), box(count), box(connect)]);
+ expect(connectBox.y).toBeGreaterThanOrEqual(directTitle.y + directTitle.height);
+ expect(Math.abs(centerY(directCount) - centerY(connectBox))).toBeLessThanOrEqual(1);
+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
+ });
+ }
+}
diff --git a/ui/e2e/model-catalog/gatewayFixture.tsx b/ui/e2e/model-catalog/gatewayFixture.tsx
index e67ce2d45..c7eb41f3c 100644
--- a/ui/e2e/model-catalog/gatewayFixture.tsx
+++ b/ui/e2e/model-catalog/gatewayFixture.tsx
@@ -9,6 +9,9 @@ export function GatewayFixture() {
const params = new URLSearchParams(location.search);
const long = params.has('long');
const status = params.get('status') ?? 'available';
+ const requestedBackend = params.get('backend');
+ const backend = requestedBackend === 'claude' || requestedBackend === 'codex' ? requestedBackend : 'opencode';
+ const direct = params.get('mode') === 'direct';
const ids = ['claude-fable-5', 'claude-opus-4-8', 'claude-fable-5-1', 'claude-opus-5', 'claude-sonnet-5'];
const source: Source = {
id: 'src_fixture', display_name: 'Primary', kind: 'api_key', vendor: 'anthropic',
@@ -17,7 +20,7 @@ export function GatewayFixture() {
models: ids.map((id) => ({ id, origin: 'discovered', reasoning_efforts: [], reasoning_efforts_source: null })),
};
const agent: AgentSupply = {
- backend: 'opencode', cli_present: true, mode: 'hub', menu_kind: 'open',
+ backend, cli_present: true, mode: direct ? 'direct' : 'hub', menu_kind: 'open',
catalog_models: status === 'empty' ? [] : ids.map((id) => ({ ...blankBackendModel(), id })),
sources: { order: [source.id], eligibility: [{ source_id: source.id, eligible: true }] },
model_supply: status === 'unknown' ? [] : ids.map((model_id, index) => ({
@@ -30,8 +33,8 @@ export function GatewayFixture() {
route_reason: 'route_unconfigured', supply_status: 'interrupted',
}],
};
- const chains = Object.fromEntries(ids.map((model_id) => [modelChainKey('opencode', model_id), readyRegion<AgentChain>({
- contract_version: 10, backend: 'opencode', model_id, route_origin: 'automatic', manual_override: null,
+ const chains = Object.fromEntries(ids.map((model_id) => [modelChainKey(backend, model_id), readyRegion<AgentChain>({
+ contract_version: 10, backend, model_id, route_origin: 'automatic', manual_override: null,
current: { source_id: source.id, model_id }, supply_state: 'ok',
chain: [{ source_id: source.id, model_id, channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }],
})]));
@@ -40,7 +43,7 @@ export function GatewayFixture() {
manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1.0.0', source_sha: 'fixture', assets: [] },
status: { installed_version: '1.0.0', verified: true, listening: null, health: 'ok', last_check: null },
}));
- return <main className="model-hub-shell mx-auto min-w-0 max-w-3xl p-4">
+ return <main className="model-hub-shell model-hub-overview mx-auto min-w-0 max-w-3xl p-4">
<AgentCard agents={[agent]} sources={[source]} chains={chains} runtime={runtime}
pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null}
onConnectHub={() => {}} onSwitchDirect={() => {}} onOpenModels={() => {}}
diff --git a/ui/src/components/settings/models/AgentCard.test.tsx b/ui/src/components/settings/models/AgentCard.test.tsx
index 7935d23e8..ac841480b 100644
--- a/ui/src/components/settings/models/AgentCard.test.tsx
+++ b/ui/src/components/settings/models/AgentCard.test.tsx
@@ -359,6 +359,8 @@ describe('AgentCard', () => {
expect(screen.getByText(/Backup/)).toBeTruthy();
expect(screen.getByTitle(mappingCopy)).toBeTruthy();
expect(screen.getByRole('button', { name: accessibleName })).toBeTruthy();
+ const takeover = screen.getByText(localeInstance(lng).t('settings.models.takeover.chip'));
+ expect(takeover.closest('.model-hub-agent-head-controls')).toBeTruthy();
});
it.each([
@@ -395,8 +397,11 @@ describe('AgentCard', () => {
const routeButton = screen.getByRole('button', { name: accessibleName });
const mapping = screen.getByTitle(mappingCopy);
- expect(routeButton.parentElement?.contains(mapping)).toBe(true);
- expect(mapping.parentElement?.textContent).toContain(lng === 'zh' ? '手动' : 'Manual');
+ const row = routeButton.closest('.model-hub-model-row');
+ expect(row).not.toBeNull();
+ expect(row?.contains(mapping)).toBe(true);
+ expect(mapping.closest('.model-hub-model-current')).toBe(mapping);
+ expect(row?.querySelector('.model-hub-route-origin')?.textContent).toContain(lng === 'zh' ? '手动' : 'Manual');
expect(modeCopy).toBeTruthy();
expect(mapping.textContent).toBe(mappingCopy);
});
@@ -475,10 +480,16 @@ describe('AgentCard', () => {
expect(order.querySelector('svg')).toBeTruthy();
expect(direct.querySelector('.lucide-power')).toBeTruthy();
expect(gateway.querySelector('svg')).toBeTruthy();
- expect(order.parentElement?.parentElement?.className).toContain('sm:flex-wrap');
- expect(order.parentElement?.className).toContain('items-center');
- expect(order.parentElement?.className).toContain('min-w-0');
- expect(order.parentElement?.parentElement?.parentElement?.className).toContain('min-h-[52px]');
+ expect(order.parentElement?.className).toContain('model-hub-agent-head-actions');
+ const header = order.closest('[data-agent-group-head]')!;
+ const summary = header.querySelector('.model-hub-agent-head-summary')!;
+ const controls = header.querySelector('.model-hub-agent-head-controls')!;
+ expect(summary.querySelector('h2')).toBeTruthy();
+ expect(summary.querySelector('.model-hub-agent-mode-trigger')).toBeTruthy();
+ expect(summary.querySelector('.model-hub-pill')).toBeNull();
+ expect(controls.querySelector('.model-hub-pill')).toBeTruthy();
+ expect(controls.contains(order)).toBe(true);
+ expect(gateway.closest('.model-hub-agent-head-controls')).toBeTruthy();
expect(gateway.className).toContain('bg-primary');
});
diff --git a/ui/src/components/settings/models/AgentCard.tsx b/ui/src/components/settings/models/AgentCard.tsx
index 1fcb9e981..842c3806f 100644
--- a/ui/src/components/settings/models/AgentCard.tsx
+++ b/ui/src/components/settings/models/AgentCard.tsx
@@ -93,25 +93,25 @@ const ModelRow: React.FC<{
<div
data-route-backend={agent.backend}
data-route-model={modelId}
- className="model-hub-model-row relative flex h-9 w-full min-w-0 items-center gap-2.5 rounded-md border border-border px-3 text-left"
+ className="model-hub-model-row relative flex h-[52px] w-full min-w-0 items-center gap-2.5 rounded-md border border-border px-3 text-left"
>
<button type="button" className="model-hub-model-open absolute inset-0 rounded-[inherit]" aria-label={openRouteLabel} onClick={(event) => onOpenRoute(agent, modelId, event.currentTarget)} />
- <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-none flex min-w-0 flex-1 flex-col justify-center gap-0.5 pr-1">
+ <span className="flex min-w-0 items-center gap-[7px]">
+ <span className="min-w-0 flex-1 truncate font-mono text-[12px] font-medium text-foreground" title={modelId}>{modelId}</span>
<span className="pointer-events-auto relative shrink-0"><RouteOriginBadge origin={routeOrigin} backend={agent.backend} open={originHelpOpen} onOpenChange={onHelpOpenChange} /></span>
- {hasCurrentMapping ? (
- <span
- className={cn('model-hub-model-current min-w-0 flex-1 truncate text-right text-[10.5px]', takeover && 'model-hub-model-current--takeover')}
- title={currentCopy}
- data-route-mapping
- >
- {currentCopy}
- </span>
- ) : (
- <span className={cn('model-hub-model-current min-w-0 flex-1 truncate text-right text-[10.5px]', supplyState === 'paused' && 'model-hub-ink-gold')} title={currentCopy}>{currentCopy}</span>
- )}
</span>
+ {hasCurrentMapping ? (
+ <span
+ className={cn('model-hub-model-current min-w-0 truncate text-left text-[10.5px]', takeover && 'model-hub-model-current--takeover')}
+ title={currentCopy}
+ data-route-mapping
+ >
+ {currentCopy}
+ </span>
+ ) : (
+ <span className={cn('model-hub-model-current min-w-0 truncate text-left text-[10.5px]', supplyState === 'paused' && 'model-hub-ink-gold')} title={currentCopy}>{currentCopy}</span>
+ )}
</span>
<ChevronRight className="model-hub-overview-chevron pointer-events-none size-[15px] shrink-0" aria-hidden="true" />
</div>
@@ -233,72 +233,74 @@ const AgentModelCard: React.FC<{
<div
tabIndex={-1}
data-agent-group-head={agent.backend}
- className="flex min-h-[52px] flex-col justify-center border-b border-border px-3.5 py-2"
+ className="flex flex-col gap-2 border-b border-border px-3.5 py-2"
>
- <div className="flex min-w-0 flex-col items-stretch gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between sm:gap-3">
+ <div className="model-hub-agent-head-summary flex min-w-0 items-center justify-between gap-2">
<div className="flex min-w-0 items-center gap-[9px]">
<span className={cn('flex size-[30px] shrink-0 items-center justify-center rounded-[9px]', ACCENT_TILE[accent])}><Icon className={cn('size-[15px]', ACCENT_ICON[accent])} /></span>
- <span className="flex min-w-0 items-center gap-[7px]">
- <h2 className="truncate text-[14px] font-bold leading-[17px] text-foreground">{t(`settings.models.backends.${agent.backend}`, { defaultValue: agent.backend })}</h2>
- <Badge variant="secondary" className={cn('model-hub-pill model-hub-fill-0a', hasTakeover && 'model-hub-takeover-chip')}>
- {hasTakeover
- ? t('settings.models.takeover.chip')
- : t('settings.models.gateway.modelCount', { count: allModels.length })}
- </Badge>
- </span>
+ <h2 className="truncate text-[14px] font-bold leading-[17px] text-foreground">{t(`settings.models.backends.${agent.backend}`, { defaultValue: agent.backend })}</h2>
</div>
+ {agent.mode === 'hub' && (
+ <ResponsiveMenu
+ open={modeMenuOpen}
+ onOpenChange={setModeMenuOpen}
+ sheetTitle={t('settings.models.gateway.modeMenu.title') as string}
+ className="model-hub-mode-menu w-[324px] rounded-[10px] border-border-strong bg-card p-1.5 !shadow-[var(--model-hub-menu-shadow)]"
+ trigger={(
+ <button
+ type="button"
+ disabled={pending}
+ aria-label={`${t('settings.models.gateway.modeMenu.title')}: ${modeStatus}`}
+ className={cn('model-hub-agent-mode-trigger flex max-w-full min-w-0 items-center gap-1.5 rounded-md px-2.5 text-[11px] font-semibold transition-colors hover:text-foreground disabled:opacity-50', statusClass)}
+ >
+ <span className={cn('size-[5px] shrink-0 rounded-full', statusDot)} />
+ <span className="truncate">{modeStatus}</span>
+ <ChevronDown className={cn('size-3 shrink-0 transition-transform', modeMenuOpen && 'rotate-180')} aria-hidden="true" />
+ </button>
+ )}
+ >
+ <p className="model-hub-mode-menu-title px-2.5 pb-1.5 pt-1 text-[10px] font-bold uppercase text-muted max-md:hidden">{t('settings.models.gateway.modeMenu.title')}</p>
+ <div role="group" aria-label={t('settings.models.gateway.modeMenu.title') as string}>
+ <button type="button" aria-pressed="true" className="model-hub-mode-menu-current flex w-full items-start gap-2.5 rounded-[7px] px-2.5 py-2.5 text-left" onClick={() => setModeMenuOpen(false)}>
+ <Route className="model-hub-ink-mint mt-0.5 size-4 shrink-0" aria-hidden="true" />
+ <span className="min-w-0 flex-1">
+ <span className="block text-[12px] font-bold text-foreground">{t('settings.models.gateway.modeMenu.gatewayCurrent')}</span>
+ <span className="mt-0.5 block text-[10.5px] leading-[15px] text-muted">{t('settings.models.gateway.modeMenu.gatewayDescription')}</span>
+ </span>
+ <Check className="model-hub-ink-mint mt-0.5 size-4 shrink-0" aria-hidden="true" />
+ </button>
+ <button
+ type="button"
+ aria-pressed="false"
+ disabled={pending}
+ className="model-hub-mode-menu-item mt-0.5 flex w-full items-start gap-2.5 rounded-[7px] px-2.5 py-2.5 text-left hover:bg-surface-2 disabled:opacity-50"
+ onClick={() => {
+ setModeMenuOpen(false);
+ onSwitchDirect(agent);
+ }}
+ >
+ <Power className="mt-0.5 size-4 shrink-0 text-muted" aria-hidden="true" />
+ <span className="min-w-0">
+ <span className="block text-[12px] font-bold text-foreground">{t(switchFailed ? 'settings.models.gateway.retry' : 'settings.models.gateway.switchToDirect')}</span>
+ <span className="mt-0.5 block text-[10.5px] leading-[15px] text-muted">{t('settings.models.gateway.modeMenu.directDescription', { backend: t(`settings.models.backends.${agent.backend}`, { defaultValue: agent.backend }) })}</span>
+ </span>
+ </button>
+ </div>
+ </ResponsiveMenu>
+ )}
+ </div>
+ <div className="model-hub-agent-head-controls flex min-w-0 items-center justify-between gap-2">
+ <Badge variant="secondary" className={cn('model-hub-pill model-hub-fill-0a min-w-0', hasTakeover && 'model-hub-takeover-chip')}>
+ <span className="truncate">{hasTakeover
+ ? t('settings.models.takeover.chip')
+ : t('settings.models.gateway.modelCount', { count: allModels.length })}</span>
+ </Badge>
{agent.mode === 'hub' ? (
- <div className="flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2">
- <ResponsiveMenu
- open={modeMenuOpen}
- onOpenChange={setModeMenuOpen}
- sheetTitle={t('settings.models.gateway.modeMenu.title') as string}
- className="model-hub-mode-menu w-[324px] rounded-[10px] border-border-strong bg-card p-1.5 !shadow-[var(--model-hub-menu-shadow)]"
- trigger={(
- <button
- type="button"
- disabled={pending}
- aria-label={`${t('settings.models.gateway.modeMenu.title')}: ${modeStatus}`}
- className={cn('model-hub-agent-mode-trigger flex max-w-full min-w-0 items-center gap-1.5 rounded-md px-2.5 text-[11px] font-semibold transition-colors hover:text-foreground disabled:opacity-50', statusClass)}
- >
- <span className={cn('size-[5px] shrink-0 rounded-full', statusDot)} />
- <span className="truncate">{modeStatus}</span>
- <ChevronDown className={cn('size-3 shrink-0 transition-transform', modeMenuOpen && 'rotate-180')} aria-hidden="true" />
- </button>
- )}
- >
- <p className="model-hub-mode-menu-title px-2.5 pb-1.5 pt-1 text-[10px] font-bold uppercase text-muted max-md:hidden">{t('settings.models.gateway.modeMenu.title')}</p>
- <div role="group" aria-label={t('settings.models.gateway.modeMenu.title') as string}>
- <button type="button" aria-pressed="true" className="model-hub-mode-menu-current flex w-full items-start gap-2.5 rounded-[7px] px-2.5 py-2.5 text-left" onClick={() => setModeMenuOpen(false)}>
- <Route className="model-hub-ink-mint mt-0.5 size-4 shrink-0" aria-hidden="true" />
- <span className="min-w-0 flex-1">
- <span className="block text-[12px] font-bold text-foreground">{t('settings.models.gateway.modeMenu.gatewayCurrent')}</span>
- <span className="mt-0.5 block text-[10.5px] leading-[15px] text-muted">{t('settings.models.gateway.modeMenu.gatewayDescription')}</span>
- </span>
- <Check className="model-hub-ink-mint mt-0.5 size-4 shrink-0" aria-hidden="true" />
- </button>
- <button
- type="button"
- aria-pressed="false"
- disabled={pending}
- className="model-hub-mode-menu-item mt-0.5 flex w-full items-start gap-2.5 rounded-[7px] px-2.5 py-2.5 text-left hover:bg-surface-2 disabled:opacity-50"
- onClick={() => {
- setModeMenuOpen(false);
- onSwitchDirect(agent);
- }}
- >
- <Power className="mt-0.5 size-4 shrink-0 text-muted" aria-hidden="true" />
- <span className="min-w-0">
- <span className="block text-[12px] font-bold text-foreground">{t(switchFailed ? 'settings.models.gateway.retry' : 'settings.models.gateway.switchToDirect')}</span>
- <span className="mt-0.5 block text-[10.5px] leading-[15px] text-muted">{t('settings.models.gateway.modeMenu.directDescription', { backend: t(`settings.models.backends.${agent.backend}`, { defaultValue: agent.backend }) })}</span>
- </span>
- </button>
- </div>
- </ResponsiveMenu>
+ <div className="model-hub-agent-head-actions">
<ManageModelsButton className="model-hub-agent-head-action" disabled={pending} onClick={() => onOpenModels(agent)} />
<Button variant="outline" size="xs" className="model-hub-agent-head-action rounded-md bg-background px-2.5 text-[11px] font-semibold shadow-sm" onClick={() => onOpenOrder(agent)} disabled={pending}><ArrowDownUp aria-hidden="true" />{t('settings.models.gateway.sourceOrder')}</Button>
</div>
- ) : <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>}
+ ) : <Button variant="default" size="xs" className="model-hub-agent-head-action shrink-0 rounded-md px-2.5 text-[11px] font-semibold" 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} 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>)}
diff --git a/ui/src/components/settings/models/modelHubStylePolicy.test.ts b/ui/src/components/settings/models/modelHubStylePolicy.test.ts
index 5ab6f669d..72cb013d5 100644
--- a/ui/src/components/settings/models/modelHubStylePolicy.test.ts
+++ b/ui/src/components/settings/models/modelHubStylePolicy.test.ts
@@ -113,6 +113,29 @@ describe('Model Hub visual token policy', () => {
expect(declarations('.model-hub-order-identity')).toMatchObject({ flex: '1', 'min-width': '0' });
});
+ it('keeps gateway header actions together on the controls row', () => {
+ const root = postcss.parse(surfaceCss);
+ const actions: Record<string, string> = {};
+ root.walkRules('.model-hub-agent-head-actions', (rule) => {
+ rule.walkDecls((decl) => { actions[decl.prop] = decl.value; });
+ });
+ expect(actions).toMatchObject({
+ display: 'flex',
+ 'min-width': '0',
+ 'flex-wrap': 'nowrap',
+ 'align-items': 'stretch',
+ gap: '8px',
+ });
+ const button: Record<string, string> = {};
+ root.walkRules('.model-hub-agent-head-actions > .model-hub-agent-head-action', (rule) => {
+ rule.walkDecls((decl) => { button[decl.prop] = decl.value; });
+ });
+ expect(button).toMatchObject({
+ 'min-width': '0', 'min-height': 'var(--model-hub-agent-head-action-height, 36px)',
+ height: 'auto', 'white-space': 'normal',
+ });
+ });
+
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);
diff --git a/ui/src/components/settings/models/modelHubSurface.css b/ui/src/components/settings/models/modelHubSurface.css
index 904dc2ea0..5eefaac5c 100644
--- a/ui/src/components/settings/models/modelHubSurface.css
+++ b/ui/src/components/settings/models/modelHubSurface.css
@@ -455,14 +455,26 @@
.model-hub-overview-chevron,
.model-hub-overview-info { color: var(--model-hub-ink-40); }
-/* The agent group head keeps a 66px minimum while holding a 36px action row and a
- 16px status row with a 7px gap. Its height may grow when compact layouts wrap
- the action row, while the row and status line dimensions stay pinned. */
+/* Each agent header separates identity/status from count/actions. Keep both
+ actions on the same controls row, including narrow desktop columns. */
.model-hub-agent-head-action {
height: var(--model-hub-agent-head-action-height, 36px);
padding-block: 0;
line-height: var(--model-hub-agent-head-action-leading, 17px);
}
+.model-hub-agent-head-actions {
+ display: flex;
+ min-width: 0;
+ flex-wrap: nowrap;
+ align-items: stretch;
+ gap: 8px;
+}
+.model-hub-agent-head-actions > .model-hub-agent-head-action {
+ min-width: 0;
+ min-height: var(--model-hub-agent-head-action-height, 36px);
+ height: auto;
+ white-space: normal;
+}
.model-hub-agent-head-status { line-height: var(--model-hub-agent-head-status-height, 16px); }
.model-hub-agent-mode-trigger {
height: var(--model-hub-agent-head-action-height, 28px);
@@ -531,7 +543,6 @@
.model-hub-route-origin--passthrough { color: var(--gold-ink); background: var(--model-hub-gold-1a); border-color: var(--model-hub-gold-4d); }
.model-hub-route-origin:focus-visible { outline: 1px solid currentColor; outline-offset: 2px; }
.model-hub-model-open:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
-.model-hub-model-row > span > span:first-child { flex: 0 1 28%; }
.model-hub-origin-help { width: 340px; max-width: calc(100vw - 32px); white-space: pre-line; font-size: 12px; line-height: 1.6; }
.model-hub-route-origin-line { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 12px; }
.model-hub-route-preview { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 8px; background: var(--model-hub-mint-1a); color: var(--mint-ink); font-size: 12px; }
@@ -546,9 +557,6 @@
.model-hub-recorded-turn strong { color: var(--destructive-ink); }
@media (max-width: 640px) {
.model-hub-model-row { height: 72px; }
- .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-model-row {
border-radius: 8px;