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(ui): restore add-hop picker and align Model Hub with the design frames
cyh3db0cddb734f
diff --git a/docs/plans/model-hub-fidelity-audit.md b/docs/plans/model-hub-fidelity-audit.mdnew file mode 100644index 000000000..c75d3ddfa--- /dev/null+++ b/docs/plans/model-hub-fidelity-audit.md@@ -0,0 +1,279 @@+# Model Hub — design-fidelity audit (frames 01 / 02 / 06)++Measured 2026-08-18 against the local Incus regression build at+`/admin/settings/models`, Dark theme. Design authority is `design.pen`; the+surface authority is `model-hub-ui-spec.md`. Per spec §0.2, **where a number in+the spec and a number in the frame disagree, the frame wins**; element+*presence* remains the spec's domain.++Frames compared:++| Frame | Node | Live surface |+| --- | --- | --- |+| 01 总览 | `pWQfB` | overview (`SettingsModelsPage` + `GatewayModule` + `SourcesCard` + `AgentCard`) |+| 02 路由链编辑 | `Q1dkS` | `RouteChainDialog` |+| 06 来源详情·型号管理 | `wItw4` | `SourceDetailPanel` |++Method: html-css export of each frame with inline computed styles, then a+DOM/`getComputedStyle` dump of the live surface at the same grain, compared+box-by-box. Frame viewport is 1440×1100; the live grid is anchored+(`.model-hub-overview-body` 1120×854, `.model-hub-overview-grid` 1120×806 —+both exactly the frame's values), so the measured viewport difference does not+affect the comparison.++## What already matches exactly++Recorded so a later pass does not "fix" a conforming value:++- Shell offsets: main 240, padding 36/40, gap 22, header at 280,36.+- Page title 26px/700 `#F5F1E8`, 52×37; runtime pill 81×23.+- Tabs strip: 1120 wide, gap 4, 1px bottom border, 2px `#5BFFA0` active+ indicator, tab width 114, padding-x 14, gap 7, icon 14, label 13px 600/400.+- Columns 384 / 72 rail / 632, gap 16. Panel radius 14, fill `#0E0E18`,+ border 1px `rgba(255,255,255,.08)`. Panel heads 56px, padding 0 14px.+- Upstream: content padding 12; card 358×80 r10, padding 0 12px, gap 10;+ tile 34 r9; footer 56, padding 0 14px, gap 8, top border.+- Gateway: content padding 8; agent head band 66, padding 0 14px, gap 7;+ agent tile 30 r9; rows padding 8 at 44px pitch. (The band and its 4px inset+ are the merged #1526 fix and are correct.)+- Model row box 596×36, padding 0 12px, gap 10, fill `rgba(255,255,255,.02)`;+ model name 12px/500; current text 10.5px/400 `rgba(155,163,184,.8)`;+ chevron 15.+- Upstream group label 10px/700 `rgba(255,255,255,.35)`; agent name 14px/700.+- Frame 06 table columns: x 299 / 565 / 665 / 1151, widths 250 / 84 / 470,+ gap 16, rows `align-items: center`. Source bar 1120×66 r12, padding+ 14px 18px, gap 14; tile 36 r9.+- Frame 02 dialog structure: 520 wide, head with mono subtitle, body label,+ bordered hop container with 添加一跳 as its last row, 按来源顺序重排 mint+ link, persisted-configuration hint, 取消 / 保存 foot. Dialog actions+ 54×33 / 52×33 r7 12px match `--model-hub-dialog-action-*`.++## A — Structural++| ID | Finding | Design | Live |+| --- | --- | --- | --- |+| A1 | Source detail replaces the tabs strip instead of rendering below it | frame 06 keeps the tabs strip at y=96 and puts the source bar at y=160; back button in the header at y=41 | `.model-hub-source-detail` starts at y=96, no tabs strip, back button at y=33 — the whole detail view sits ~64px high |+| A2 | Per-row overflow action missing on discovered models | frame 06 draws `···` on **every** table row, including `自动拉取` ones | `SourceDetailPanel.tsx:804` renders `ManualModelMenu` only when `model.origin === 'manual'`; the 230px action column is empty (`230×0`) on discovered rows |+| A3 | 添加一跳 selector is hand-rolled instead of the product's standard anchored selection surface | spec §1.2: "添加一跳 opens the product's standard anchored selection surface without assigning new frame geometry" — that surface is `ui/components/ui/combobox.tsx` (`Popover` + `Command` + `CommandInput` + `CommandGroup`), itself already design-anchored | `RouteChainDialog.tsx:964-1055` builds its own `Popover` + `section`/`p`/`button` list. See A3a–A3e below |+| A4 | Undesigned overview surfaces | frame 01 ends at the body; neither `最近切换` nor `高级` appears in the frame, and neither is registered anywhere in the spec | `RecentSwitchesCard` (h=195) and `AdvancedRow` (h=55) render after the body (`SettingsModelsPage.tsx:1122-1123`) |++A3 consequences, all observed:++- **A3a** No filter for 45 candidates across 2 sources; `Combobox` supplies+ `CommandInput` for exactly this.+- **A3b** Fill is `bg-background` (`#080812`) while the base `PopoverContent`+ uses `bg-panel` (= `--surface`, `#0e0e18`). The panel is therefore *darker*+ than the dialog it floats over.+- **A3c** No elevation: measured `box-shadow` is transparent, so with A3b the+ panel reads as a hole punched through the dialog rather than a layer above it.+- **A3d** The 300px panel flips above its trigger and overshoots the dialog+ (panel top y=148 vs dialog top y=300), overlaying the page title and tabs+ strip. `collisionPadding` bounds it to the *viewport*, not to the dialog.+- **A3e** The confirm button is stranded: the scroll list is 241px inside a+ 300px panel, so 添加 floats in ~50px of dead space with no separator or+ footer band. The active candidate's focus ring plus `aria-pressed` mint fill+ reads as a focused text `Input`, not a selected list row.+- **A3f** The list does not scroll — the original 「无法滚动,是定死的」, which+ §I below wrongly cleared. The CSS bound is fine and the box really is+ overflowing; the wheel never reaches it. `@radix-ui/react-dialog` mounts+ `RemoveScroll` on its Overlay with `shards: [contentRef]`, and+ `[email protected]` keeps a module-level `lockStack` whose+ `shouldPrevent` early-returns unless the top lock owns the event. A+ body-portalled **non-modal** `PopoverContent` is in neither the lock nor any+ shard, so every wheel inside it is `preventDefault()`ed by the dialog's lock.+- **A3g** The 来源 column is gone. Frame 02 labels each candidate with its+ source; `2c16c96af` (#1526) dropped that label while restyling the picker, so+ two identically-named models from different upstreams are now+ indistinguishable. A regression introduced by the previous fidelity pass, not+ an original gap.++## B — Radius++The token scale is `ui/src/index.css:99-105`+(`xs 4 / sm 6 / md 8 / lg 12 / xl 16 / 2xl 20 / 3xl 24`).++| ID | Element | Design | Live |+| --- | --- | --- | --- |+| B1 | agent group card | 12 (`rounded-lg`) | 16 (`rounded-xl`) |+| B2 | model row | 8 (`rounded-md`) | 12 (`rounded-lg`) — `AgentCard.tsx` |+| B3 | agent head action button | 8 | 12 |+| B4 | source-detail more button | 33×30 r7 | 32×32 r8 |+| B5 | route-selector confirm | surface token `--model-hub-dialog-action-radius: 7px` | 12 — the rule sets height and font-size but not radius, so the raw `Button` `rounded-lg` survives |++## C — Line-height inflation (systemic; single largest cause)++The root cascades a 1.5-ratio leading, so every element the frame draws with a+tight line box renders 1–4px taller. `modelHubSurface.css` already has the+remedy pattern (`--model-hub-route-hint-line: 17px`,+`--model-hub-agent-head-action-leading: 17px`); it simply has not been applied+to the rest.++| Element | Design box | Live box |+| --- | --- | --- |+| 10.5px pills (upstream count, gateway port, model count, accent pill, mode chip) | 23 | 24 |+| agent name `h2` | 17 | 21 |+| panel `h2` (网关 / 来源) | 23 | 24 |+| upstream card name | 18 | 19 |+| upstream card detail | 14 | 16 |+| table head label | 15 | 16 |+| table row model id | 16 | 18 |+| entry pill | 22 | 23 |+| footnote | 16 | 19 (line-height 18.69) |++**This is the user's 「上上下下,样式比较乱」.** The frame-06 columns, x-positions+and gap match exactly and every cell *is* vertically centered — but each column+carries a different amount of baked-in leading (18 vs 23 vs 26 against the+frame's 16 / 22 / 32), so the ink inside the boxes does not share a rhythm even+though the boxes do.++## D — Fill and colour++| ID | Element | Design | Live |+| --- | --- | --- | --- |+| D1 | 「N 个型号」 pill | `rgba(255,255,255,.04)` | opaque `#0E0E18` |+| D2 | panel footer secondary button | `rgba(255,255,255,.04)` | opaque `#080812` |+| D3 | source-bar 添加模型 | solid `#5BFFA0` with `#080812` ink | mint-ink ghost on `#11111C` |+| D4 | route selector | `bg-panel` (base popover) | `bg-background` — see A3b |++## E — Metrics++| ID | Element | Design | Live |+| --- | --- | --- | --- |+| E1 | gateway content gap (between agent groups) | 10 | 16 |+| E2 | upstream content gap (label↔card, card↔card) | 10 | 8 |+| E3 | agent head action height | 36 | 35 |+| E4 | tab height | 41 (padding 10px 14px + 2px indicator) | 39 |+| E5 | page-title info icon | 13×13 glyph | 26×26 wrapper (the 来源 panel icon is correctly 13×13) |+| E6 | panel footer buttons | 88×30 borderless / 113×32 1px, 11.5px/600 | 90×31 / 115×31, 11.5px/500 |+| E7 | source-bar action label | 12px/600 | 13px/500 |+| E8 | table row height / head padding / add-row padding | 55 / `10px 18px` / `12px 18px` | 54 / `0 18px` / `0 18px` |+| E9 | source-bar identity line gap | 7 | 8 |+| E10 | 来源 panel content region | 430px holding 406px of cards (~24px slack) | 306px holding 194px of cards (~100px void above the footer) |++## F — Alignment++| ID | Finding |+| --- | --- |+| F1 | `.model-hub-model-current` is `min-w-0 flex-1 truncate` with no `text-right`. The frame right-aligns it against the chevron (x=1233, w=111); live leaves it at x=1077, w=268, so short values such as `—` float mid-row. |++## G — Data-state differences, not defects++Verified against the spec and the code; the regression fixture has zero supply+relations and no runnable hops.++- Supply legend absent — `SupplyGraph.tsx:88-89` returns `null` at zero relations.+- Rail wires absent — same cause.+- All 18 model rows uncollapsed — G-25 plus `has_runnable_hop` false everywhere+ (`AgentCard.tsx:118`).+- 「没有可用来源」 line present; `—` in the current-source slot.+- Neutral (not cyan/mint) tiles; 20 table rows against the frame's 12.+- 「未设置档位 + 添加档位」 in the tier column **is** the designed empty state —+ frame 06 draws it on `glm-4.6v` and `ernie-5.0`. Not a defect. The frame's+ 32px tier slot vs live's 26px comes from filled rows carrying 24–25px chips.++## H — Spec-vs-frame conflicts needing a decision++Not silent defects: the frame owns numbers, the spec owns element presence, and+these two disagree about presence.++| ID | Conflict | Options |+| --- | --- | --- |+| H1 | `.model-hub-model-mode-chip` (28×24, currently rendering `—`). Frame 01's model row does not draw it; spec §1.1 registers "a chain chip" in `Exx0a`'s inventory. | Drop the chip and correct §1.1, or draw it into the frame. |+| H2 | A4's `最近切换` and `高级`: rendered, drawn nowhere, registered nowhere. | Draw them into frame 01 and register them, or remove them. |++## I — Checked and cleared++- ~~**Route-selector scrolling already works.**~~ **Wrong — withdrawn.** The+ cited evidence was real (`modelHubSurface.css:724-733` bounds the panel and+ puts `overflow-y: auto` on the list; `scrollHeight 1480` vs+ `clientHeight 241`) but it does not support the conclusion. All of it+ describes the *box*; 「无法滚动」 is about the *event*, and no wheel was ever+ dispatched before clearing the item. A box can be perfectly overflowing and+ still refuse to scroll if an ancestor cancels the wheel — which is exactly+ what was happening. Filed as A3f. The general lesson: an event-outcome claim+ is only closed by dispatching the event.+- **「路由链没读到」 on first open did not reproduce.** Seen once, then clean on+ three subsequent opens; `GET /api/models/agents/<backend>/chain` returns 200+ with `chain: []`, which the dialog correctly renders as the empty-but-valid+ Route. Not filed.+- Frame-06 column geometry, and the whole "already matches" list above.++## Convergence order++1. **C** — one pass over `modelHubSurface.css` adding explicit line-height+ tokens. Largest visible win, lowest risk, and it is what the reported table+ complaint actually is.+2. **A1** — restore the tabs strip above the source detail.+3. **A3** — rebuild the add-hop surface on `Combobox`/`Command`.+4. **B**, **D**, **E**, **F** — mechanical token corrections.+5. **A2** — needs the behaviour decision first (frame 06's own dialog says+ 「只有手动添加的型号能移除」, so a discovered row's `···` needs a defined menu).+6. **H1**, **H2** — decide, then either correct the spec or change the code.++## Resolution++This pass closed **A3** (including A3f/A3g) and all of **C**, **B**, **D**,+**E**, **F**. Still open: A1, A2, A4, H1, H2.++Two entries were implemented as something other than what the table's Design+column literally says. Both are reinterpretations of the measurement, not+descoping:++- **E6 — footer buttons.** The frame's `88×30` borderless and `113×32` 1px are+ not two different heights: they are one 30px band with the outlined button's+ stroke drawn *outside* it, which is what makes its border-box 2px taller.+ Implemented as exactly that (`--model-hub-footer-action-height: 30px` plus a+ `--outlined` modifier at `+2px`), so the relationship survives a token+ change. The **widths are deliberately left content-driven**: 88 and 113 are+ what the frame's Chinese labels measure, and pinning them would clip every+ other locale.+- **E8 — table head / add-row padding.** The frame's `10px 18px` and+ `12px 18px` describe a 35px head and a 41px add row. Under Tailwind's+ `box-sizing: border-box` preflight, the existing `height` + `align-items:+ center` already produce those exact boxes, so writing the padding would be a+ second spelling of a satisfied constraint. Only the row height was actually+ wrong (54 → 55); `--model-hub-source-table-draft-height` was already 55.++Two ownership consolidations came out of the C pass rather than being listed as+findings:++- `.model-hub-pill` now owns the 10.5px status pill's box (six call sites:+ upstream count, gateway port, model-count badge, source kind, model mode,+ direct kind). Colour stays at the call site. A seventh pill written as a+ utility bundle fails `modelHubStylePolicy.test.ts` instead of costing a+ review round.+- The add-hop picker is now composed from the shared anchored-selection+ primitives — `Popover` plus `Command` / `CommandInput` / `CommandList` /+ `CommandItem` and `Button` — the same set `Combobox` is built from, instead+ of hand-rolled markup. `Combobox` itself cannot be the surface: this picker+ is a two-column source/model grid and commits in two steps (highlight, then+ 「添加」), where a combobox commits on select. So what is shared is the+ primitive layer, and A3f is fixed at that layer: `combobox.tsx` was given the+ same `modal` treatment, so every dialog-hosted picker in the product is+ covered by the one diagnosis rather than only this one.++### A3d — where the picker opens++A3d asked for the panel to stay inside its dialog. Two ways of expressing that+were built and measured on the empty-chain fixture (`claude-fable-5`, 1440×801),+and both were worse than the defect:++| Variant | Panel | List | Verdict |+| --- | --- | --- | --- |+| `collisionBoundary` = the dialog | 131px | **18px** over 1272px of content | One visible row. Ships the original complaint in a new form. |+| Viewport boundary, collisions on | 300px | 187px | Flips to `side: "top"` at y=148 — 150px above the dialog's own top, covering the page title and tab strip. |++The dialog is sized by its chain, so an empty chain — exactly when this picker+matters — makes it short, and the same boundary feeds+`--radix-popover-content-available-height`. The flip happens because the room+below the trigger lands a few pixels under the 300px preference.++Resolved by making placement deterministic and the height adaptive instead:+`side="bottom" avoidCollisions={false}` with the existing+`max-height: min(300px, available-height)` cap. Measured: panel 287px attached+6px under its trigger, list 174px over 1272px of content, 45 rows, bottom edge+785px inside an 801px viewport, `wheel` not prevented. A long chain that pushes+the trigger down yields a shorter panel, still scrolling, and the dialog body+scrolls so the trigger can be brought back up. Panel overhang past the dialog's+lower edge is accepted — ordinary floating-layer behaviour, unlike a one-row+list or a panel over the page title.diff --git a/docs/plans/model-hub-ui-spec.md b/docs/plans/model-hub-ui-spec.mdindex d35ea7b24..57027dec1 100644--- a/docs/plans/model-hub-ui-spec.md+++ b/docs/plans/model-hub-ui-spec.md@@ -841,7 +841,7 @@ state exit; held intent never bypasses the evidence column.| §1.1 | Leaving the gateway | 切换到直连 pressed on a gateway group `[frame]` D-30 — `PATCH /api/models/agents/<backend>/mode` | F1, in place on the group head | `gateway.switchToDirect`, `gateway.fail.switchToDirect`, `gateway.retry` | Success → the group re-renders in its 直连 form; when it was the last gateway backend the page is decided by the sources that are still there, not by the switch — no source left → 09, at least one source retained → **01**, which is §1.8's own *Retained sources* branch and not this frame; a failure keeps the group on the gateway and puts the line and 重试 on the group head, which is the slot the re-rendered form would have used || §1.2 | Loading route | A model row opens 02 with the exact `(backend, menu_model)` held; `GET /api/models/agents/<backend>/chain?model=<id>` owns the dialog body | F1 → Route unread | `route.title`, `route.loading`, `route.cancel` | ET-1–ET-4, ET-8a and ET-18a own opening, response dispatch, focus, retry and the non-mutating exit; an unlisted answer cannot leave this state || §1.2 | Route unread `[derived]` | The dialog-owned opening chain read failed while the containing page remains mounted | F1, in place | `route.fail.read`, `route.retry`, `route.cancel` | ET-3/ET-4/ET-8a own entry, Retry and the non-mutating exit; the independent dialog read never rewrites the held page row |-| §1.2 | Ready | The exact AgentChain is held and the local pair projection is byte-identical to its opening `chain` | F5 | `route.title`, `route.section`, `route.addHop`, `route.reorder`, `route.hint`, `route.cancel`, `route.save`; `route.removeHop` / `route.grip` when `hops` is nonempty; `route.empty` only when it is empty; `route.add.none` when no candidate remains; `route.add.source`, `route.add.model`, `route.add.confirm` while the Add selector is open; `route.sourceMissing` only on a hop whose authoritative chain annotation reads `reason: source_missing`; `route.reorder.grabbed`, `route.reorder.position`, `route.reorder.dropped`, `route.reorder.cancelled`, `route.reorder.sorted`, `route.reorder.unchanged` only for their registered live-region event | ET-5a–ET-7f, ET-8a and ET-9a own every selector, local edit, grab, exit and submission edge |+| §1.2 | Ready | The exact AgentChain is held and the local pair projection is byte-identical to its opening `chain` | F5 | `route.title`, `route.section`, `route.addHop`, `route.reorder`, `route.hint`, `route.cancel`, `route.save`; `route.removeHop` / `route.grip` when `hops` is nonempty; `route.empty` only when it is empty; `route.add.none` when no candidate remains; `route.add.source`, `route.add.model`, `route.add.search`, `route.add.confirm` while the Add selector is open, and `route.add.noMatch` only while a typed filter excludes every candidate; `route.sourceMissing` only on a hop whose authoritative chain annotation reads `reason: source_missing`; `route.reorder.grabbed`, `route.reorder.position`, `route.reorder.dropped`, `route.reorder.cancelled`, `route.reorder.sorted`, `route.reorder.unchanged` only for their registered live-region event | ET-5a–ET-7f, ET-8a and ET-9a own every selector, local edit, grab, exit and submission edge || §1.2 | Dirty | The ordered pair draft differs from the current reversible origin and remains V5-valid | F5 — every edit is local | Same normal-frame keys as Ready | ET-5a–ET-7f, ET-8a and ET-9a own every selector, local edit, grab, exit and submission edge || §1.2 | Invalid after refresh `[derived]` | ET-17e holds refreshed Hub AgentSupply/Source/chain authorities and at least one new or changed draft pair is now V5-invalid; unchanged persisted stale pairs do not enter this state | F5 — the refresh completed and no mutation is sent | Same normal-frame keys as Dirty plus `route.invalidAfterRefresh` on every offending row | ET-5a–ET-8a and ET-17e own repair, exit and focus. Every offending row stays removable; Save remains disabled with the rendered invalid lines as its description || §1.2 | Saving | 保存 or guard confirmation activated — `PUT /api/models/agents/<backend>/chain?model=<id>` sends the complete submitted `hops`; the first request is non-forced and a confirmed retry carries `force: true` plus both exact refusal arrays `[contract]` | DP-2: the request owns the dialog and every dismissal path until classification | `route.saving` | ET-9a/ET-13b, ET-10, ET-12, ET-14, ET-15 and ET-18a own the complete response dispatch and destination focus for every answer/no-answer branch |@@ -1988,11 +1988,20 @@ V5 is the sole Add-hop and draft validator. 添加一跳 opens the product's staselection surface without assigning new frame geometry: candidates come from the currentAgentSupply eligibility plus Source inventory, are grouped by Source, name the exactupstream model id, and exclude duplicate pairs. The selector owns exactly one active-candidate, which is also its selected pair: ET-5a selects the first candidate as it receives-focus, and every ET-5d roving-focus move atomically replaces both values. Pointer activation+candidate, which is also its selected pair: ET-5a selects the first listed candidate as the+surface opens, and every ET-5d move atomically replaces both values. Which element holds DOM+focus is the standard surface's business — the filter field owns the caret and carries the+active candidate as its active descendant — so "active" here names the one owner the+confirmation reads, never a focus location. Pointer activationfirst makes that exact candidate active/selected; the separate confirmation is enabled andderived only from this one owner. Confirming appends that exact pair and focuses its grip-through ET-5c. Identity mapping and an explicit cross-model mapping are+through ET-5c. The surface also carries the standard filter field, which narrows what is+listed and never what is legal: the active candidate is always one of the candidates+currently listed, so a filter — or a draft change — that drops it re-elects the first listed+one rather than leaving the confirmation pointing at a row nobody can see. A filter that+excludes everything renders `route.add.noMatch`, which is a statement about the typed term+and never about supply; `route.add.none` remains the only claim that no pair is available.+Identity mapping and an explicit cross-model mapping areequally legal; the UI never invents a substitute model. If no valid pair remains, theaction is disabled with `route.add.none`. Persisted pairs that later became stale stay inthe list and may be reordered or removed, because the contract validates only new or@@ -2279,7 +2288,7 @@ cannot name the reducer/CA result for one row is incomplete.| RT-18 — CA-D positive phase partition | Table-drive initial idle/busy, generic-subset idle/busy, Source-only idle/busy, post-nonmatch exact-read idle, plus invalid and successful products | Each of the seven named families selects exactly its CA-D row; invalid/successful selects zero enabled rows. ET-17b cannot also admit CA-D1, ET-17f cannot also admit CA-D1/D3, and every busy phase emits nothing for pointer/Enter/Space. CA-R1 is exercised separately and can create only a new workflow || RT-19 — unknown/nonmatch dismissal | Exercise `unknown + nonmatching@epoch` while Source is pending, after failure and during Source-only Retry; invoke Cancel/title-close/Escape/outside | Every gesture takes ET-8b: first retain the installed exact AgentChain, then disown modal-only work, drop the old attempt evidence and reveal that newest authority. It sends no read/mutation. Saving remains inert, terminal rejection uses ET-8a and committed stays ET-20 || RT-20 — PF-1 survives removed backend | Refresh the edited backend to `cli_present: false` in (a) Hub/01 with retained Sources and zero installed groups and (b) Direct/no-Sources No backend found | Active target, model row and group head all fail FF-1; PF-1 selects the first existing registered control on the exact destination page. Focus never targets the omitted group or unregistered text, and no new UI/copy is required |-| RT-21 — selector selection owner | Open Add selector, then move by Arrow/Home/End and pointer before confirmation | ET-5a selects the first focused candidate; every ET-5d move atomically makes the new active candidate the selected pair. `route.add.confirm` derives enabled state only from that owner and ET-5c appends exactly it |+| RT-21 — selector selection owner | Open Add selector, then move by Arrow/Home/End and pointer, and narrow by filter, before confirmation | ET-5a selects the first listed candidate; every ET-5d move atomically makes the new active candidate the selected pair, and a filter that drops the active one re-elects the first still-listed candidate through the same edge. `route.add.confirm` derives enabled state only from that owner and ET-5c appends exactly it || RT-22 — rejected is terminal, unknown is read-only | Table-drive shaped rejection, unknown + matching, unknown + nonmatching and unknown + read failure | Rejection performs no D-36 read and explicit Retry creates a new workflow/PUT. Matching enters commit/M6. Nonmatching and failure leave the old attempt unknown and can issue only chain reads or abandon; no case emits a recovery PUT || RT-23 — late old PUT after nonmatch | Exact chain read returns nonmatch, then the unanswered old PUT commits after the observation | The installed nonmatching chain remains the latest observed authority and no PUT was resent. A later D-35/row-open read naturally installs the late commit; the UI never claims the earlier nonmatch proved non-commit || RT-24 — successful-member install before exit | In each response order, settle successful Agents, Source or nonmatching/matching AgentChain, then immediately dismiss or transfer the modal | The member is installed before cleanup/focus/owner change. ET-8a/ET-8b may discard workflow evidence but the receiving page cannot reveal an older member projection |@@ -2372,10 +2381,10 @@ generation is ignored and cannot install authority, feedback or focus.| ET-2 — opening chain success | Loading route + returned AgentChain | Validate the envelope, then install its exact pair array as origin and draft | Clear loading only | Ready | Normal frame copy | Keep `route.cancel`; payload arrival does not steal focus | None || ET-3 — opening non-direct failure | Loading route + held page row; DM-1 is reserved for ET-18a | Exclude `direct_mode`, then classify the shaped/transport failure | Clear loading; retain the independent page row | Route unread | `route.fail.read` | `route.retry` | None until explicit Retry || ET-4 — unread Retry | Route unread + exact identity/page row | Settle the old RL generation, acquire its successor and reissue only the opening chain GET | Clear the old error | Loading route | `route.loading` | FF-1-valid `route.cancel` | Dialog-owned chain GET |-| ET-5a — open Add selector | Ready, Dirty or Invalid after refresh + current V5 authorities | Materialize current V5 candidates and make the first focused candidate the single active/selected pair | Clear any prior selector owner before assigning that pair | Same editor state + selector open | Selector keys; existing invalid lines remain | The active/selected first exact candidate | None |+| ET-5a — open Add selector | Ready, Dirty or Invalid after refresh + current V5 authorities | Materialize current V5 candidates, focus the filter field and make the first listed candidate the single active/selected pair carried as its active descendant | Clear any prior selector owner before assigning that pair | Same editor state + selector open | Selector keys; existing invalid lines remain | The active/selected first exact candidate | None || ET-5b — dismiss Add selector | Open selector + unchanged draft | Send/read nothing | Clear selector selection and close only the selector | Owning Ready, Dirty or Invalid state | Normal frame copy; existing invalid lines remain | `route.addHop` | None || ET-5c — confirm Add candidate | Open selector + selected exact pair | Revalidate the pair through V5, then append it | Clear selection and close selector | Ready if equal to origin, otherwise Dirty or existing Invalid after refresh | Normal copy plus every remaining invalid line | New row's grip | None |-| ET-5d — choose another Add candidate | Open selector + current active/selected candidate | Send/read nothing; Arrow/Home/End or pointer activation atomically makes the destination candidate both active and selected | Replace the one prior active/selected owner | Same open selector | Existing selector copy | Newly active/selected candidate | None |+| ET-5d — choose another Add candidate | Open selector + current active/selected candidate | Send/read nothing; Arrow/Home/End from the filter field, pointer activation, or a filter change that drops the active candidate atomically makes the destination candidate both active and selected | Replace the one prior active/selected owner | Same open selector | Existing selector copy | Newly active/selected candidate | None || ET-6a — remove one row | Ready, Dirty or Invalid after refresh + exact row/draft | Remove locally, then re-run V5 | Drop selector/grab state owned by that row | Ready if equal to origin; Dirty if changed and valid; Invalid only while a marked row remains | Normal copy plus every remaining invalid line | First FF-1-valid target: successor grip; predecessor grip; when empty `route.addHop` only if V5 admits it; then `route.reorder`; finally enabled `route.cancel` | None || ET-6b — pointer move one row | Ready, Dirty or Invalid after refresh + exact row/draft | Apply the one pointer move, then re-run V5 | Finish the pointer operation | Ready if equal to origin; Dirty if changed and valid; existing Invalid while marked rows remain | `route.reorder.position` plus registered invalid lines | Moved row's grip | None || ET-6c — global draft sort | Ready, Dirty or Invalid after refresh + exact draft and page-held Source order | Apply the registered stable local sort once, then re-run V5; no-op is valid | Finish only the sort gesture | Ready if equal to origin; Dirty if changed and valid; existing Invalid while marked rows remain | Changed → `route.reorder.sorted`; no-op → `route.reorder.unchanged`; retain registered invalid lines | `route.reorder`, including after a no-op | None |@@ -2472,7 +2481,8 @@ products select no enabled CA-D row:| Route unread | 取消 button | `route.cancel` | Enabled | Normal Tab order; activation emits ET-8a || Route unread | Title-bar close | `route.cancel` | Enabled | Independent Tab stop; activation emits ET-8a || Ready / Dirty / Invalid after refresh | 添加一跳 | `route.addHop`; disabled explanation `route.add.none` | Enabled exactly when V5 exposes a candidate | Normal Tab order; activation emits ET-5a |-| Ready / Dirty / Invalid after refresh + Add selector | Source/model candidate region | `route.add.source`, `route.add.model` | Labels render while open; exactly one valid pair is the active/selected candidate | Arrow/Home/End or pointer activation emits ET-5d; Escape emits ET-5b; Tab reaches confirmation |+| Ready / Dirty / Invalid after refresh + Add selector | Candidate filter field | `route.add.search`; empty-result explanation `route.add.noMatch` | Enabled while open; receives focus as the selector opens | Typing narrows the listed candidates and re-elects the active one through ET-5d; Escape emits ET-5b; Tab reaches the candidate region |+| Ready / Dirty / Invalid after refresh + Add selector | Source/model candidate region | `route.add.source`, `route.add.model` | Labels render while open; exactly one currently listed valid pair is the active/selected candidate | Arrow/Home/End or pointer activation emits ET-5d; Escape emits ET-5b; Tab reaches confirmation || Ready / Dirty / Invalid after refresh + Add selector | 添加 confirmation | `route.add.confirm` | Enabled only for the selected exact V5-valid pair | Activation emits ET-5c || Ready / Dirty / Invalid after refresh | 按来源顺序重排 | `route.reorder` | Enabled; stable-sort no-op remains valid | Normal Tab order; activation emits ET-6c and focus stays here || Ready / Dirty / Invalid after refresh | Each hop grip | `route.grip` | Rendered for every hop; exactly one grip is the roving list tab stop | Pointer drag emits ET-6b; Space/Arrow/Home/End/Tab/Escape emit ET-7a–ET-7f by phase |@@ -2520,7 +2530,7 @@ focus:| `Tab` / `Shift+Tab` | Ungrabbed: move through each enabled control, including Cancel and title-close as distinct stops, and wrap in the modal. Grabbed: ET-7f first drops and clears `aria-grabbed`, then performs that move || `Space` on a grip | Ungrabbed → ET-7b start; grabbed → ET-7d drop || `↑` / `↓`, `Home` / `End` on a grip | Ungrabbed → ET-7a roving focus; grabbed → ET-7c draft movement |-| Candidate Arrow / `Home` / `End`, or pointer activation | ET-5d atomically moves the selector's one active/selected owner |+| Candidate Arrow / `Home` / `End` from the selector's filter field, or pointer activation | ET-5d atomically moves the selector's one active/selected owner || `Escape` | Grabbed → ET-7e cancel/restore; selector open → ET-5b; otherwise emit the exact phase edge in the dismissal matrix (including guard → ET-13a); Saving emits nothing || `Enter` / `Space` on a remove action | ET-6a removes that row || `Enter` / `Space` on 按来源顺序重排 | ET-6c sorts and retains `route.reorder` focus |diff --git a/ui/src/components/settings/models/AgentCard.tsx b/ui/src/components/settings/models/AgentCard.tsxindex 0d2f03a5f..7c3c648fd 100644--- a/ui/src/components/settings/models/AgentCard.tsx+++ b/ui/src/components/settings/models/AgentCard.tsx@@ -62,11 +62,11 @@ const ModelRow: React.FC<{data-route-model={modelId}onClick={(event) => onOpenRoute(agent, modelId, event.currentTarget)}aria-label={t('settings.models.routeDialog.open', { model: modelId }) as string}- className="model-hub-model-row flex h-9 w-full min-w-0 items-center gap-2.5 overflow-hidden rounded-lg border border-border px-3 text-left"+ className="model-hub-model-row flex h-9 w-full min-w-0 items-center gap-2.5 overflow-hidden rounded-md border border-border px-3 text-left"><span className="flex min-w-0 flex-1 items-center justify-between gap-2.5">- <span className="flex min-w-0 flex-1 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="model-hub-model-mode-chip shrink-0 rounded-full border border-border px-2 py-[3px] text-[10.5px] font-semibold text-muted">{mode}</span></span>- <span className={cn('model-hub-model-current min-w-0 flex-1 truncate text-[10.5px]', supplyState === 'paused' ? 'model-hub-ink-gold' : takeover && 'model-hub-model-current--takeover')} title={currentCopy}>{currentCopy}</span>+ <span className="flex min-w-0 flex-1 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="model-hub-pill model-hub-model-mode-chip border border-border text-muted">{mode}</span></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' : takeover && 'model-hub-model-current--takeover')} title={currentCopy}>{currentCopy}</span></span><ChevronRight className="model-hub-overview-chevron size-[15px] shrink-0" aria-hidden="true" /></button>@@ -129,7 +129,7 @@ const AgentModelCard: React.FC<{? 'bg-mint': 'bg-muted';return (- <section className="overflow-hidden rounded-xl border border-border bg-background" data-agent-backend={agent.backend}>+ <section className="overflow-hidden rounded-lg border border-border bg-background" data-agent-backend={agent.backend}><divtabIndex={-1}data-agent-group-head={agent.backend}@@ -139,13 +139,13 @@ const AgentModelCard: React.FC<{<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 text-foreground">{t(`settings.models.backends.${agent.backend}`, { defaultValue: agent.backend })}</h2>- <Badge variant="secondary" className={cn('px-2 py-[3px] text-[10.5px] font-semibold', hasTakeover && 'model-hub-takeover-chip')}>+ <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></div>- {agent.mode === 'hub' ? <div className="flex shrink-0 flex-wrap gap-2"><Button variant="secondary" size="sm" className="model-hub-agent-head-action rounded-lg px-3 text-[11.5px] font-bold" onClick={() => onOpenOrder(agent)} disabled={pending}>{t('settings.models.gateway.sourceOrder')}</Button><Button variant="outline" size="sm" className="model-hub-agent-head-action rounded-lg px-3 text-[11.5px] font-bold" onClick={() => onSwitchDirect(agent)} disabled={pending}>{t(switchFailed ? 'settings.models.gateway.retry' : 'settings.models.gateway.switchToDirect')}</Button></div> : <Button variant="secondary" size="sm" className="model-hub-agent-head-action shrink-0 self-start rounded-lg px-3 text-[11.5px] font-bold sm:self-auto" onClick={() => onConnectHub(agent)} disabled={connecting}>{t('settings.models.gateway.switchToGateway')}</Button>}+ {agent.mode === 'hub' ? <div className="flex shrink-0 flex-wrap gap-2"><Button variant="secondary" size="sm" className="model-hub-agent-head-action rounded-md px-3 text-[11.5px] font-bold" onClick={() => onOpenOrder(agent)} disabled={pending}>{t('settings.models.gateway.sourceOrder')}</Button><Button variant="outline" size="sm" className="model-hub-agent-head-action rounded-md px-3 text-[11.5px] font-bold" onClick={() => onSwitchDirect(agent)} disabled={pending}>{t(switchFailed ? 'settings.models.gateway.retry' : 'settings.models.gateway.switchToDirect')}</Button></div> : <Button variant="secondary" size="sm" className="model-hub-agent-head-action shrink-0 self-start rounded-md px-3 text-[11.5px] font-bold sm:self-auto" onClick={() => onConnectHub(agent)} disabled={connecting}>{t('settings.models.gateway.switchToGateway')}</Button>}</div><span className={cn('model-hub-agent-head-status flex items-center gap-1.5 text-[11px] font-semibold sm:ml-[42px]', statusClass)}><span className={cn('size-[5px] shrink-0 rounded-full', statusDot)} />@@ -171,4 +171,4 @@ 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-4">{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 }) => <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>;diff --git a/ui/src/components/settings/models/GatewayModule.tsx b/ui/src/components/settings/models/GatewayModule.tsxindex 4df0da45c..9694c9a8c 100644--- a/ui/src/components/settings/models/GatewayModule.tsx+++ b/ui/src/components/settings/models/GatewayModule.tsx@@ -28,8 +28,8 @@ export const GatewayModule: React.FC<GatewayModuleProps> = ({ runtime, runtimeSnreturn (<section className="relative z-20 flex max-h-full min-h-[420px] flex-col self-start overflow-hidden rounded-[14px] border border-border bg-surface"><header className="flex h-14 shrink-0 items-center justify-between border-b border-border px-3.5">- <h2 className="text-[16px] font-bold text-foreground">{t('settings.models.gateway.heading')}</h2>- {listening && <span className="model-hub-fill-0a rounded-full border border-border px-2 py-[3px] text-[10.5px] font-semibold text-muted">{listening.host}:{listening.port}</span>}+ <h2 className="text-[16px] font-bold leading-[23px] text-foreground">{t('settings.models.gateway.heading')}</h2>+ {listening && <span className="model-hub-pill model-hub-fill-0a border border-border text-muted">{listening.host}:{listening.port}</span>}</header><div className="min-h-0 flex-1 overflow-y-auto p-2">{supply.kind === 'loading' && agents === undefineddiff --git a/ui/src/components/settings/models/RouteChainDialog.test.tsx b/ui/src/components/settings/models/RouteChainDialog.test.tsxindex d1836de98..7f83db149 100644--- a/ui/src/components/settings/models/RouteChainDialog.test.tsx+++ b/ui/src/components/settings/models/RouteChainDialog.test.tsx@@ -2,7 +2,7 @@import { act, cleanup, render, screen, waitFor } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { I18nextProvider } from "react-i18next";-import { afterEach, describe, expect, it, vi } from "vitest";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import i18n from "@/i18n";import { ApiCallError, modelsApi } from "./modelsApi";@@ -87,6 +87,38 @@ const mutation = (removed_hops: report.removed_hops ?? [],interrupted: report.interrupted ?? [],});+/** An Agent whose eligible sources actually carry spare models — the only shape+ * that makes the add-hop selector reachable, since `routeCandidates` excludes+ * the pairs the draft already holds. */+const stocked = () => ({+ agent: {+ ...agent,+ sources: {+ order: ["src_a", "src_b"],+ eligibility: [+ { source_id: "src_a", eligible: true },+ { source_id: "src_b", eligible: true },+ ],+ },+ } satisfies AgentSupply,+ sources: [+ {+ ...sources[0],+ models: [+ { id: "claude-opus-5", origin: "discovered", reasoning_efforts: [] },+ { id: "claude-sonnet-5", origin: "discovered", reasoning_efforts: [] },+ { id: "claude-haiku-5", origin: "discovered", reasoning_efforts: [] },+ ],+ },+ {+ ...sources[1],+ models: [+ { id: "opus-5", origin: "discovered", reasoning_efforts: [] },+ { id: "sonnet-5", origin: "discovered", reasoning_efforts: [] },+ ],+ },+ ] satisfies Source[],+});const observation = <T,>(value: T) => ({ value, install: vi.fn() });const deferred = <T,>() => {let resolve!: (value: T) => void;@@ -97,6 +129,26 @@ const deferred = <T,>() => {});return { promise, reject, resolve };};+const renderStockedDialog = () => {+ const fixture = stocked();+ vi.spyOn(modelsApi, "getAgentChain").mockResolvedValue(chain);+ render(+ <I18nextProvider i18n={i18n}>+ <RouteChainDialog+ selection={{+ agent: fixture.agent,+ modelId: "opus-5",+ read: readyRegion(chain),+ }}+ sources={fixture.sources}+ onClose={vi.fn()}+ onCommitted={vi.fn()}+ readAgents={vi.fn().mockResolvedValue(observation([fixture.agent]))}+ readSources={vi.fn().mockResolvedValue(observation(fixture.sources))}+ />+ </I18nextProvider>,+ );+};const renderDialog = (onCommitted = vi.fn()) => {vi.spyOn(modelsApi, "getAgentChain").mockResolvedValue(chain);return render(@@ -113,9 +165,24 @@ const renderDialog = (onCommitted = vi.fn()) => {);};+beforeEach(() => {+ // cmdk observes its list box and scrolls the active row into view; jsdom+ // implements neither.+ vi.stubGlobal(+ "ResizeObserver",+ class {+ observe() {}+ unobserve() {}+ disconnect() {}+ },+ );+ Element.prototype.scrollIntoView = vi.fn();+});+afterEach(() => {cleanup();vi.restoreAllMocks();+ vi.unstubAllGlobals();});describe("RouteChainDialog", () => {@@ -464,31 +531,7 @@ describe("RouteChainDialog", () => {it("returns an invalidated pending draft to editing after a named rejection", async () => {const user = userEvent.setup();const pending = deferred<AgentChainMutation>();- const editableAgent: AgentSupply = {- ...agent,- sources: {- order: ["src_a", "src_b"],- eligibility: [- { source_id: "src_a", eligible: true },- { source_id: "src_b", eligible: true },- ],- },- };- const editableSources: Source[] = [- {- ...sources[0],- models: [- { id: "claude-opus-5", origin: "discovered", reasoning_efforts: [] },- { id: "claude-sonnet-5", origin: "discovered", reasoning_efforts: [] },- ],- },- {- ...sources[1],- models: [- { id: "opus-5", origin: "discovered", reasoning_efforts: [] },- ],- },- ];+ const { agent: editableAgent, sources: editableSources } = stocked();vi.spyOn(modelsApi, "getAgentChain").mockResolvedValue(chain);vi.spyOn(modelsApi, "putAgentChain").mockReturnValue(pending.promise);const props = {@@ -539,6 +582,107 @@ describe("RouteChainDialog", () => {).toBe(true);});+ it("names both candidate columns and prints each source once per group", async () => {+ const user = userEvent.setup();+ renderStockedDialog();+ await screen.findAllByRole("button", { name: "Remove hop" });++ await user.click(screen.getByRole("button", { name: "Add a hop" }));++ expect(screen.getByText("Source")).toBeTruthy();+ expect(screen.getByText("Model")).toBeTruthy();+ // Both halves of a candidate are legible: the model id AND which source+ // supplies it. The source column is what a sizing rework once dropped, so+ // the assertion is over the rendered row grid, not over the mere presence+ // of the name somewhere in the panel.+ const rows = [...document.querySelectorAll(".model-hub-route-candidate")];+ expect(+ rows.map((row) => [+ row.querySelector(".model-hub-route-candidate-source")?.textContent,+ row.querySelector(".model-hub-route-candidate-model")?.textContent,+ ]),+ ).toEqual([+ ["API key", "claude-haiku-5"],+ ["", "claude-sonnet-5"],+ ["Claude subscription", "sonnet-5"],+ ]);+ });++ it("narrows the candidates to what was typed without claiming none exist", async () => {+ const user = userEvent.setup();+ renderStockedDialog();+ await screen.findAllByRole("button", { name: "Remove hop" });+ await user.click(screen.getByRole("button", { name: "Add a hop" }));++ await user.type(+ screen.getByPlaceholderText("Search sources or models"),+ "subscription",+ );++ expect(+ [...document.querySelectorAll(".model-hub-route-candidate-model")].map(+ (cell) => cell.textContent,+ ),+ ).toEqual(["sonnet-5"]);++ await user.clear(screen.getByPlaceholderText("Search sources or models"));+ await user.type(+ screen.getByPlaceholderText("Search sources or models"),+ "gpt",+ );++ expect(screen.getByText("No source or model matches that")).toBeTruthy();+ expect(+ (screen.getByRole("button", { name: "Add" }) as HTMLButtonElement)+ .disabled,+ ).toBe(true);+ });++ it("keeps the candidate list scrollable while the dialog locks the page", async () => {+ const user = userEvent.setup();+ renderStockedDialog();+ await screen.findAllByRole("button", { name: "Remove hop" });+ await user.click(screen.getByRole("button", { name: "Add a hop" }));++ // The dialog locks page scrolling through `react-remove-scroll`, which+ // cancels wheel events outside its own lock and shards. The selector is+ // portalled to `document.body`, so it is outside both unless it owns a lock+ // of its own — and when it does not, the panel keeps its `overflow-y: auto`+ // and its overflowing content while the wheel silently does nothing. Only+ // the event outcome can see that, so it is measured here rather than+ // inferred from the CSS. jsdom has no layout, so the scrollability the+ // browser gets from that CSS is stated explicitly.+ const list = document.querySelector<HTMLElement>(+ ".model-hub-route-selector-list",+ );+ expect(list).not.toBeNull();+ (list as HTMLElement).style.overflowY = "auto";+ Object.defineProperty(list, "scrollHeight", {+ value: 1000,+ configurable: true,+ });+ Object.defineProperty(list, "clientHeight", {+ value: 200,+ configurable: true,+ });+ const wheelPrevented = (node: Element) => {+ const event = new WheelEvent("wheel", {+ bubbles: true,+ cancelable: true,+ deltaY: 240,+ });+ node.dispatchEvent(event);+ return event.defaultPrevented;+ };++ expect(+ wheelPrevented(document.querySelector(".model-hub-route-candidate")!),+ ).toBe(false);+ expect(+ wheelPrevented(document.body.appendChild(document.createElement("div"))),+ ).toBe(true);+ });+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.tsxindex 1a3c13e80..6ad9999da 100644--- a/ui/src/components/settings/models/RouteChainDialog.tsx+++ b/ui/src/components/settings/models/RouteChainDialog.tsx@@ -11,6 +11,14 @@ import {import { useTranslation } from "react-i18next";import { Button } from "@/components/ui/button";+import {+ Command,+ CommandEmpty,+ CommandGroup,+ CommandInput,+ CommandItem,+ CommandList,+} from "@/components/ui/command";import {Popover,PopoverContent,@@ -44,6 +52,10 @@ import type {const sourceName = (sources: Source[], sourceId: string): string =>sources.find((source) => source.id === sourceId)?.display_name ?? sourceId;+/** Stable list-item identity for one candidate pair. Nothing parses it back. */+const candidateKey = (hop: RouteHop): string =>+ JSON.stringify([hop.source_id, hop.model_id]);+type GuardState = {hops: RouteHopRef[];gaps: NonNullable<GuardConfirmation["would_interrupt"]>;@@ -135,6 +147,7 @@ export const RouteChainDialog: React.FC<{React.useState<UnknownObservation>("none");const [unknownSourceCurrent, setUnknownSourceCurrent] = React.useState(false);const [selectorOpen, setSelectorOpen] = React.useState(false);+ const [query, setQuery] = React.useState("");const [candidate, setCandidate] = React.useState<RouteCandidate | null>(null);const [announcement, setAnnouncement] = React.useState<{key: string;@@ -142,7 +155,7 @@ export const RouteChainDialog: React.FC<{} | null>(null);const gripRefs = React.useRef<Array<HTMLButtonElement | null>>([]);const removeRefs = React.useRef<Array<HTMLButtonElement | null>>([]);- const candidateRefs = React.useRef<Array<HTMLButtonElement | null>>([]);+ const searchRef = React.useRef<HTMLInputElement | null>(null);const addButtonRef = React.useRef<HTMLButtonElement | null>(null);const reseedButtonRef = React.useRef<HTMLButtonElement | null>(null);const cancelButtonRef = React.useRef<HTMLButtonElement | null>(null);@@ -170,20 +183,28 @@ export const RouteChainDialog: React.FC<{[],);const candidates = agent ? routeCandidates(agent, sources, draft) : [];- const candidateGroups = candidates.reduce<- Array<{- source: Source;- items: Array<{ candidate: RouteCandidate; index: number }>;- }>- >((groups, item, index) => {+ // The filter narrows the same grouped projection V5 exposes, so an empty+ // result means "nothing matches what you typed", never "nothing is available"+ // — that second sentence stays `route.add.none` on the disabled trigger.+ const term = query.trim().toLowerCase();+ const matched = term+ ? candidates.filter((item) =>+ `${item.source.display_name}\n${item.hop.model_id}`+ .toLowerCase()+ .includes(term),+ )+ : candidates;+ const candidateGroups = matched.reduce<+ Array<{ source: Source; items: RouteCandidate[] }>+ >((groups, item) => {const previous = groups.at(-1);- if (previous?.source.id === item.source.id) {- previous.items.push({ candidate: item, index });- } else {- groups.push({ source: item.source, items: [{ candidate: item, index }] });- }+ if (previous?.source.id === item.source.id) previous.items.push(item);+ else groups.push({ source: item.source, items: [item] });return groups;}, []);+ const matchedRef = React.useRef(matched);+ matchedRef.current = matched;+ const matchedKeys = matched.map((item) => candidateKey(item.hop)).join("\n");const backend = agent? (t(`settings.models.backends.${agent.backend}`, {defaultValue: agent.backend,@@ -244,6 +265,7 @@ export const RouteChainDialog: React.FC<{setUnknownObservation("none");setUnknownSourceCurrent(false);setSelectorOpen(false);+ setQuery("");setCandidate(null);advanceInteraction({ type: "reset", draft: [], focusIndex: 0 });if (selection) void readChain();@@ -262,9 +284,18 @@ export const RouteChainDialog: React.FC<{onClose();}, [onClose, phase, selection]);+ // ET-5a plus its invariant: while the selector is open exactly one candidate is+ // active, and it is always one of the candidates currently listed. Filtering or+ // a draft change that drops the active pair re-elects the first listed one+ // rather than leaving the confirmation pointing at a row nobody can see.React.useEffect(() => {- if (selectorOpen) candidateRefs.current[0]?.focus();- }, [selectorOpen]);+ if (!selectorOpen) return;+ setCandidate((current) => {+ const keys = matchedKeys ? matchedKeys.split("\n") : [];+ if (current && keys.includes(candidateKey(current.hop))) return current;+ return matchedRef.current[0] ?? null;+ });+ }, [matchedKeys, selectorOpen]);React.useEffect(() => {const signature = valid.invalidIndexes.join(",");@@ -277,6 +308,7 @@ export const RouteChainDialog: React.FC<{invalidSignature.current = signature;if (phase === "rejected") setPhase("ready");setSelectorOpen(false);+ setQuery("");setCandidate(null);advanceInteraction({ type: "drop-grab" });focusAfterRender({@@ -639,44 +671,22 @@ export const RouteChainDialog: React.FC<{doneButtonRef.current?.focus();commitReconciliation.retry();};- const chooseCandidate = (next: RouteCandidate) => {- setCandidate(next);- };- const moveCandidateFocus = (index: number) => {- const nextIndex = Math.max(0, Math.min(candidates.length - 1, index));- const next = candidates[nextIndex];- if (!next) return;- setCandidate(next);- candidateRefs.current[nextIndex]?.focus();+ // Every ET-5d move — arrow keys, Home/End, pointer activation — arrives here as+ // the list's single active key, so activeness and selection cannot diverge.+ const chooseCandidate = (next: string) => {+ setCandidate(+ matchedRef.current.find((item) => candidateKey(item.hop) === next) ?? null,+ );};- const onCandidateKeyDown = (- event: React.KeyboardEvent<HTMLButtonElement>,- index: number,- ) => {- if (event.key === "ArrowDown" || event.key === "ArrowRight") {- event.preventDefault();- moveCandidateFocus(index + 1);- } else if (event.key === "ArrowUp" || event.key === "ArrowLeft") {- event.preventDefault();- moveCandidateFocus(index - 1);- } else if (event.key === "Home") {- event.preventDefault();- moveCandidateFocus(0);- } else if (event.key === "End") {- event.preventDefault();- moveCandidateFocus(candidates.length - 1);- } else if (event.key === "Escape") {- event.preventDefault();- setSelectorOpen(false);- setCandidate(null);- focusAfterSelectorClose();- }+ const closeSelector = () => {+ setSelectorOpen(false);+ setQuery("");+ setCandidate(null);};const addCandidate = () => {if (!candidate) return;const next = advanceInteraction({ type: "append", hop: candidate.hop });- setSelectorOpen(false);- setCandidate(null);+ closeSelector();requestAnimationFrame(() => gripRefs.current[next.focusIndex]?.focus());};const renderHop = (hop: RouteHop, index: number) => {@@ -961,12 +971,20 @@ export const RouteChainDialog: React.FC<{{t("settings.models.routeDialog.empty")}</div>)}+ {/* `modal` is what makes the panel scrollable: the Dialog's overlay owns a+ `react-remove-scroll` lock whose shards cover the dialog only, so a+ body-portalled non-modal popover has its wheel events cancelled. A+ modal popover pushes its own lock, which the dialog's defers to. */}<Popover+ modalopen={selectorOpen}onOpenChange={(open) => {- setSelectorOpen(open);- setCandidate(open ? (candidates[0] ?? null) : null);- if (!open) focusAfterSelectorClose();+ if (open) {+ setSelectorOpen(true);+ return;+ }+ closeSelector();+ focusAfterSelectorClose();}}><PopoverTrigger asChild>@@ -985,71 +1003,100 @@ export const RouteChainDialog: React.FC<{{t("settings.models.routeDialog.addHop")}</button></PopoverTrigger>- {/* `collisionPadding` plus the class's available-height bound keep the- whole panel — not just its list — inside the viewport; without- them a source with many models opened a panel that ran past the- dialog and clipped its own last row. */}+ {/* Placement is deterministic and the height adapts, rather than the+ other way round. Two variants were measured and rejected: bounding+ collisions to the dialog gives a 131px panel over an 18px list,+ because an empty chain — the case where this picker matters most —+ makes the dialog short; letting it flip gives a full 300px panel+ that jumps 150px above the dialog's own top, covering the page+ title, since the room below happens to fall a few px short of the+ 300px preference. Dropping down always and taking `min(300px,+ available-height)` keeps the panel attached to its trigger and on+ screen. It stays scrollable when a long chain leaves little room+ below; the dialog body scrolls, so the trigger can be moved up. */}<PopoverContent+ side="bottom"+ avoidCollisions={false}align="start"sideOffset={6}collisionPadding={16}- className="model-hub-route-selector flex w-[var(--radix-popover-trigger-width)] max-w-[calc(100vw-64px)] flex-col gap-2 rounded-lg border border-border bg-background p-2"+ className="model-hub-route-selector flex w-[var(--radix-popover-trigger-width)] max-w-[calc(100vw-64px)] flex-col p-0"onOpenAutoFocus={(event) => {event.preventDefault();- candidateRefs.current[0]?.focus();+ searchRef.current?.focus();}}onCloseAutoFocus={(event) => {event.preventDefault();addButtonRef.current?.focus();}}>- <div className="model-hub-route-selector-list flex flex-col gap-2">- {candidateGroups.map((group) => (- <section- key={group.source.id}- aria-label={group.source.display_name}- className="flex flex-col gap-1"- >- <p className="model-hub-route-selector-label truncate px-2">- {group.source.display_name}- </p>- {group.items.map(({ candidate: item, index }) => (- <button- ref={(node) => {- candidateRefs.current[index] = node;- }}- key={`${item.hop.source_id}:${item.hop.model_id}`}- type="button"- aria-pressed={Boolean(- candidate &&- equalHopIdentity(candidate.hop, item.hop),- )}- tabIndex={- candidate &&- equalHopIdentity(candidate.hop, item.hop)- ? 0- : -1- }- onClick={() => chooseCandidate(item)}- onKeyDown={(event) => onCandidateKeyDown(event, index)}- className="model-hub-route-candidate flex items-center rounded-md px-2 py-1 text-left text-xs text-foreground"- >- <span className="model-hub-route-candidate-model truncate font-mono text-muted">- {item.hop.model_id}- </span>- </button>- ))}- </section>- ))}- </div>- <Button- type="button"- className="model-hub-route-selector-confirm shrink-0 self-end px-4"- disabled={!candidate}- onClick={addCandidate}+ <Command+ shouldFilter={false}+ disablePointerSelection+ label={t("settings.models.routeDialog.addHop") as string}+ value={candidate ? candidateKey(candidate.hop) : ""}+ onValueChange={chooseCandidate}+ className="model-hub-route-selector-command min-h-0 bg-transparent">- {t("settings.models.routeDialog.add.confirm")}- </Button>+ <CommandInput+ ref={searchRef}+ value={query}+ onValueChange={setQuery}+ placeholder={+ t("settings.models.routeDialog.add.search") as string+ }+ />+ <p+ className="model-hub-route-selector-head model-hub-route-selector-row"+ aria-hidden="true"+ >+ <span>{t("settings.models.routeDialog.add.source")}</span>+ <span>{t("settings.models.routeDialog.add.model")}</span>+ </p>+ <CommandList className="model-hub-route-selector-list">+ {matched.length === 0 && (+ <CommandEmpty>+ {t("settings.models.routeDialog.add.noMatch")}+ </CommandEmpty>+ )}+ {candidateGroups.map((group) => (+ <CommandGroup+ key={group.source.id}+ heading={group.source.display_name}+ className="model-hub-route-selector-group [&_[cmdk-group-heading]]:sr-only"+ >+ {group.items.map((item, itemIndex) => (+ <CommandItem+ key={candidateKey(item.hop)}+ value={candidateKey(item.hop)}+ onSelect={() => setCandidate(item)}+ className="model-hub-route-candidate model-hub-route-selector-row text-foreground"+ >+ {/* The frame prints the source once per group and leaves+ the rest of the column blank; the group's own heading+ carries it for assistive tech. */}+ <span className="model-hub-route-candidate-source truncate">+ {itemIndex === 0 ? group.source.display_name : ""}+ </span>+ <span className="model-hub-route-candidate-model truncate font-mono">+ {item.hop.model_id}+ </span>+ </CommandItem>+ ))}+ </CommandGroup>+ ))}+ </CommandList>+ <div className="model-hub-route-selector-foot flex shrink-0 items-center justify-end border-t border-border">+ <Button+ type="button"+ className="model-hub-route-selector-confirm px-4"+ disabled={!candidate}+ onClick={addCandidate}+ >+ {t("settings.models.routeDialog.add.confirm")}+ </Button>+ </div>+ </Command></PopoverContent></Popover></div>diff --git a/ui/src/components/settings/models/SettingsModelsPage.tsx b/ui/src/components/settings/models/SettingsModelsPage.tsxindex a38b6dac9..ad2fd0b3a 100644--- a/ui/src/components/settings/models/SettingsModelsPage.tsx+++ b/ui/src/components/settings/models/SettingsModelsPage.tsx@@ -226,7 +226,7 @@ const HubTabs: React.FC<{ tab: 'sources' | 'usage'; onChange: (tab: 'sources' |return (<div role="tablist" className="flex h-[39px] items-end gap-1 border-b border-border">{(['sources', 'usage'] as const).map((id) => (- <button key={id} type="button" role="tab" aria-selected={tab === id} onClick={() => onChange(id)} className={cn('flex h-[39px] items-center gap-[7px] border-b-2 px-3.5 text-[13px] transition-colors', tab === id ? 'border-mint font-semibold text-foreground' : 'border-transparent font-normal text-muted hover:text-foreground')}>+ <button key={id} type="button" role="tab" aria-selected={tab === id} onClick={() => onChange(id)} className={cn('flex h-[41px] items-center gap-[7px] border-b-2 px-3.5 text-[13px] transition-colors', tab === id ? 'border-mint font-semibold text-foreground' : 'border-transparent font-normal text-muted hover:text-foreground')}>{id === 'sources' ? <Route className="size-3.5" /> : <Gauge className="size-3.5" />}{t(`settings.models.shell.tab.${id === 'sources' ? 'hub' : 'usage'}`)}</button>@@ -256,7 +256,7 @@ const DirectHome: React.FC<{ agents: AgentSupply[]; onSwitch: (agent: AgentSuppl<span className="model-hub-direct-backend-copy"><span className="flex min-w-0 items-center gap-1.5"><span className="model-hub-direct-backend-name truncate text-foreground">{t(`settings.models.backends.${agent.backend}`, { defaultValue: agent.backend })}</span>- <span className="model-hub-direct-kind-pill shrink-0 rounded-full border px-2 py-[3px] text-[10.5px] font-semibold">{t('settings.models.direct.pill.direct')}</span>+ <span className="model-hub-pill model-hub-direct-kind-pill border">{t('settings.models.direct.pill.direct')}</span></span><span className="model-hub-direct-backend-detail truncate" title={t(`settings.models.direct.backend.${agent.backend}.detail`) as string}>{t(`settings.models.direct.backend.${agent.backend}.detail`)}</span></span>diff --git a/ui/src/components/settings/models/SourceDetailPanel.test.tsx b/ui/src/components/settings/models/SourceDetailPanel.test.tsxindex 0ace43a35..5f7f9f026 100644--- a/ui/src/components/settings/models/SourceDetailPanel.test.tsx+++ b/ui/src/components/settings/models/SourceDetailPanel.test.tsx@@ -1178,7 +1178,12 @@ describe('SourceDetailPanel', () => {}expect(reached).toEqual(new Set(Object.keys(REPAIR_LABEL_KEY) as RepairKind[]));- });+ // Explicit budget rather than the 5s default: this test's cost is the enum+ // product, so it grows whenever a status, cause, kind, or channel is added —+ // exactly the growth that makes it valuable. ~0.9s alone, but it runs beside+ // 67 other files, and a scheduling-noise failure here reads as a real defect.+ // Still bounded well below a hung render.+ }, 15_000);it('opens key replacement from the revoked hub credential repair tap', async () => {render(diff --git a/ui/src/components/settings/models/SourceDetailPanel.tsx b/ui/src/components/settings/models/SourceDetailPanel.tsxindex 056f477d0..1cdb590dc 100644--- a/ui/src/components/settings/models/SourceDetailPanel.tsx+++ b/ui/src/components/settings/models/SourceDetailPanel.tsx@@ -62,7 +62,7 @@ const ManualModelMenu: React.FC<{onOpenChange={setOpen}sheetTitle={model.id}className="w-40"- trigger={<button type="button" disabled={busy} aria-label={label} title={label} className="grid size-8 place-items-center rounded-md text-muted hover:bg-surface-2 hover:text-foreground"><MoreHorizontal className="size-4" /></button>}+ trigger={<button type="button" disabled={busy} aria-label={label} title={label} className="model-hub-source-more grid place-items-center text-muted hover:bg-surface-2 hover:text-foreground"><MoreHorizontal className="size-4" /></button>}><button type="button" role="menuitem" className="flex w-full items-center rounded-md px-2.5 py-2 text-left text-[12px] font-semibold text-destructive-ink hover:bg-destructive/[0.08]" onClick={() => { setOpen(false); onRemove(); }}>{t('settings.models.sourceDetail.row.remove')}</button></ResponsiveMenu>@@ -89,7 +89,7 @@ const SourceManageMenu: React.FC<{onOpenChange={setOpen}sheetTitle={source.display_name}className="w-44"- trigger={<button type="button" disabled={busy} aria-label={label} title={label} className="grid size-8 place-items-center rounded-md text-muted hover:bg-surface-2 hover:text-foreground"><MoreHorizontal className="size-4" /></button>}+ trigger={<button type="button" disabled={busy} aria-label={label} title={label} className="model-hub-source-more grid place-items-center text-muted hover:bg-surface-2 hover:text-foreground"><MoreHorizontal className="size-4" /></button>}>{manageActions().map((kind) => (<button@@ -764,7 +764,7 @@ export const SourceDetailPanel: React.FC<{— the design omits it entirely, but a subscription source has nohost to fall back on and would be unidentifiable without it. */}<div className="model-hub-source-copy flex min-w-0 flex-1 flex-col">- <div className={cn('model-hub-source-line flex min-w-0 flex-wrap items-center gap-x-2', state.textClass)}>+ <div className={cn('model-hub-source-line flex min-w-0 flex-wrap items-center gap-x-[7px]', state.textClass)}><h2 ref={headingRef} tabIndex={-1} className="model-hub-source-title truncate font-bold text-foreground">{source.display_name}</h2>{state.key && <span className="model-hub-source-state flex items-center gap-1.5"><span className={cn('size-[5px] shrink-0 rounded-full', state.dotClass)} />{t(state.key, state.values)}</span>}{source.last_discovered_at && <span className="model-hub-source-age text-muted">{t('settings.models.sourceDetail.status.listUpdated', { time: formatRelativeTime(source.last_discovered_at, t) })}</span>}@@ -775,7 +775,7 @@ export const SourceDetailPanel: React.FC<{{repairDestination === 'reauth_dialog' && <Button size="sm" className="model-hub-source-action" data-repair-kind={repair} data-repair-destination={repairDestination} disabled={busy} onClick={() => setConfirmingReauth(true)}><LogIn />{t(REPAIR_LABEL_KEY.reauth)}</Button>}{repairDestination === 'replace_key_dialog' && <Button size="sm" className="model-hub-source-action" data-repair-kind={repair} data-repair-destination={repairDestination} disabled={busy} onClick={() => setReplacingKey(true)}>{t(REPAIR_LABEL_KEY.replace_key)}</Button>}{source.supply_channel === 'hub' && <Button variant="outline" size="sm" className="model-hub-source-action" data-repair-kind={repairDestination === 'refetch_button' ? repair : undefined} data-repair-destination={repairDestination === 'refetch_button' ? repairDestination : undefined} disabled={busy} onClick={() => void refetch()}>{busy ? <Loader2 className="animate-spin" /> : <RefreshCw />}{t('settings.models.sourceDetail.action.refetch')}</Button>}- {source.kind === 'api_key' && <Button variant="secondary" size="sm" className="model-hub-source-action model-hub-ink-mint" disabled={busy || manualDraft !== null} onClick={() => setManualDraft({ modelId: '', tiers: [], failed: false, retryRead: false })}><Plus />{t('settings.models.sourceDetail.action.addModel')}</Button>}+ {source.kind === 'api_key' && <Button size="sm" className="model-hub-source-action" disabled={busy || manualDraft !== null} onClick={() => setManualDraft({ modelId: '', tiers: [], failed: false, retryRead: false })}><Plus />{t('settings.models.sourceDetail.action.addModel')}</Button>}<SourceManageMenu source={source} busy={busy || manageStage.kind !== 'idle'} onEdit={beginEdit} onDelete={beginDelete} /></div></section>@@ -831,7 +831,7 @@ export const SourceDetailPanel: React.FC<{</button>)}</section>- <p className="model-hub-source-footnote flex gap-2 leading-relaxed">+ <p className="model-hub-source-footnote flex gap-2"><Info className="model-hub-ink-59 mt-px size-[13px] shrink-0" aria-hidden="true" /><span>{t('settings.models.sourceDetail.footnote')}</span></p>diff --git a/ui/src/components/settings/models/SourceRow.tsx b/ui/src/components/settings/models/SourceRow.tsxindex 8b9b0894e..c0e20e1d7 100644--- a/ui/src/components/settings/models/SourceRow.tsx+++ b/ui/src/components/settings/models/SourceRow.tsx@@ -43,12 +43,12 @@ export const SourceRow: React.FC<{ source: Source; onOpen: (source: Source) => v</span><span className="min-w-0 flex-1"><span className="flex min-w-0 items-center gap-1.5">- <span className="truncate text-[12.5px] font-bold text-foreground" title={source.display_name}>{source.display_name}</span>- <span className={cn('shrink-0 rounded-full border px-2 py-[3px] text-[10.5px] font-semibold', ACCENT_PILL[accent])}>+ <span className="truncate text-[12.5px] font-bold leading-[18px] text-foreground" title={source.display_name}>{source.display_name}</span>+ <span className={cn('model-hub-pill border', ACCENT_PILL[accent])}>{t(`settings.models.upstream.kind.${kindKey}`)}</span></span>- {detail && <span className="model-hub-upstream-detail mt-1 block truncate font-mono text-[10.5px]" title={detail}>{detail}</span>}+ {detail && <span className="model-hub-upstream-detail mt-1 block truncate font-mono text-[10.5px] leading-[14px]" title={detail}>{detail}</span>}{state.key && <span className={cn('mt-1 flex items-center gap-[5px] text-[10.5px] font-semibold', state.textClass)}><span className={cn('size-[5px] rounded-full', state.dotClass)} />{t(state.key, state.values)}diff --git a/ui/src/components/settings/models/SourcesCard.tsx b/ui/src/components/settings/models/SourcesCard.tsxindex a0ee6cd89..e53c31798 100644--- a/ui/src/components/settings/models/SourcesCard.tsx+++ b/ui/src/components/settings/models/SourcesCard.tsx@@ -29,18 +29,22 @@ export const SourcesCard: React.FC<{{ id: 'native', sources: (sources ?? []).filter((source) => source.supply_channel === 'native_cli') },{ id: 'hub', sources: (sources ?? []).filter((source) => source.supply_channel === 'hub') },].filter((group) => group.sources.length > 0);+ // No height floor: the frame sizes this panel to its cards, so a fixture with+ // fewer sources than the design draws should end below the footer rather than+ // leave ~100px of void above it. `max-h-full` still hands overflow to the+ // scroll region when there are more.return (- <section className="relative z-20 flex max-h-full min-h-[420px] flex-col self-start overflow-hidden rounded-[14px] border border-border bg-surface">+ <section className="relative z-20 flex max-h-full flex-col self-start overflow-hidden rounded-[14px] border border-border bg-surface"><div className="flex h-14 shrink-0 items-center justify-between border-b border-border px-3.5"><span className="flex items-center gap-[7px]">- <h2 className="text-[16px] font-bold text-foreground">{t('settings.models.upstream.heading')}</h2>+ <h2 className="text-[16px] font-bold leading-[23px] text-foreground">{t('settings.models.upstream.heading')}</h2><ModelHubInfoHintlabel={t('settings.models.shell.gatewayInfo.label')}content={t('settings.models.shell.gatewayInfo.body')}className="model-hub-upstream-info"/></span>- {sources !== undefined && <span className="model-hub-upstream-count rounded-full border px-2 py-[3px] text-[10.5px] font-semibold">{t('settings.models.upstream.count', { count: sources.length })}</span>}+ {sources !== undefined && <span className="model-hub-pill model-hub-upstream-count border">{t('settings.models.upstream.count', { count: sources.length })}</span>}</div><div className="min-h-0 flex-1 space-y-2.5 overflow-y-auto p-3">{read.kind === 'loading' && sources === undefined@@ -50,7 +54,7 @@ export const SourcesCard: React.FC<{: <>{read.kind === 'degraded' && read.cause === 'read_failed' && <div className="mb-2 flex items-center justify-between gap-3 rounded-lg border border-destructive/25 bg-destructive/[0.08] px-3 py-2"><p className="text-[11px] text-destructive-ink">{readFailureCopy ?? t('settings.models.upstream.unread')}</p><Button variant="outline" size="xs" onClick={onRetry}>{t('settings.models.upstream.retry')}</Button></div>}{groups.length > 0- ? groups.map((group) => <div key={group.id} className="space-y-2"><h3 className="model-hub-upstream-group-label flex h-[18px] items-center uppercase">{t(`settings.models.upstream.group.${group.id}`)}</h3>{group.sources.map((source) => <SourceRow key={source.id} source={source} onOpen={onOpenSource} />)}</div>)+ ? groups.map((group) => <div key={group.id} className="space-y-2.5"><h3 className="model-hub-upstream-group-label flex h-[18px] items-center uppercase">{t(`settings.models.upstream.group.${group.id}`)}</h3>{group.sources.map((source) => <SourceRow key={source.id} source={source} onOpen={onOpenSource} />)}</div>): <p className="px-3 py-10 text-center text-[12px] text-muted">{t('settings.models.upstream.empty')}</p>}</>}</div>@@ -61,7 +65,7 @@ export const SourcesCard: React.FC<{size="xs"aria-haspopup="menu"aria-expanded={subscriptionPickerOpen}- className="model-hub-footer-action shadow-none disabled:opacity-100"+ className="model-hub-footer-action model-hub-footer-action--filled shadow-none disabled:opacity-100"onClick={onAddSubscription}><Plus className="size-3" />@@ -70,7 +74,7 @@ export const SourcesCard: React.FC<{<Buttonvariant="outline"size="xs"- className="model-hub-footer-action"+ className="model-hub-footer-action model-hub-footer-action--outlined model-hub-fill-0a"onClick={onAddApiKey}><Plus className="size-3" />diff --git a/ui/src/components/settings/models/modelHubStylePolicy.test.ts b/ui/src/components/settings/models/modelHubStylePolicy.test.tsindex aa505aefa..60064650f 100644--- a/ui/src/components/settings/models/modelHubStylePolicy.test.ts+++ b/ui/src/components/settings/models/modelHubStylePolicy.test.ts@@ -69,6 +69,14 @@ describe('Model Hub visual token policy', () => {expect(body).toContain('overflow-y: auto');});+ // Containment only: that the picker cannot grow past the room the popover+ // reports, and that the overflow lands on the list rather than on the panel.+ // It deliberately says nothing about whether a wheel reaches that list — CSS+ // can declare a perfectly scrollable box whose wheel events are cancelled by+ // an ancestor's scroll lock, which is exactly the defect this file's earlier+ // version read as fixed. That property is an event outcome and is owned by+ // `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] ?? '';@@ -78,4 +86,29 @@ describe('Model Hub visual token policy', () => {expect(list).toContain('overflow-y: auto');expect(list).toContain('min-height: 0');});++ // The surface draws the same 10.5px status pill in six places (upstream count,+ // gateway port, model-count badge, source kind, model mode, direct kind). Each+ // used to carry its own copy of the utility bundle, which is how all six ended+ // up 1px taller than the frame at once. One class owns the box now; a seventh+ // pill written the old way fails here rather than costing a review round.+ //+ // A pill is a *padded* round box at that type size — which is what separates it+ // from the fixed-size round markers (the mint step numbers) that legitimately+ // share the type size without sharing the shape.+ it('gives the 10.5px status pill exactly one shape owner', () => {+ const pill = surfaceCss.match(/\.model-hub-pill\s*\{([^}]*)\}/)?.[1] ?? '';+ expect(pill).toContain('font-size: 10.5px');+ expect(pill).toMatch(/line-height:\s*\d/);++ const restated = productFiles(__dirname).flatMap((path) => (+ [...readFileSync(path, 'utf8').matchAll(/(['"`])((?:(?!\1)[\s\S])*)\1/g)]+ .filter((match) => /rounded-full/.test(match[2])+ && /text-\[10\.5px\]/.test(match[2])+ && /(?:^|\s)px-/.test(match[2]))+ .map((match) => `${path}:${match[2]}`)+ ));++ expect(restated).toEqual([]);+ });});diff --git a/ui/src/components/settings/models/modelHubSurface.css b/ui/src/components/settings/models/modelHubSurface.cssindex 5bdc0c5f3..409b085f0 100644--- a/ui/src/components/settings/models/modelHubSurface.css+++ b/ui/src/components/settings/models/modelHubSurface.css@@ -139,6 +139,25 @@.model-hub-accent-pill--violet { border-color: var(--model-hub-violet-4d); background: var(--model-hub-violet-1a); color: var(--violet-ink); }.model-hub-accent-pill--neutral { border-color: var(--model-hub-wash-14); background: var(--model-hub-wash-0a); color: var(--muted); }+/* One owner for the surface's 10.5px status pill. Every frame draws it as a 23px+ box: a 1px border plus 3px insets over a 15px line box. The line-height is the+ part that has to be pinned — inherited leading grows the same padding into a+ 25px box, which is what every pill on the page was doing. Colour stays at the+ call site (`.model-hub-accent-pill--*`, `.model-hub-upstream-count`,+ `.model-hub-takeover-chip`, Badge variants); this owns only the shape. */+.model-hub-pill {+ display: inline-flex;+ flex: none;+ align-items: center;+ border-radius: 999px;+ padding: 3px 8px;+ font-size: 10.5px;+ font-weight: 600;+ letter-spacing: 0;+ line-height: 15px;+ white-space: nowrap;+}+.model-hub-ink-mint { color: var(--mint-ink); }.model-hub-ink-gold { color: var(--gold-ink); }.model-hub-ink-violet { color: var(--violet-ink); }@@ -180,9 +199,12 @@line-height: normal;}+/* The glyph is the control: the frame draws a bare 13px hint icon beside the+ page title, exactly like the one in the 来源 panel head, with no 26px box+ around it pushing the title's baseline off-centre. */.model-hub-shell-info {- width: 26px;- height: 26px;+ width: 13px;+ height: 13px;color: var(--model-hub-ink-40);}@@ -270,7 +292,7 @@--model-hub-wire-active-width: 1.75px;--model-hub-wire-muted-width: 1px;--model-hub-wire-node: 7px;- --model-hub-footer-action-height: 31px;+ --model-hub-footer-action-height: 30px;--model-hub-footer-action-radius: 7px;--model-hub-footer-action-font-size: 11.5px;--model-hub-upstream-info-ink: var(--model-hub-ink-40);@@ -281,7 +303,7 @@--model-hub-model-current-ink: var(--model-hub-muted-cc);--model-hub-model-collapse-ink: var(--model-hub-ink-59);--model-hub-takeover-current-ink: var(--model-hub-violet-ink);- --model-hub-agent-head-action-height: 35px;+ --model-hub-agent-head-action-height: 36px;--model-hub-agent-head-action-leading: 17px;--model-hub-agent-head-status-height: 16px;display: flex;@@ -291,12 +313,12 @@.model-hub-overview-chevron,.model-hub-overview-info { color: var(--model-hub-ink-40); }-/* The agent group head is a fixed 66px band holding a 35px action row and a- 16px status row with a 7px gap: 58px of content leaves a symmetric 4px inset.- Both rows have to be pinned, because inherited line-height alone grows them to- 37px/17px and eats the top inset. */+/* The agent group head is a fixed 66px band holding a 36px action row and a+ 16px status row with a 7px gap; the frame's 59px of content is centred in it,+ so the inset is the half-pixel 3.5 rather than a round number. Both rows have+ to be pinned, because inherited line-height alone grows them past that. */.model-hub-agent-head-action {- height: var(--model-hub-agent-head-action-height, 35px);+ height: var(--model-hub-agent-head-action-height, 36px);padding-block: 0;line-height: var(--model-hub-agent-head-action-leading, 17px);}@@ -348,7 +370,13 @@padding-inline: 12px;border-radius: var(--model-hub-footer-action-radius);font-size: var(--model-hub-footer-action-font-size);+ font-weight: 600;}+/* Both footer buttons sit on one 30px band. The frame strokes the outlined one+ *outside* that band, so its border-box is the 2px taller of the two — which is+ why the design reads 88x30 next to 113x32 rather than two equal heights. */+.model-hub-footer-action--filled { border-width: 0; }+.model-hub-footer-action--outlined { height: calc(var(--model-hub-footer-action-height) + 2px); }.model-hub-subscription-menu-row--active,.model-hub-subscription-menu-row:hover,@@ -715,31 +743,71 @@.model-hub-route-grip[aria-grabbed="true"] { color: var(--mint-ink); }.model-hub-route-invalid,.model-hub-route-invalid-summary { color: var(--destructive-ink); font-size: 10px; line-height: 14px; }-.model-hub-route-selector-label { color: var(--model-hub-ink-73); font-size: 10.5px; font-weight: 700; }/* The picker opens from a button that sits near the bottom of an anchoreddialog, so it has to bound itself against the space Radix reports instead ofletting a long model list run past the dialog and off the screen. Its metricslive here rather than on `.model-hub-route-dialog` because the popover is- portalled out of the dialog and inherits nothing from it. */+ portalled out of the dialog and inherits nothing from it — including the+ dialog-action tokens the confirmation shares with 取消 / 保存.++ Bounding the panel is only half of it: the bound has to land on the list, so+ every fixed band (search, column head, confirm foot) stays out of the way and+ the remaining space is what scrolls. `min-height: 0` on each link of that+ 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 {--model-hub-route-selector-max: 300px;--model-hub-route-selector-confirm-height: 33px;--model-hub-route-selector-confirm-size: 12px;+ --model-hub-dialog-action-radius: 7px;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-list { min-height: 0; overflow-y: auto; }-.model-hub-route-candidate { min-height: 28px; }+.model-hub-route-selector-command { min-height: 0; flex: 1 1 auto; }+.model-hub-route-selector [cmdk-input-wrapper] {+ flex-shrink: 0;+ padding-inline: 10px;+ border-color: var(--model-hub-wash-14);+}+.model-hub-route-selector [cmdk-input] {+ height: 34px;+ padding-block: 0;+ font-size: 12px;+ line-height: 17px;+}+.model-hub-route-selector-row {+ display: grid;+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);+ align-items: center;+ gap: 10px;+}+.model-hub-route-selector-head {+ flex-shrink: 0;+ padding: 8px 12px 4px;+ color: var(--model-hub-ink-73);+ font-size: 10.5px;+ font-weight: 700;+ line-height: 14px;+}+.model-hub-route-selector-list { min-height: 0; 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); }.model-hub-route-candidate:hover { background: var(--model-hub-wash-0a); }-.model-hub-route-candidate[aria-pressed="true"] {+.model-hub-route-candidate[data-selected="true"] {background: var(--model-hub-mint-1a);color: var(--mint-ink);}-.model-hub-route-candidate[aria-pressed="true"] .model-hub-route-candidate-model { color: inherit; }+.model-hub-route-candidate[data-selected="true"] .model-hub-route-candidate-model { color: inherit; }+.model-hub-route-selector-foot {+ padding: 8px 10px;+ border-color: var(--model-hub-wash-14);+}.model-hub-route-selector-confirm {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);}.model-hub-route-remove { width: 26px; height: 26px; border-radius: 6px; color: var(--foreground); }@@ -765,8 +833,9 @@--model-hub-source-action-width: 95px;--model-hub-source-action-height: 33px;--model-hub-source-action-radius: 7px;+ --model-hub-source-action-size: 12px;--model-hub-source-table-head-height: 36px;- --model-hub-source-table-row-height: 54px;+ --model-hub-source-table-row-height: 55px;--model-hub-source-table-draft-height: 55px;--model-hub-source-table-add-height: 41px;--model-hub-source-table-columns: 250px 84px minmax(220px, 470px) 1fr;@@ -827,6 +896,16 @@width: var(--model-hub-source-action-width);height: var(--model-hub-source-action-height);border-radius: var(--model-hub-source-action-radius);+ font-size: var(--model-hub-source-action-size);+ font-weight: 600;+}+/* The bar's `···` is not a square: the frame gives it the action row's radius and+ a slightly wide, slightly short box so it reads as part of that row rather than+ as an icon button dropped beside it. */+.model-hub-source-more {+ width: 33px;+ height: 30px;+ border-radius: var(--model-hub-source-action-radius);}.model-hub-source-table { border-radius: var(--model-hub-source-radius); }.model-hub-source-table-head,@@ -846,7 +925,7 @@background: var(--model-hub-source-table-head-fill);color: var(--model-hub-source-label-ink);font-size: var(--model-hub-source-label-size);- line-height: 16px;+ line-height: 15px;}.model-hub-source-table-row {min-height: var(--model-hub-source-table-row-height);@@ -864,9 +943,9 @@color: var(--model-hub-source-summary-ink);font-size: var(--model-hub-source-tier-size);}-.model-hub-source-model { font-size: var(--model-hub-source-model-size); }+.model-hub-source-model { font-size: var(--model-hub-source-model-size); line-height: 16px; }.model-hub-source-manual-id { border-radius: var(--model-hub-source-manual-input-radius); }-.model-hub-source-pill { font-size: var(--model-hub-source-pill-size); }+.model-hub-source-pill { font-size: var(--model-hub-source-pill-size); line-height: 14px; }.model-hub-source-tier { font-size: var(--model-hub-source-tier-size); }.model-hub-source-tier-chip {background: var(--model-hub-source-chip-fill);@@ -896,9 +975,10 @@color: var(--foreground);}.model-hub-source-footnote {- min-height: 17px;+ min-height: 16px;color: var(--model-hub-source-footnote-ink);font-size: var(--model-hub-source-footnote-size);+ line-height: 16px;}.model-hub-guard-overlay { background: var(--model-hub-scrim); }diff --git a/ui/src/components/ui/anchored-selection-scroll.test.tsx b/ui/src/components/ui/anchored-selection-scroll.test.tsxnew file mode 100644index 000000000..233492e9a--- /dev/null+++ b/ui/src/components/ui/anchored-selection-scroll.test.tsx@@ -0,0 +1,106 @@+// @vitest-environment jsdom+import * as DialogPrimitive from "@radix-ui/react-dialog";+import { cleanup, render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import { Combobox } from "./combobox";++/**+ * An open modal Dialog locks page scrolling through `react-remove-scroll`, whose+ * document-level handler cancels every wheel event it does not recognise as+ * belonging to its own lock or one of its declared shards. The Dialog declares+ * only its own content as a shard, so an anchored selection surface portalled to+ * `document.body` — any Popover-based picker — falls outside both and loses its+ * wheel silently: the list keeps `overflow-y: auto` and a real `scrollHeight`,+ * `scrollTop` still moves when set programmatically, and only the user's wheel+ * does nothing. A CSS assertion therefore cannot see this defect at all; the+ * property has to be measured as an event outcome.+ *+ * The property: while a modal Dialog is open, the page stays locked and a+ * selection surface the Dialog opened still scrolls itself. Both halves are+ * asserted together, because the locked half is what keeps the scrollable half+ * from passing vacuously in a tree where no lock was ever installed.+ *+ * jsdom has no layout, so every element reports `scrollHeight === clientHeight`+ * and the lock legitimately cancels a wheel over a region that cannot scroll.+ * The list's scrollability is the browser's contribution to the scenario, so the+ * test states it explicitly instead of asserting through it — what is being+ * measured is which lock owns the event, not whether Tailwind emitted a class.+ */+const wheelPrevented = (node: Element): boolean => {+ const event = new WheelEvent("wheel", {+ bubbles: true,+ cancelable: true,+ deltaY: 240,+ });+ node.dispatchEvent(event);+ return event.defaultPrevented;+};++const declareScrollable = (node: HTMLElement) => {+ node.style.overflowY = "auto";+ Object.defineProperty(node, "scrollHeight", {+ value: 1000,+ configurable: true,+ });+ Object.defineProperty(node, "clientHeight", {+ value: 200,+ configurable: true,+ });+};++const outsideTheDialog = () => document.body.appendChild(document.createElement("div"));++beforeEach(() => {+ // cmdk observes its list box and scrolls the active row into view; jsdom+ // implements neither.+ vi.stubGlobal(+ "ResizeObserver",+ class {+ observe() {}+ unobserve() {}+ disconnect() {}+ },+ );+ Element.prototype.scrollIntoView = vi.fn();+});++afterEach(() => {+ cleanup();+ vi.restoreAllMocks();+ vi.unstubAllGlobals();+});++describe("anchored selection surfaces inside a modal Dialog", () => {+ it("keeps the page locked while the surface itself still scrolls", async () => {+ const outside = outsideTheDialog();+ render(+ <DialogPrimitive.Root open>+ <DialogPrimitive.Portal>+ <DialogPrimitive.Overlay />+ <DialogPrimitive.Content aria-label="host dialog">+ <Combobox+ options={[+ { value: "a", label: "first" },+ { value: "b", label: "second" },+ ]}+ value=""+ onValueChange={vi.fn()}+ placeholder="pick one"+ />+ </DialogPrimitive.Content>+ </DialogPrimitive.Portal>+ </DialogPrimitive.Root>,+ );++ await userEvent.click(screen.getByRole("combobox"));+ const option = await screen.findByText("first");+ const list = document.querySelector<HTMLElement>("[cmdk-list]");+ expect(list).not.toBeNull();+ declareScrollable(list as HTMLElement);++ expect(wheelPrevented(option)).toBe(false);+ expect(wheelPrevented(outside)).toBe(true);+ });+});diff --git a/ui/src/components/ui/combobox.tsx b/ui/src/components/ui/combobox.tsxindex 0976ce057..51d487cb0 100644--- a/ui/src/components/ui/combobox.tsx+++ b/ui/src/components/ui/combobox.tsx@@ -105,7 +105,12 @@ export function Combobox({)return (+ // `modal` unconditionally, matching Radix `Select`: a non-modal popover opened+ // inside a Dialog has its wheel events cancelled by the Dialog's scroll lock,+ // so the option list silently stops scrolling. Owning its own lock is a+ // property of the surface, not something each call site should have to know.<Popover+ modalopen={open}onOpenChange={(next) => {// Only opt-in consumers (commitOnClose) commit a typed custom value ondiff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 49b7fa7bd..95630b634 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -1016,7 +1016,14 @@"section": "Route chain for this model","removeHop": "Remove hop","addHop": "Add a hop",- "add": { "confirm": "Add", "none": "No source/model pair is available to add" },+ "add": {+ "source": "Source",+ "model": "Model",+ "search": "Search sources or models",+ "confirm": "Add",+ "noMatch": "No source or model matches that",+ "none": "No source/model pair is available to add"+ },"sourceMissing": "Source missing","invalidAfterRefresh": "This edited hop is unavailable after the refresh. Remove it before saving.","reorder": {diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 1d6b551bd..184219582 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -1016,7 +1016,14 @@"section": "这个型号的路由链","removeHop": "移除这一跳","addHop": "添加一跳",- "add": { "confirm": "添加", "none": "没有可添加的来源型号" },+ "add": {+ "source": "来源",+ "model": "型号",+ "search": "搜索来源或型号",+ "confirm": "添加",+ "noMatch": "没有匹配的来源型号",+ "none": "没有可添加的来源型号"+ },"sourceMissing": "来源不存在","invalidAfterRefresh": "这个已编辑的跳在刷新后的来源中不可用。移除它后再保存。","reorder": {