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(model-hub): centre the route dialog and floor its add-hop list (#2096)

Call White06bdc47ec38b
diff --git a/ui/e2e/d-routing.spec.ts b/ui/e2e/d-routing.spec.ts
index 62cbb0d28..eb146726c 100644
--- a/ui/e2e/d-routing.spec.ts
+++ b/ui/e2e/d-routing.spec.ts
@@ -93,8 +93,15 @@ test.describe('D: inherited routes, manual editing, and default routing', () =>
await search.press('Enter');
await search.press('Tab');
const selector = page.locator('.model-hub-route-selector');
+ // The manual pair is folded away, so the tab ring reaches its toggle where
+ // it used to reach the first field; opening it from the keyboard has to put
+ // both fields back into that ring, ahead of the confirm button.
+ const manual = selector.getByRole('button', { name: copy('routeDialog.add.manual'), exact: true });
+ await expect(manual).toBeFocused();
+ await manual.press('Enter');
const source = selector.getByLabel(copy('routeDialog.add.source'), { exact: true });
const exactModel = selector.getByLabel(copy('routing.exactModel'), { exact: true });
+ await manual.press('Tab');
await expect(source).toBeFocused();
await source.press('Tab');
await expect(exactModel).toBeFocused();
diff --git a/ui/e2e/model-catalog/route-direct-edit.spec.ts b/ui/e2e/model-catalog/route-direct-edit.spec.ts
index e3e99bbe0..37eb52210 100644
--- a/ui/e2e/model-catalog/route-direct-edit.spec.ts
+++ b/ui/e2e/model-catalog/route-direct-edit.spec.ts
@@ -1,6 +1,13 @@
-import { expect, test } from '@playwright/test';
+import { expect, test, type Locator } from '@playwright/test';
import { hub } from '../support/copy';
+// The picker zooms in, and every box read before that lands is a scaled box:
+// heights that are not layout pixels, and a panel that is smaller than the one
+// the user is left looking at.
+const settled = (panel: Locator) => panel.evaluate(async (element: HTMLElement) => {
+ await Promise.all(element.getAnimations({ subtree: true }).map((animation) => animation.finished));
+});
+
for (const backend of ['claude', 'codex', 'opencode']) {
for (const lang of ['en', 'zh'] as const) {
for (const origin of ['automatic', 'passthrough', 'manual']) {
@@ -41,6 +48,7 @@ for (const backend of ['claude', 'codex', 'opencode']) {
await dialog.getByRole('button', { name: copy('routeDialog.editHop'), exact: true }).first().click();
const selector = page.locator('.model-hub-route-selector');
+ await selector.getByRole('button', { name: copy('routeDialog.add.manual'), exact: true }).click();
await selector.getByLabel(copy('routing.exactModel'), { exact: true }).fill('exact/model-中文');
await selector.getByRole('button', { name: copy('routeDialog.edit.confirm'), exact: true }).click();
await expect(dialog).toBeVisible();
@@ -105,3 +113,167 @@ for (const lang of ['en', 'zh'] as const) {
});
}
}
+
+// The add-hop picker is bounded by the room the popover reports below its
+// trigger, and it neither flips nor scrolls the page, so that room is the whole
+// budget. The dialog's literal `top: 300px` spent most of it before the picker
+// opened — at 1280x720 it left 103px against 139px of fixed bands, which is a
+// candidate list of nothing and a confirm button painting 72px below the fold.
+// Centring the dialog returns the room; folding the manual pair stops a rare
+// path from holding a third of it; the floor spends what is returned on the
+// list. Measured here rather than reasoned about, because every term in that
+// sentence is a rendered height.
+for (const lang of ['en', 'zh'] as const) {
+ test(`MH-ROUTING-007: the add-hop picker opens onto a readable list (${lang})`, async ({ page }) => {
+ const copy = (key: string) => hub(key, {}, lang);
+ await page.setViewportSize({ width: 1280, height: 720 });
+ await page.goto(`/e2e/model-catalog/fixture.html?view=route&backend=codex&lang=${lang}&stocked=1`);
+ await page.getByRole('button', { name: 'Open route', exact: true }).click();
+ const dialog = page.locator('.model-hub-route-dialog');
+ await expect(dialog.locator('.model-hub-route-hop')).toHaveCount(2);
+
+ // Centred, so the room below the dialog is the room above it.
+ const viewport = page.viewportSize()!;
+ const dialogBox = (await dialog.boundingBox())!;
+ expect(Math.abs(dialogBox.y + dialogBox.height / 2 - viewport.height / 2)).toBeLessThanOrEqual(1);
+
+ await dialog.getByRole('button', { name: copy('routeDialog.addHop'), exact: true }).click();
+ const selector = page.locator('.model-hub-route-selector');
+ await expect(selector).toBeVisible();
+ await settled(selector);
+ // The manual pair is folded away: the panel opens on what it is for.
+ await expect(selector.locator('.model-hub-route-custom')).toHaveCount(0);
+
+ const measure = async () => {
+ const panel = (await selector.boundingBox())!;
+ const list = (await selector.locator('.model-hub-route-selector-list').boundingBox())!;
+ const row = (await selector.locator('.model-hub-route-candidate').first().boundingBox())!;
+ const confirm = (await selector.locator('.model-hub-route-selector-confirm').boundingBox())!;
+ return { rows: list.height / row.height, confirm, panelBottom: panel.y + panel.height };
+ };
+
+ const folded = await measure();
+ expect(folded.rows).toBeGreaterThanOrEqual(3);
+ // The panel keeps its own border around the confirm row, and the row stays
+ // on screen: under a popover that cannot flip, below the fold is unreachable.
+ expect(folded.confirm.y + folded.confirm.height).toBeLessThanOrEqual(folded.panelBottom + 1);
+ expect(folded.confirm.y + folded.confirm.height).toBeLessThanOrEqual(viewport.height);
+
+ // Opening the rare path costs list room, never the confirm button.
+ await selector.getByRole('button', { name: copy('routeDialog.add.manual'), exact: true }).click();
+ await expect(selector.getByLabel(copy('routing.exactModel'), { exact: true })).toBeVisible();
+ await settled(selector);
+ const opened = await measure();
+ expect(opened.confirm.y + opened.confirm.height).toBeLessThanOrEqual(opened.panelBottom + 1);
+ expect(opened.confirm.y + opened.confirm.height).toBeLessThanOrEqual(viewport.height);
+ });
+}
+
+// The disclosure is one of those bands, and a subscription-only inventory does
+// not draw it. Budgeting it anyway is 30px the panel will not give back, taken
+// off the bottom of the screen — which is where the confirm button is.
+test('MH-ROUTING-007: a panel with nothing to type by hand is a band shorter', async ({ page }) => {
+ await page.setViewportSize({ width: 900, height: 600 });
+ await page.goto('/e2e/model-catalog/fixture.html?view=route&backend=codex&lang=en&stocked=1&subscription=1&long=1');
+ await page.getByRole('button', { name: 'Open route', exact: true }).click();
+ const dialog = page.locator('.model-hub-route-dialog');
+ await expect(dialog.locator('.model-hub-route-hop')).toHaveCount(2);
+ await dialog.getByRole('button', { name: hub('routeDialog.addHop', {}, 'en'), exact: true }).click();
+ const selector = page.locator('.model-hub-route-selector');
+ await expect(selector).toBeVisible();
+ await settled(selector);
+ await expect(selector.locator('.model-hub-route-selector-manual')).toHaveCount(0);
+
+ // A long chain leaves less room than the panel's own bands, so the panel is
+ // held at exactly those bands — search, column head and confirm foot, and not
+ // a toggle that is not there — plus the border it keeps around them.
+ const panel = (await selector.boundingBox())!;
+ const bands = ['[cmdk-input-wrapper]', '.model-hub-route-selector-head', '.model-hub-route-selector-foot'];
+ const drawn = await Promise.all(bands.map(async (band) => (await selector.locator(band).boundingBox())!.height));
+ const frame = await selector.evaluate((element: HTMLElement) => {
+ const style = getComputedStyle(element);
+ return parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
+ });
+ expect(panel.height).toBeLessThanOrEqual(drawn.reduce((total, height) => total + height, frame) + 1);
+});
+
+// A band is budgeted by a term and drawn by a primitive, and nothing keeps the
+// two equal on its own. Both drifts are defects, and both were here: the manual
+// pair was budgeted as two stacked controls while its grid draws them side by
+// side — fourteen pixels of list room given up for nothing — and the hairlines
+// between the bands, and the popover's own border, were drawn but budgeted
+// nowhere, so a panel held at its bands overflowed the bound it had just
+// declared by exactly the border it was supposed to keep around the confirm
+// row. Every term is read back as a length here and matched against the band it
+// stands for, because each one is a rendered height and none of them is
+// checkable by reading the stylesheet.
+for (const lang of ['en', 'zh'] as const) {
+ test(`MH-ROUTING-007: every budgeted band is the height it draws (${lang})`, async ({ page }) => {
+ const copy = (key: string) => hub(key, {}, lang);
+ // Room to spare: a band already at its own bound would agree with a wrong
+ // term for the wrong reason.
+ await page.setViewportSize({ width: 1440, height: 1000 });
+ await page.goto(`/e2e/model-catalog/fixture.html?view=route&backend=codex&lang=${lang}&stocked=1`);
+ await page.getByRole('button', { name: 'Open route', exact: true }).click();
+ const dialog = page.locator('.model-hub-route-dialog');
+ await expect(dialog.locator('.model-hub-route-hop')).toHaveCount(2);
+ await dialog.getByRole('button', { name: copy('routeDialog.addHop'), exact: true }).click();
+ const selector = page.locator('.model-hub-route-selector');
+ await expect(selector).toBeVisible();
+ await settled(selector);
+
+ // An unregistered custom property reads back as its token stream rather than
+ // a length, so what a term came to can only be seen by making something draw
+ // it — out of flow, or the panel's flex column shrinks the probe too.
+ const terms = (...properties: string[]) => selector.evaluate((panel: HTMLElement, names: string[]) => {
+ const probe = document.createElement('div');
+ probe.style.cssText = 'position:absolute;visibility:hidden;flex:none';
+ panel.appendChild(probe);
+ const lengths = names.map((name) => {
+ probe.style.height = `var(${name})`;
+ return probe.getBoundingClientRect().height;
+ });
+ probe.remove();
+ return lengths;
+ }, properties);
+ const drawn = async (css: string) => (await selector.locator(css).boundingBox())!.height;
+
+ const [search, head, toggleRow, foot, foldedBands, frame, listMin, max] = await terms(
+ '--model-hub-route-selector-search-height',
+ '--model-hub-route-selector-head-height',
+ '--model-hub-route-selector-manual-height',
+ '--model-hub-route-selector-foot-height',
+ '--model-hub-route-selector-bands',
+ '--model-hub-route-selector-frame',
+ '--model-hub-route-selector-list-min',
+ '--model-hub-route-selector-max',
+ );
+ expect(search).toBe(await drawn('[cmdk-input-wrapper]'));
+ expect(head).toBe(await drawn('.model-hub-route-selector-head'));
+ expect(foot).toBe(await drawn('.model-hub-route-selector-foot'));
+ // Folded, the disclosure is its toggle and the hairline above it, and its
+ // fields are off the budget rather than budgeted at nothing.
+ expect(toggleRow).toBe(await drawn('.model-hub-route-selector-manual'));
+ await expect(selector.locator('.model-hub-route-custom')).toHaveCount(0);
+ // Which is what leaves the fullest folded panel able to reach its three-row
+ // floor under the cap instead of stopping short of its own floor.
+ expect(foldedBands + frame + listMin).toBeLessThanOrEqual(max);
+
+ await selector.getByRole('button', { name: copy('routeDialog.add.manual'), exact: true }).click();
+ await expect(selector.getByLabel(copy('routing.exactModel'), { exact: true })).toBeVisible();
+ await settled(selector);
+ const [fields, bands] = await terms(
+ '--model-hub-route-selector-manual-fields-height',
+ '--model-hub-route-selector-bands',
+ );
+ // One complete field column, not two controls stacked: the pair is a grid.
+ expect(fields).toBe(await drawn('.model-hub-route-custom'));
+ expect(toggleRow + fields).toBe(await drawn('.model-hub-route-selector-manual'));
+
+ // And the column adds up: the budget is every band, the frame is the
+ // popover's own border, and what is left over is the list. A band added
+ // without a term shows up here as a panel that does not.
+ expect((await selector.boundingBox())!.height)
+ .toBe(frame + bands + await drawn('.model-hub-route-selector-list'));
+ });
+}
diff --git a/ui/e2e/model-catalog/routeFixture.tsx b/ui/e2e/model-catalog/routeFixture.tsx
index 95529dfc3..132bda5ff 100644
--- a/ui/e2e/model-catalog/routeFixture.tsx
+++ b/ui/e2e/model-catalog/routeFixture.tsx
@@ -10,10 +10,17 @@ const origin = (params.get('origin') ?? 'automatic') as AgentChain['route_origin
const modelId = params.has('long') ? `模型/${'long-model-identity/'.repeat(10)}gpt-test` : 'gpt-test';
const sources: Source[] = ['a', 'b'].map((id) => ({
id: `src_${id}`, display_name: id === 'a' ? 'Provider A' : 'Provider B',
- kind: 'api_key', vendor: 'openai', protocol: 'openai_responses',
+ // `subscription` is the inventory with nothing to type by hand: the picker
+ // renders no manual pair there, so the panel is one band shorter.
+ kind: params.has('subscription') ? 'subscription' : 'api_key',
+ vendor: 'openai', protocol: 'openai_responses',
supply_channel: 'hub', billing: 'metered', last_discovered_at: null,
state: { status: 'active', retry_at: null, detail_key: null },
- models: [{ id: modelId, origin: 'discovered', reasoning_efforts: [], reasoning_efforts_source: null }],
+ // `stocked` gives each source models the chain does not already use, so the
+ // add-hop picker has candidates to draw. Every other case keeps the two-hop
+ // chain it reads today.
+ models: [modelId, ...(params.has('stocked') ? ['gpt-alt-1', 'gpt-alt-2', 'gpt-alt-3', 'gpt-alt-4', 'gpt-alt-5'] : [])]
+ .map((id) => ({ id, origin: 'discovered' as const, reasoning_efforts: [], reasoning_efforts_source: null })),
}));
const inheritedHops = sources.map((source) => ({ source_id: source.id, model_id: modelId }));
const supply: AgentSupply = {
diff --git a/ui/e2e/model-routing-origin.spec.ts b/ui/e2e/model-routing-origin.spec.ts
index eda7ae7b7..dbfd3e995 100644
--- a/ui/e2e/model-routing-origin.spec.ts
+++ b/ui/e2e/model-routing-origin.spec.ts
@@ -64,6 +64,7 @@ test('MH-ROUTING-007 restore, undo, cancel, and save preserve explicit route int
// Undo must preserve the unsaved candidate, not reconstruct the saved route.
await dialog.getByRole('button', { name: copy('routeDialog.editHop'), exact: true }).click();
const selector = page.locator('.model-hub-route-selector');
+ await selector.getByRole('button', { name: copy('routeDialog.add.manual'), exact: true }).click();
await selector.getByLabel(copy('routeDialog.add.source'), { exact: true }).selectOption(gateway.sources[0].id);
await selector.getByLabel(copy('routing.exactModel'), { exact: true }).fill(unsavedModel);
await expect(selector.getByRole('button', { name: copy('routeDialog.add.confirm'), exact: true })).toHaveCount(0);
diff --git a/ui/src/components/settings/models/RouteCandidatePopover.tsx b/ui/src/components/settings/models/RouteCandidatePopover.tsx
index 31c210f8b..264501493 100644
--- a/ui/src/components/settings/models/RouteCandidatePopover.tsx
+++ b/ui/src/components/settings/models/RouteCandidatePopover.tsx
@@ -1,3 +1,4 @@
+import { ChevronRight } from "lucide-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
@@ -51,6 +52,7 @@ export const RouteCandidatePopover: React.FC<{
const [candidate, setCandidate] = React.useState<RouteCandidate | null>(null);
const [customModel, setCustomModel] = React.useState('');
const [customSource, setCustomSource] = React.useState('');
+ const [manualOpen, setManualOpen] = React.useState(false);
const searchRef = React.useRef<HTMLInputElement | null>(null);
const pendingCandidateRef = React.useRef<RouteCandidate | null>(null);
const term = query.trim().toLowerCase();
@@ -113,6 +115,7 @@ export const RouteCandidatePopover: React.FC<{
onOpenChange={(nextOpen) => {
if (nextOpen) {
setCustomModel('');
+ setManualOpen(false);
setCustomSource(typedSources.find((source) => source.id === initialHop?.source_id)?.id ?? typedSources[0]?.id ?? '');
setQuery("");
setCandidate(
@@ -144,6 +147,12 @@ export const RouteCandidatePopover: React.FC<{
collisionPadding={16}
className={cn(
"model-hub-route-selector flex max-w-[calc(100vw-64px)] flex-col p-0",
+ // The disclosure and its fields are bands only where they are drawn:
+ // an inventory with nothing to type by hand has neither, and an
+ // unopened one has only its toggle. The budget has a term for each,
+ // and these are what turn them on.
+ typedSources.length > 0 && "model-hub-route-selector--manual",
+ manualOpen && "model-hub-route-selector--manual-open",
width === "trigger"
? "w-[var(--radix-popover-trigger-width)]"
: "w-[420px]",
@@ -211,11 +220,38 @@ export const RouteCandidatePopover: React.FC<{
</CommandGroup>
))}
</CommandList>
- {typedSources.length > 0 && <div className="model-hub-route-custom border-t border-border">
- <Field label={t('settings.models.routeDialog.add.source')}>{(id) => <select id={id} value={customSource} onChange={(event) => setCustomSource(event.target.value)}>
- {typedSources.map((source) => <option key={source.id} value={source.id}>{source.display_name}</option>)}
- </select>}</Field>
- <Field label={t('settings.models.routing.exactModel')}>{(id) => <Input id={id} value={customModel} onChange={(event) => setCustomModel(event.target.value)} placeholder={t('settings.models.routing.exactModel')} />}</Field>
+ {/* The rare path, folded away. Left permanently open it was a third
+ fixed band on a bounded panel — with the search, column head and
+ confirm foot it took ~197px of a 300px box, and the candidate list,
+ the only child that can shrink, was what paid for it. */}
+ {typedSources.length > 0 && <div className="model-hub-route-selector-manual shrink-0 border-t border-border">
+ <button
+ type="button"
+ aria-expanded={manualOpen}
+ className="model-hub-route-selector-manual-toggle flex w-full items-center gap-1.5"
+ onKeyDown={(event) => {
+ // cmdk answers Enter on the command root by selecting the
+ // highlighted candidate and preventing the default — which,
+ // for the button the user is focused on, is its own click.
+ if (event.key === 'Enter') event.stopPropagation();
+ }}
+ onClick={() => {
+ const next = !manualOpen;
+ setManualOpen(next);
+ // Closing drops the draft: a hidden value must never be what the
+ // confirm button is acting on.
+ if (!next) setCustomModel('');
+ }}
+ >
+ <ChevronRight aria-hidden="true" className={cn('size-3 shrink-0 transition-transform', manualOpen && 'rotate-90')} />
+ {t('settings.models.routeDialog.add.manual')}
+ </button>
+ {manualOpen && <div className="model-hub-route-custom">
+ <Field label={t('settings.models.routeDialog.add.source')}>{(id) => <select id={id} value={customSource} onChange={(event) => setCustomSource(event.target.value)}>
+ {typedSources.map((source) => <option key={source.id} value={source.id}>{source.display_name}</option>)}
+ </select>}</Field>
+ <Field label={t('settings.models.routing.exactModel')}>{(id) => <Input id={id} value={customModel} onChange={(event) => setCustomModel(event.target.value)} placeholder={t('settings.models.routing.exactModel')} />}</Field>
+ </div>}
</div>}
<div className="model-hub-route-selector-foot flex shrink-0 items-center justify-end border-t border-border">
<Button
diff --git a/ui/src/components/settings/models/RouteChainDialog.directEdit.test.tsx b/ui/src/components/settings/models/RouteChainDialog.directEdit.test.tsx
index c51ad1a9a..8afdc537d 100644
--- a/ui/src/components/settings/models/RouteChainDialog.directEdit.test.tsx
+++ b/ui/src/components/settings/models/RouteChainDialog.directEdit.test.tsx
@@ -106,6 +106,7 @@ describe('direct route editing', () => {
await user.keyboard('{Escape}');
expect(close).not.toHaveBeenCalled();
await user.click(edit);
+ await user.click(screen.getByRole('button', { name: 'Enter a model ID manually' }));
await user.type(screen.getByLabelText('Exact model ID'), 'gpt-test');
expect(screen.getByRole('button', { name: 'Replace' })).toHaveProperty('disabled', true);
await user.click(screen.getByRole('button', { name: 'Replace' }));
diff --git a/ui/src/components/settings/models/RouteChainDialog.test.tsx b/ui/src/components/settings/models/RouteChainDialog.test.tsx
index b1a940385..d22d11870 100644
--- a/ui/src/components/settings/models/RouteChainDialog.test.tsx
+++ b/ui/src/components/settings/models/RouteChainDialog.test.tsx
@@ -1,4 +1,7 @@
// @vitest-environment jsdom
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+
import { act, cleanup, render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { I18nextProvider } from "react-i18next";
@@ -131,8 +134,13 @@ const deferred = <T,>() => {
});
return { promise, reject, resolve };
};
-const renderStockedDialog = () => {
+const renderStockedDialog = (
+ // The inventory the picker draws from. Its kinds decide whether the manual
+ // pair is rendered at all, which is why one test supplies its own.
+ supplied: (stockedSources: Source[]) => Source[] = (stockedSources) => stockedSources,
+) => {
const fixture = stocked();
+ const fixtureSources = supplied(fixture.sources);
vi.spyOn(modelsApi, "getAgentChain").mockResolvedValue(chain);
render(
<I18nextProvider i18n={i18n}>
@@ -142,11 +150,11 @@ const renderStockedDialog = () => {
modelId: "opus-5",
read: readyRegion(chain),
}}
- sources={fixture.sources}
+ sources={fixtureSources}
onClose={vi.fn()}
onCommitted={vi.fn()}
readAgents={vi.fn().mockResolvedValue(observation([fixture.agent]))}
- readSources={vi.fn().mockResolvedValue(observation(fixture.sources))}
+ readSources={vi.fn().mockResolvedValue(observation(fixtureSources))}
/>
</I18nextProvider>,
);
@@ -360,6 +368,7 @@ describe("RouteChainDialog", () => {
} }, [sources[0]]);
await user.click(await screen.findByRole('button', { name: 'Add a hop' }));
+ await user.click(screen.getByRole('button', { name: 'Enter a model ID manually' }));
await user.type(screen.getByLabelText('Exact model ID'), hop.model_id);
await user.click(screen.getByRole('button', { name: 'Add' }));
await user.click(screen.getByRole('button', { name: 'Save' }));
@@ -680,6 +689,9 @@ describe("RouteChainDialog", () => {
const user = userEvent.setup();
renderStockedDialog();
await user.click(await screen.findByRole('button', { name: 'Add a hop' }));
+ // The pair is folded away until asked for; the picker opens on the list.
+ expect(screen.queryByLabelText('Exact model ID')).toBeNull();
+ await user.click(screen.getByRole('button', { name: 'Enter a model ID manually' }));
expect(screen.getByLabelText('Source').querySelectorAll('option')).toHaveLength(1);
await user.type(screen.getByLabelText('Exact model ID'), 'unlisted-model');
await user.click(screen.getByRole('button', { name: 'Add' }));
@@ -1233,6 +1245,99 @@ describe("RouteChainDialog", () => {
).toBe(true);
});
+ // The panel is one flexible list plus bands that cannot shrink, so whatever a
+ // new band takes, it takes from the list — which is how the manual
+ // source/model pair once squeezed it to a sliver. `modelHubSurface.css` now
+ // carries a term per band in `--model-hub-route-selector-min`, and the style
+ // policy checks that arithmetic; what arithmetic cannot see is a band nobody
+ // wrote a term for. This is that half: every in-flow child of the column is
+ // either the list or a band the budget already pays for.
+ it("leaves no band in the add-hop panel outside the height budget", async () => {
+ const user = userEvent.setup();
+ renderStockedDialog();
+ await screen.findAllByRole("button", { name: "Remove hop" });
+ await user.click(screen.getByRole("button", { name: "Add a hop" }));
+
+ // Each band the column draws, in order, against the term that pays for it.
+ const budgeted: Array<[string, string]> = [
+ ["[cmdk-input-wrapper]", "--model-hub-route-selector-search-height"],
+ [".model-hub-route-selector-head", "--model-hub-route-selector-head-height"],
+ [".model-hub-route-selector-list", "--model-hub-route-selector-list-min"],
+ [".model-hub-route-selector-manual", "--model-hub-route-selector-manual-height"],
+ [".model-hub-route-selector-foot", "--model-hub-route-selector-foot-height"],
+ ];
+ const census = (root: string, bands: Array<[string, string]>) => {
+ const parent = document.querySelector<HTMLElement>(root);
+ expect(parent, `${root} is not rendered`).not.toBeNull();
+ const inFlow = [...parent!.children].filter(
+ // cmdk's own accessible label is absolutely positioned, so it costs the
+ // column nothing and needs no term.
+ (child) => getComputedStyle(child).position !== "absolute",
+ );
+ expect(inFlow.map((child) => (
+ bands.find(([selector]) => child.matches(selector))?.[1] ?? `unbudgeted: ${child.outerHTML.slice(0, 80)}`
+ ))).toEqual(bands.map(([, term]) => term));
+ };
+ census(".model-hub-route-selector-command", budgeted);
+
+ // The rare path is folded, so its fields are a band only once opened — and
+ // then they are one too, not free space taken out of the list.
+ await user.click(screen.getByRole("button", { name: "Enter a model ID manually" }));
+ census(".model-hub-route-selector-manual", [
+ [".model-hub-route-selector-manual-toggle", "--model-hub-route-selector-manual-height"],
+ [".model-hub-route-custom", "--model-hub-route-selector-manual-fields-height"],
+ ]);
+
+ // ...and those are the budget's own terms, not a list this test agrees with
+ // itself about: the fixed bands are what the list's floor is measured
+ // against, and the remaining term is that floor.
+ const css = readFileSync(join(__dirname, "modelHubSurface.css"), "utf8");
+ const budget = css.match(/--model-hub-route-selector-bands:([^;]*);/)?.[1] ?? "";
+ for (const [selector, term] of [...budgeted, ["", "--model-hub-route-selector-manual-fields-height"] as const]) {
+ expect(selector === ".model-hub-route-selector-list" ? css : budget).toContain(`var(${term})`);
+ }
+ });
+
+ // A subscription-only inventory has no model ID to type by hand, so the
+ // disclosure is not rendered — and must not be budgeted either. A term held
+ // for a row that is not on screen is 30px the panel refuses to give back, and
+ // it comes out of the bottom of the screen where the confirm button is.
+ it("drops the manual band from the budget where nothing can be typed", async () => {
+ const user = userEvent.setup();
+ renderStockedDialog((stockedSources) =>
+ stockedSources.map((source) => ({ ...source, kind: "subscription" as const })));
+ await screen.findAllByRole("button", { name: "Remove hop" });
+ await user.click(screen.getByRole("button", { name: "Add a hop" }));
+
+ const panel = document.querySelector<HTMLElement>(".model-hub-route-selector");
+ expect(panel).not.toBeNull();
+ expect(panel!.querySelector(".model-hub-route-selector-manual")).toBeNull();
+ expect(panel!.className).not.toContain("model-hub-route-selector--manual");
+ // ...and the candidates are still there: this is a shorter panel, not an
+ // empty one.
+ expect(document.querySelectorAll(".model-hub-route-candidate").length).toBeGreaterThan(0);
+ });
+
+ // cmdk answers Enter on its own root: it selects the highlighted candidate and
+ // prevents the default, which for a focused button is that button's own
+ // activation. A disclosure inside the command column has to keep the key it is
+ // focused for, or the rare path is reachable by pointer only.
+ it("opens the manual pair from the keyboard, where cmdk owns Enter", async () => {
+ const user = userEvent.setup();
+ renderStockedDialog();
+ await screen.findAllByRole("button", { name: "Remove hop" });
+ await user.click(screen.getByRole("button", { name: "Add a hop" }));
+
+ const toggle = screen.getByRole("button", { name: "Enter a model ID manually" });
+ toggle.focus();
+ await user.keyboard("{Enter}");
+ expect(screen.queryByLabelText("Exact model ID")).not.toBeNull();
+
+ // And the same key folds it again, rather than reaching the list below.
+ await user.keyboard("{Enter}");
+ expect(screen.queryByLabelText("Exact model ID")).toBeNull();
+ });
+
it("announces the one-based position of the hop focused after removal", async () => {
const user = userEvent.setup();
const threeHopChain: AgentChain = {
diff --git a/ui/src/components/settings/models/RouteChainDialog.tsx b/ui/src/components/settings/models/RouteChainDialog.tsx
index 4c8fce986..ce31ef970 100644
--- a/ui/src/components/settings/models/RouteChainDialog.tsx
+++ b/ui/src/components/settings/models/RouteChainDialog.tsx
@@ -1184,7 +1184,7 @@ export const RouteChainDialog: React.FC<{
phase === "refreshing" ||
phase === "reconciling"
}
- className="model-hub-route-dialog fixed left-1/2 z-50 flex -translate-x-1/2 flex-col gap-0 overflow-hidden border border-border-strong bg-surface p-0"
+ className="model-hub-route-dialog fixed left-1/2 top-1/2 z-50 flex -translate-x-1/2 -translate-y-1/2 flex-col gap-0 overflow-hidden border border-border-strong bg-surface p-0"
onOpenAutoFocus={(event) => {
event.preventDefault();
cancelButtonRef.current?.focus();
diff --git a/ui/src/components/settings/models/modelHubStylePolicy.test.ts b/ui/src/components/settings/models/modelHubStylePolicy.test.ts
index 72cb013d5..524ae23b4 100644
--- a/ui/src/components/settings/models/modelHubStylePolicy.test.ts
+++ b/ui/src/components/settings/models/modelHubStylePolicy.test.ts
@@ -204,18 +204,28 @@ describe('Model Hub visual token policy', () => {
expect(literals).toEqual([]);
});
- it('pins the route dialog placement, shadow, and bounded body scroll to named roles', () => {
- const dialog = surfaceCss.match(/\.model-hub-route-dialog\s*\{([^}]*)\}/)?.[1] ?? '';
- const body = surfaceCss.match(/\.model-hub-route-body\s*\{([^}]*)\}/)?.[1] ?? '';
-
- expect(dialog).toContain('--model-hub-route-offset: min(');
- expect(dialog).toContain('--model-hub-route-top: 300px');
- expect(dialog).toContain('var(--model-hub-route-top)');
- expect(dialog).toContain('top: var(--model-hub-route-offset)');
+ // Every modal in `design.pen` whose frame carries an explicit height sits at
+ // exactly (viewport - dialog) / 2. This one is the file's single hug-height
+ // frame, so its 300px `y` is a round stand-in for the 332.5px its own
+ // head/body/foot measure to — and read as a literal `top` it held at the
+ // 1100px artboard and nowhere else, which is how the dialog came to sit near
+ // the bottom of an ordinary laptop viewport.
+ it('centres the route dialog and leaves it the room a centred box has', () => {
+ const dialog = surfaceCssBody.match(/\.model-hub-route-dialog\s*\{([^}]*)\}/)?.[1] ?? '';
+ const body = surfaceCssBody.match(/\.model-hub-route-body\s*\{([^}]*)\}/)?.[1] ?? '';
+ const root = readFileSync(join(__dirname, 'RouteChainDialog.tsx'), 'utf8');
+
+ // Placement through the shared modal idiom, so nothing here has to track
+ // the dialog's measured height.
+ expect(root).toContain('model-hub-route-dialog fixed left-1/2 top-1/2');
+ expect(root).toContain('-translate-x-1/2 -translate-y-1/2');
+ expect(dialog).not.toMatch(/(?:^|;)\s*top\s*:/);
+ expect(dialog).not.toContain('--model-hub-route-top');
+ expect(dialog).not.toContain('--model-hub-route-offset');
expect(dialog).toContain('box-shadow: var(--model-hub-dialog-shadow)');
- // The dialog grows with its chain, so what bounds it is the room below the
- // offset it is anchored at — not the viewport minus two insets.
- expect(dialog).toMatch(/max-height:\s*calc\([\s\S]*100dvh - var\(--model-hub-route-offset\) -[\s\S]*var\(--model-hub-route-viewport-inset\)/);
+ // A centred box of at most this height clears both insets by construction,
+ // so a long chain can no longer push the footer off the bottom.
+ expect(dialog).toMatch(/max-height:\s*calc\(\s*100dvh - var\(--model-hub-route-viewport-inset\) -\s*var\(--model-hub-route-viewport-inset\)\s*\)/);
expect(body).not.toMatch(/^\s*height:/m);
expect(body).toContain('overflow-y: auto');
});
@@ -229,13 +239,102 @@ describe('Model Hub visual token policy', () => {
// `ui/src/components/ui/anchored-selection-scroll.test.tsx` and by the add-hop
// case in `RouteChainDialog.test.tsx`.
it('bounds the add-hop picker against the space the popover reports', () => {
- const selector = surfaceCss.match(/\.model-hub-route-selector\s*\{([^}]*)\}/)?.[1] ?? '';
- const list = surfaceCss.match(/\.model-hub-route-selector-list\s*\{([^}]*)\}/)?.[1] ?? '';
+ const selector = surfaceCssBody.match(/\.model-hub-route-selector\s*\{([^}]*)\}/)?.[1] ?? '';
+ const list = surfaceCssBody.match(/\.model-hub-route-selector-list\s*\{([^}]*)\}/)?.[1] ?? '';
expect(selector).toContain('--radix-popover-content-available-height');
- expect(selector).toContain('max-height: min(');
+ expect(selector).toMatch(/max-height:\s*max\(\s*calc\(var\(--model-hub-route-selector-bands\) \+ var\(--model-hub-route-selector-frame\)\),\s*min\(\s*var\(--model-hub-route-selector-max\),\s*var\(--model-hub-route-selector-room\)/);
expect(list).toContain('overflow-y: auto');
- expect(list).toContain('min-height: 0');
+ });
+
+ // The panel is one flexible list plus bands that cannot shrink, so the list is
+ // the only child a new band can be paid for out of — which is what happened:
+ // the manual source/model pair went straight into the column, nothing
+ // recomputed, and the list was left a few pixels of green. The floor makes
+ // that arithmetic, and this is where the arithmetic has to hold. That the
+ // panel drawn in a browser contains nothing the arithmetic missed is the other
+ // half, and belongs to the rendered census in `RouteChainDialog.test.tsx`.
+ it('keeps a three-row list floor no fixed band can take back', () => {
+ const selector = surfaceCssBody.match(/\.model-hub-route-selector\s*\{([^}]*)\}/)?.[1] ?? '';
+ const list = surfaceCssBody.match(/\.model-hub-route-selector-list\s*\{([^}]*)\}/)?.[1] ?? '';
+ const candidate = surfaceCssBody.match(/\.model-hub-route-candidate\s*\{([^}]*)\}/)?.[1] ?? '';
+ const px = (source: string, property: string) => {
+ const value = source.match(new RegExp(`${property}:\\s*(\\d+(?:\\.\\d+)?)px`))?.[1];
+ expect(value, `${property} is not declared in px`).toBeDefined();
+ return Number(value);
+ };
+
+ // Three rows wherever the room reaches, and the room minus the bands where
+ // it does not — a floor held past that point would not produce a list, only
+ // a confirm button below the fold, which is unreachable under a popover
+ // that neither flips nor scrolls the page.
+ expect(list).toMatch(/min-height:\s*clamp\(\s*0px,\s*calc\(\s*min\(var\(--model-hub-route-selector-max\), var\(--model-hub-route-selector-room\)\) -\s*var\(--model-hub-route-selector-frame\) - var\(--model-hub-route-selector-bands\)\s*\),\s*var\(--model-hub-route-selector-list-min\)\s*\)/);
+ expect(px(selector, '--model-hub-route-selector-list-min'))
+ .toBeGreaterThanOrEqual(px(candidate, 'min-height') * 3);
+
+ // Every band that cannot shrink has a term, so the room the floor is
+ // measured against is the room the list can actually be given.
+ const bands = [
+ '--model-hub-route-selector-search-height',
+ '--model-hub-route-selector-head-height',
+ '--model-hub-route-selector-manual-height',
+ '--model-hub-route-selector-manual-fields-height',
+ '--model-hub-route-selector-foot-height',
+ ];
+ const summed = [...(selector.match(/--model-hub-route-selector-bands:([^;]*);/)?.[1] ?? '')
+ .matchAll(/var\((--[\w-]+)\)/g)].map((match) => match[1]);
+ expect(summed).toEqual(bands);
+
+ // What each term comes to is a rendered length — a term is a composition of
+ // other terms and jsdom resolves no `calc()` — so the arithmetic itself
+ // (every term against the band it draws, and the folded bands plus the
+ // floor still under the cap) is measured in the rendered census in
+ // `e2e/model-catalog/route-direct-edit.spec.ts`. What belongs here is the
+ // shape that arithmetic rests on: the bands are drawn with a hairline
+ // between them and the popover draws one around itself, and `max-height` is
+ // border-box. Left out, both were the panel overflowing the bound it had
+ // just declared by exactly the border it keeps around the confirm row.
+ expect(selector).toMatch(
+ /--model-hub-route-selector-frame:\s*calc\(var\(--model-hub-route-selector-hairline\) \* 2\)/,
+ );
+ for (const band of ['search-height', 'foot-height']) {
+ expect(selector.match(new RegExp(`--model-hub-route-selector-${band}:([^;]*);`))?.[1])
+ .toContain('var(--model-hub-route-selector-hairline)');
+ }
+
+ // Each half of the disclosure is a band only where it is drawn — an
+ // inventory with nothing to type by hand renders neither, and a folded one
+ // only its toggle. Both default to zero and are turned on by the state the
+ // panel is in, so the lower bound never holds the panel open for a row that
+ // is not on screen. Opened, the fields term is every part of what they draw
+ // rather than a number measured once off a screenshot.
+ const state = (modifier: string) =>
+ surfaceCssBody.match(new RegExp(`\\.model-hub-route-selector--${modifier}\\s*\\{([^}]*)\\}`))?.[1] ?? '';
+ expect(px(selector, '--model-hub-route-selector-manual-height')).toBe(0);
+ expect(state('manual\\b')).toMatch(
+ /--model-hub-route-selector-manual-height:\s*calc\(\s*var\(--model-hub-route-selector-hairline\) \+ var\(--model-hub-route-selector-manual-row\)\s*\)/,
+ );
+ expect(px(selector, '--model-hub-route-selector-manual-fields-height')).toBe(0);
+ const opened = state('manual-open');
+ expect([...opened.matchAll(/var\((--[\w-]+)\)/g)].map((match) => match[1])).toEqual([
+ '--model-hub-route-custom-label-height',
+ '--model-hub-route-custom-field-gap',
+ '--model-hub-route-custom-source-height',
+ '--model-hub-route-custom-model-height',
+ '--model-hub-route-custom-pad-block-end',
+ ]);
+ expect(opened).toMatch(/--model-hub-route-selector-manual-fields-height:\s*calc\(/);
+ // The pair is a two-column grid, so what it adds is the taller field column
+ // — not both controls summed as though one sat under the other, which is a
+ // row's worth of list room given up for nothing.
+ expect(opened).toMatch(
+ /max\(\s*var\(--model-hub-route-custom-source-height\),\s*var\(--model-hub-route-custom-model-height\)\s*\)/,
+ );
+
+ // The toggle draws the height its own term names, not the budgeted one:
+ // that one is zero unless the panel says the row is there.
+ const toggle = surfaceCssBody.match(/\.model-hub-route-selector-manual-toggle\s*\{([^}]*)\}/)?.[1] ?? '';
+ expect(toggle).toContain('height: var(--model-hub-route-selector-manual-row)');
});
// The surface draws the same 10.5px status pill in six places (upstream count,
diff --git a/ui/src/components/settings/models/modelHubSurface.css b/ui/src/components/settings/models/modelHubSurface.css
index 934af7287..33cfd118f 100644
--- a/ui/src/components/settings/models/modelHubSurface.css
+++ b/ui/src/components/settings/models/modelHubSurface.css
@@ -550,8 +550,12 @@
.model-hub-route-preview[data-origin="unconfigured"] { background: var(--model-hub-wash-08); color: var(--muted); }
.model-hub-route-ordinal[data-origin="automatic"] { color: var(--mint-ink); background: var(--model-hub-mint-1a); }
.model-hub-route-ordinal[data-origin="passthrough"] { color: var(--gold-ink); background: var(--model-hub-gold-1a); }
-.model-hub-route-custom { display: grid; grid-template-columns: minmax(80px, auto) minmax(0, 1fr); gap: 8px; align-items: center; padding: 12px; font-size: 12px; }
-.model-hub-route-custom select { min-width: 0; height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--background); color: var(--foreground); padding: 0 8px; }
+.model-hub-route-custom { display: grid; grid-template-columns: minmax(80px, auto) minmax(0, 1fr); gap: var(--model-hub-route-custom-gap, 8px); align-items: center; padding: 0 12px var(--model-hub-route-custom-pad-block-end, 12px); font-size: 12px; }
+.model-hub-route-custom select { min-width: 0; height: var(--model-hub-route-custom-source-height, 32px); border: 1px solid var(--border); border-radius: 6px; background: var(--background); color: var(--foreground); padding: 0 8px; }
+/* The label term of the budgeted band, drawn rather than assumed: a bare
+ `line-height: normal` is font metrics, and a band the panel's arithmetic
+ depends on may not be a different height on the machine that renders it. */
+.model-hub-route-custom label { line-height: var(--model-hub-route-custom-label-height, 18px); }
.model-hub-default-counts { margin-top: auto; padding: 20px; font-size: 12px; color: var(--muted); }
.model-hub-recorded-turn { display: flex; flex-direction: column; gap: 6px; margin: 0 20px 16px; padding: 12px; border-left: 2px solid var(--destructive-ink); font-size: 12px; overflow-wrap: anywhere; color: var(--muted); }
.model-hub-recorded-turn strong { color: var(--destructive-ink); }
@@ -1000,27 +1004,17 @@
.model-hub-route-dialog {
--model-hub-route-width: 520px;
- --model-hub-route-top: 300px;
--model-hub-route-viewport-inset: 16px;
--model-hub-route-radius: 14px;
- /* The design's 302px body is what a two-hop chain measures, not a fixed box:
- pinning it left short chains padded with dead space and long ones scrolling
- inside a dialog that never grew. It survives only as the anchor the top
- offset is computed from, so the resting placement still matches the design. */
- --model-hub-route-body-anchor: 302px;
- --model-hub-route-offset: min(
- var(--model-hub-route-top),
- max(
- var(--model-hub-route-viewport-inset),
- calc(
- 100dvh - var(--model-hub-route-head-height) -
- var(--model-hub-route-body-anchor) -
- var(--model-hub-dialog-foot-height) -
- var(--model-hub-route-viewport-inset)
- )
- )
- );
- top: var(--model-hub-route-offset);
+ /* Centred, like every other modal in the design file: each one whose frame
+ carries an explicit height sits at exactly (viewport - dialog) / 2. The
+ route dialog is the one hug-height frame there, so its 300px `y` is a round
+ stand-in for the 332.5px its own head/body/foot measure to — and read as a
+ literal `top` it only held at the 1100px-tall artboard, leaving the dialog
+ near the bottom of every shorter viewport. Placement is `top: 50%` plus the
+ element's own translate; what belongs here is the room a centred box may
+ take. A centred box of at most this height clears both insets by
+ construction, so the footer cannot be pushed off the bottom. */
width: min(
var(--model-hub-route-width),
calc(
@@ -1029,11 +1023,8 @@
)
);
max-width: var(--model-hub-route-width);
- /* Anchored at `top` rather than centred, so the room left over is what is
- below the offset — subtracting only the two insets would let a long chain
- push the footer off the bottom of the screen. */
max-height: calc(
- 100dvh - var(--model-hub-route-offset) -
+ 100dvh - var(--model-hub-route-viewport-inset) -
var(--model-hub-route-viewport-inset)
);
border-radius: var(--model-hub-route-radius);
@@ -1117,12 +1108,104 @@
chain is what lets a flex item shrink below its content and hand the overflow
to the one element that owns `overflow-y: auto`. */
.model-hub-route-selector {
+ /* Every band that cannot shrink, named once so the floor below is arithmetic
+ rather than a number someone re-eyeballs. A band added to the panel without
+ a term here is what `modelHubStylePolicy.test.ts` fails on: the manual
+ source/model pair was added straight into the flex column, nothing
+ recomputed, and the list — the only child that can give — went to a sliver.
+ Each term is what its band draws, hairline included, and the rendered band
+ census in `e2e/model-catalog/route-direct-edit.spec.ts` measures every one
+ of them against the band on screen: a term that drifts low is a panel that
+ overflows the bound it just declared, one that drifts high is room taken
+ off the list for nothing. */
+ --model-hub-route-selector-hairline: 1px;
+ /* The popover draws that same hairline around itself, and `max-height` is
+ border-box: a bound written in band space is two pixels short of the column
+ it has to hold, which is the confirm row's own border painting over it. */
+ --model-hub-route-selector-frame: calc(var(--model-hub-route-selector-hairline) * 2);
+ --model-hub-route-selector-search-input: 34px;
+ --model-hub-route-selector-search-height: calc(
+ var(--model-hub-route-selector-search-input) + var(--model-hub-route-selector-hairline)
+ );
+ --model-hub-route-selector-head-height: 26px;
+ --model-hub-route-selector-confirm-height: 33px;
+ --model-hub-route-selector-foot-pad-block: 8px;
+ --model-hub-route-selector-foot-height: calc(
+ var(--model-hub-route-selector-hairline) +
+ var(--model-hub-route-selector-foot-pad-block) * 2 +
+ var(--model-hub-route-selector-confirm-height)
+ );
+ /* What the disclosure's own toggle draws. Budgeted only where it is
+ rendered: a subscription-only inventory has no model ID to type, so the
+ panel there is genuinely one band shorter and must not be held open for a
+ row that is not on screen. */
+ --model-hub-route-selector-manual-row: 30px;
+ --model-hub-route-selector-manual-height: 0px;
+ /* What the disclosure adds when it is opened. The pair is a two-column grid,
+ so what it adds is one complete field column — the label, the gap the
+ shared `Field` draws under it, and the taller of the two controls — plus
+ the band's own bottom padding. Summing both controls would budget a second
+ row that is not on screen. Terms rather than an override of the primitives:
+ if one of those heights changes, the rendered census fails on the term
+ instead of this panel silently mis-budgeting the band. */
+ --model-hub-route-custom-label-height: 18px;
+ --model-hub-route-custom-field-gap: 8px;
+ --model-hub-route-custom-source-height: 32px;
+ --model-hub-route-custom-model-height: 36px;
+ --model-hub-route-custom-gap: 8px;
+ --model-hub-route-custom-pad-block-end: 12px;
+ /* Folded, so zero too — which is what lets the room below the trigger bound
+ the panel in the state it opens in, and still leaves its border around the
+ confirm row once the pair is on screen. */
+ --model-hub-route-selector-manual-fields-height: 0px;
+ --model-hub-route-selector-bands: calc(
+ var(--model-hub-route-selector-search-height) +
+ var(--model-hub-route-selector-head-height) +
+ var(--model-hub-route-selector-manual-height) +
+ var(--model-hub-route-selector-manual-fields-height) +
+ var(--model-hub-route-selector-foot-height)
+ );
+ /* Three candidate rows: the least that still reads as a list to scroll. */
+ --model-hub-route-selector-list-min: 84px;
--model-hub-route-selector-max: 300px;
- max-height: min(
- var(--model-hub-route-selector-max),
- var(--radix-popover-content-available-height, var(--model-hub-route-selector-max))
+ --model-hub-route-selector-room: var(
+ --radix-popover-content-available-height,
+ var(--model-hub-route-selector-max)
+ );
+ /* The reported room bounds the panel — it is what is on screen below the
+ trigger, and this popover neither flips nor scrolls the page, so anything
+ past it is unreachable rather than merely clipped. The one thing the room
+ may not do is take the panel below its own fixed bands: there the panel
+ would stop drawing its border around the confirm row instead of shrinking. */
+ max-height: max(
+ calc(var(--model-hub-route-selector-bands) + var(--model-hub-route-selector-frame)),
+ min(
+ var(--model-hub-route-selector-max),
+ var(--model-hub-route-selector-room)
+ )
+ );
+}
+.model-hub-route-selector--manual {
+ --model-hub-route-selector-manual-height: calc(
+ var(--model-hub-route-selector-hairline) + var(--model-hub-route-selector-manual-row)
+ );
+}
+.model-hub-route-selector--manual-open {
+ --model-hub-route-selector-manual-fields-height: calc(
+ var(--model-hub-route-custom-label-height) + var(--model-hub-route-custom-field-gap) +
+ max(
+ var(--model-hub-route-custom-source-height),
+ var(--model-hub-route-custom-model-height)
+ ) + var(--model-hub-route-custom-pad-block-end)
);
}
+.model-hub-route-selector-manual-toggle {
+ height: var(--model-hub-route-selector-manual-row);
+ padding-inline: 12px;
+ color: var(--model-hub-ink-73);
+ font-size: 11.5px;
+}
+.model-hub-route-selector-manual-toggle:hover { color: var(--foreground); }
.model-hub-route-selector-command { min-height: 0; flex: 1 1 auto; }
.model-hub-route-selector [cmdk-input-wrapper] {
flex-shrink: 0;
@@ -1130,7 +1213,7 @@
border-color: var(--model-hub-wash-14);
}
.model-hub-route-selector [cmdk-input] {
- height: 34px;
+ height: var(--model-hub-route-selector-search-input);
padding-block: 0;
font-size: 12px;
line-height: 17px;
@@ -1149,7 +1232,25 @@
font-weight: 700;
line-height: 14px;
}
-.model-hub-route-selector-list { min-height: 0; max-height: none; flex: 1 1 auto; overflow-y: auto; }
+/* The list is the only child that can give, so without a floor it is what every
+ fixed band is paid for out of — which is how the manual source/model pair,
+ added straight into the column, left a sliver of green where the candidates
+ were. The floor is three rows wherever the room reaches, and the room minus
+ the bands where it does not: a floor held past that point would not produce a
+ list, only a confirm button below the fold. */
+.model-hub-route-selector-list {
+ min-height: clamp(
+ 0px,
+ calc(
+ min(var(--model-hub-route-selector-max), var(--model-hub-route-selector-room)) -
+ var(--model-hub-route-selector-frame) - var(--model-hub-route-selector-bands)
+ ),
+ var(--model-hub-route-selector-list-min)
+ );
+ max-height: none;
+ flex: 1 1 auto;
+ overflow-y: auto;
+}
.model-hub-route-selector-group { padding: 0 6px 6px; }
.model-hub-route-candidate { min-height: 28px; font-size: 11.5px; line-height: 16px; }
.model-hub-route-candidate-model { color: var(--model-hub-ink-73); }
@@ -1160,12 +1261,11 @@
}
.model-hub-route-candidate[data-selected="true"] .model-hub-route-candidate-model { color: inherit; }
.model-hub-route-selector-foot {
- padding: 8px 10px;
+ padding: var(--model-hub-route-selector-foot-pad-block) 10px;
border-color: var(--model-hub-wash-14);
}
.model-hub-route-selector-confirm {
--model-hub-route-selector-confirm-size: 12px;
- --model-hub-route-selector-confirm-height: 33px;
height: var(--model-hub-route-selector-confirm-height);
border-radius: var(--model-hub-dialog-action-radius);
font-size: var(--model-hub-route-selector-confirm-size);
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 0a9c11d7e..fa161433f 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -1379,7 +1379,8 @@
"search": "Search sources or models",
"confirm": "Add",
"noMatch": "No source or model matches that",
- "none": "No source/model pair is available to add"
+ "none": "No source/model pair is available to add",
+ "manual": "Enter a model ID manually"
},
"edit": {
"confirm": "Replace",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index d6a20676b..1ce666b5c 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -1379,7 +1379,8 @@
"search": "搜索供应商或模型",
"confirm": "添加",
"noMatch": "没有匹配的供应商或模型",
- "none": "没有可添加的供应商或模型"
+ "none": "没有可添加的供应商或模型",
+ "manual": "手动输入模型 ID"
},
"edit": {
"confirm": "替换",