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): keep the row-action picker on screen at phone widths

cyh0c02d55c9e28
diff --git a/ui/e2e/model-catalog/route-direct-edit.spec.ts b/ui/e2e/model-catalog/route-direct-edit.spec.ts
index 37eb52210..648346b74 100644
--- a/ui/e2e/model-catalog/route-direct-edit.spec.ts
+++ b/ui/e2e/model-catalog/route-direct-edit.spec.ts
@@ -277,3 +277,36 @@ for (const lang of ['en', 'zh'] as const) {
.toBe(frame + bands + await drawn('.model-hub-route-selector-list'));
});
}
+
+// The row action is the one trigger narrower than the panel it opens, and it
+// sits at the right edge of the row. Aligned to its end under a popover with
+// collision handling off, the panel's left edge is placed a panel-width to the
+// left of that — off screen on a phone, where the first column and the search
+// field were simply cut away. Vertically the same panel is bounded by what the
+// engine reports is on screen; this is that reading on the other axis, so the
+// assertion is the one the screenshot would have failed: both edges inside the
+// viewport, at every width a phone actually is.
+for (const [label, width] of [['small', 390], ['large', 430]] as const) {
+ test(`MH-ROUTING-007: the edit picker stays on screen on a ${label} phone`, async ({ page }) => {
+ const copy = (key: string) => hub(key, {}, 'zh');
+ await page.setViewportSize({ width, height: 844 });
+ await page.goto('/e2e/model-catalog/fixture.html?view=route&backend=codex&lang=zh&stocked=1');
+ await page.getByRole('button', { name: 'Open route', exact: true }).click();
+ const dialog = page.locator('.model-hub-route-dialog');
+ await dialog.getByRole('button', { name: copy('routeDialog.editHop'), exact: true }).first().click();
+ const selector = page.locator('.model-hub-route-selector');
+ await expect(selector).toBeVisible();
+ await settled(selector);
+
+ const panel = (await selector.boundingBox())!;
+ expect(panel.x).toBeGreaterThanOrEqual(0);
+ expect(panel.x + panel.width).toBeLessThanOrEqual(width);
+ // Contained by shrinking, not by collapsing: a panel bounded to nothing
+ // would satisfy the edges above and still be unusable.
+ expect(panel.width).toBeGreaterThanOrEqual(240);
+ // And the column that was being cut is the one that has to survive: its
+ // left edge is what leaves the viewport first.
+ const head = (await selector.locator('.model-hub-route-selector-list').boundingBox())!;
+ expect(head.x).toBeGreaterThanOrEqual(0);
+ });
+}
diff --git a/ui/src/components/settings/models/RouteCandidatePopover.tsx b/ui/src/components/settings/models/RouteCandidatePopover.tsx
index 264501493..6c7164d11 100644
--- a/ui/src/components/settings/models/RouteCandidatePopover.tsx
+++ b/ui/src/components/settings/models/RouteCandidatePopover.tsx
@@ -153,9 +153,14 @@ export const RouteCandidatePopover: React.FC<{
// and these are what turn them on.
typedSources.length > 0 && "model-hub-route-selector--manual",
manualOpen && "model-hub-route-selector--manual-open",
+ // Borrowing the trigger's width contains the panel by construction;
+ // a width of its own does not, and this variant hangs off a row
+ // action a panel-width from the right edge. The bound lives in CSS
+ // next to its vertical twin, because it is the same reading of the
+ // same report: what the engine says is on screen for this placement.
width === "trigger"
? "w-[var(--radix-popover-trigger-width)]"
- : "w-[420px]",
+ : "model-hub-route-selector--width-route",
)}
onOpenAutoFocus={(event) => {
event.preventDefault();
diff --git a/ui/src/components/settings/models/modelHubStylePolicy.test.ts b/ui/src/components/settings/models/modelHubStylePolicy.test.ts
index 524ae23b4..ca81a6041 100644
--- a/ui/src/components/settings/models/modelHubStylePolicy.test.ts
+++ b/ui/src/components/settings/models/modelHubStylePolicy.test.ts
@@ -247,6 +247,31 @@ describe('Model Hub visual token policy', () => {
expect(list).toContain('overflow-y: auto');
});
+ // The same report, read on the other axis. `avoidCollisions={false}` turns off
+ // both of Radix's collision middlewares at once — the side-axis flip this
+ // panel must not do, and the align-axis shift that would have kept it on
+ // screen — and `collisionPadding` is inert once detection is off, so nothing
+ // in the component's own props bounds this panel horizontally. The `size`
+ // middleware is not gated, so the available-width report survives, and for a
+ // bottom/end placement it is the width whose left edge lands on the padding
+ // line. The variant that borrows its trigger's width is contained by
+ // construction; this one hangs off a row action a panel-width from the right
+ // edge, so it has to be bound to the report instead. A literal width here
+ // reads fine and ships a panel with its first column off the screen.
+ it('bounds the row-action picker against the width the popover reports', () => {
+ const route = surfaceCssBody
+ .match(/\.model-hub-route-selector--width-route\s*\{([^}]*)\}/)?.[1] ?? '';
+
+ expect(route).toContain('--radix-popover-content-available-width');
+ expect(route).toMatch(/width:\s*min\(\s*var\(--model-hub-route-selector-inline-max\),\s*var\(--model-hub-route-selector-inline-room\)\s*\)/);
+ // Bounded by shrinking, not by collapsing, and still the width the design
+ // draws wherever the room reaches it.
+ expect(route).toMatch(/--model-hub-route-selector-inline-max:\s*420px/);
+ // The fallback is the design width, so a placement that publishes no report
+ // at all keeps the panel rather than reducing it to nothing.
+ expect(route).toMatch(/--radix-popover-content-available-width,\s*var\(--model-hub-route-selector-inline-max\)/);
+ });
+
// 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
diff --git a/ui/src/components/settings/models/modelHubSurface.css b/ui/src/components/settings/models/modelHubSurface.css
index 33cfd118f..0f6bae3dc 100644
--- a/ui/src/components/settings/models/modelHubSurface.css
+++ b/ui/src/components/settings/models/modelHubSurface.css
@@ -1185,6 +1185,30 @@
)
);
}
+/* The horizontal reading of that same report, for the one variant that does not
+ borrow its width from its trigger. `avoidCollisions={false}` turns off both
+ of Radix's collision middlewares — the side-axis flip this panel must not do,
+ and the align-axis shift that would have pushed it back into view — so a
+ 420px panel aligned to the end of a row action sat a panel-width from the
+ right edge and hung its left edge off screen. `collisionPadding` is inert
+ there for the same reason: nothing reads it once detection is off.
+ `size` is not gated (`@radix-ui/react-popper` applies it unconditionally), so
+ the available-width report survives, and for a `bottom`/`end` placement
+ floating-ui computes it as `width - overflow.left`: exactly the width whose
+ left edge lands on the padding line. Bounding by it contains the panel
+ without restoring the flip. Where the room is ampler than the design width —
+ every desktop placement — the min is the design width and nothing moves. */
+.model-hub-route-selector--width-route {
+ --model-hub-route-selector-inline-max: 420px;
+ --model-hub-route-selector-inline-room: var(
+ --radix-popover-content-available-width,
+ var(--model-hub-route-selector-inline-max)
+ );
+ width: min(
+ var(--model-hub-route-selector-inline-max),
+ var(--model-hub-route-selector-inline-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)