Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(model-hub): contain default route text and test inherited gaps (#1915)
Call White5a49973ec416
diff --git a/docs/plans/model-hub-e2e-test-plan.md b/docs/plans/model-hub-e2e-test-plan.mdindex 95027eddf..b9bdeee10 100644--- a/docs/plans/model-hub-e2e-test-plan.md+++ b/docs/plans/model-hub-e2e-test-plan.md@@ -49,7 +49,7 @@ Out of scope (documented, not dropped silently):| B4 | discovery fails | 422 `inventory_unavailable` unless `accept_unavailable_inventory:true`; then source commits with `state.status=error` | assert || B5 | replay create with same `client_nonce` | idempotent, no duplicate source | assert || B6 | replace key happy + rollback; rename; patch base URL | C22/C23 contracts | assert |-| B7 | delete source in a chain → guard 409 → echo plan → force | hop removed, impact report lists interrupted agents; malformed echo rejected | assert |+| B7 | sole owned default source + exact one-hop manual route, verified by reads → delete source → guard 409 → echo plan → force | actual inherited supply gap; impact report lists interrupted agents; malformed echo rejected; canonical route and exact captured default order restored independently (only the owned deleted ID may be omitted) | assert || B8 | force transport asymmetry (`?force=` vs body) | document current split (B6 issue); decide normalization | baseline || B9 | refetch after upstream inventory change | added/removed diff; **`discovered_at` preserved for pre-existing models** (currently overwritten — fix-first, see B-list) | fix-first || B10 | inspect catalog-managed tiers; edit user/null tiers; reload a v6 row and refresh | catalog edits return 409 `source_model_tiers_managed` with exact provenance; user tiers remain editable; refresh restores catalog truth and emits one redacted override event | assert |diff --git a/docs/plans/model-hub-routing-modes.md b/docs/plans/model-hub-routing-modes.mdindex c23e24158..aa418c0e7 100644--- a/docs/plans/model-hub-routing-modes.md+++ b/docs/plans/model-hub-routing-modes.md@@ -509,6 +509,61 @@ tests rather than disabling them. Cleanup compares canonical intent and must notrestore an obsolete empty-disable state. Existing failed live artifacts stayimmutable; the required browser flows and safety gates are not waived.+## Post-Merge Guard Acceptance Closure++The first complete v10 browser run passed all four visual flows but exposed an+old B7 fixture premise: deleting a one-hop manual route's source does not imply+a supply gap when its now-inherited default route still has eligible sources.+The actual no-interruption refusal and UI were consistent with the contract.++B7 must continue testing a genuine source-removal gap, refusal, exact confirmation+and impact report. Arrange the selected backend's default membership so the+owned source being deleted is its only eligible default, while retaining the+explicit one-hop manual route. Assert these preconditions through real reads.+Removing that source then leaves neither a nonempty override nor inherited+supply. Do not weaken the assertion to accept either gap/no-gap, fake an API+response, restore empty-disable semantics, or alter production guards.++Snapshot defaults before the arrangement and enter cleanup protection before+either write. Restore canonical original manual intent and original default+membership/order independently even after an ambiguous write or failed assertion.+Only the test-owned deleted source may be omitted from a captured default order;+an unrelated disappeared source is a cleanup failure, not permission to silently+filter arbitrary IDs. Preserve the existing case identity and four named baseline+gaps. Source deletion and its impact remain real browser actions. This is a+browser-fixture correction, with no product/API/version change.++## Default Drawer Text Containment++Root's complete v10 visual inspection found ordered source text painting over+the action group and the provider-priority explanation clipped outside the+mobile drawer. This is a text-column ownership defect, not permission to resize+the approved 26px controls or change route semantics. The previous action-only+scope is extended only for these demonstrated default-drawer text boundaries.++The shared source identity column stretches its children to its available width.+Ordered, held-out and missing-source reconciliation rows display complete source+identity and protocol/inventory text with normal wrapping and overflow-wrap for+long tokens. The existing 58px row height becomes its minimum; longer content+can increase the row height with tokenized padding. Do not rely on title-only+disclosure, crop strings, hide overflow on the entire row, or overlap controls.+The action group remains nonshrinking with its existing dimensions, focus,+disabled boundaries, pointer and keyboard behavior.++Provider-priority explanation reuses the existing held-out section explanation+owner: a bounded, normally wrapping line below its heading, with the same muted+type treatment. No new tooltip, unbounded chip or reduced text size is needed.+The current route dialog shell, global Button and persistence/guard policy are+outside this correction.++Consumption tests cover shared long-prefix/different-suffix identities and+ordered/held-out/reconciling states in both languages. Actual desktop/mobile,+light/dark browser acceptance must measure painted text containment relative to+the row and action group, not only the outer drawer or button-to-button overlap.+Screenshots must show the expected settled data before capture. Seven loading+images from the prior run are not evidence for their named persisted/default/+automatic states; the original result remains immutable.+## Delivery OwnershipOne feature PR is intentional: executable schema/type/mirror closure needs alldiff --git a/tests/test_memory_legacy_cleanup.py b/tests/test_memory_legacy_cleanup.pyindex d391fa967..df2ac803b 100644--- a/tests/test_memory_legacy_cleanup.py+++ b/tests/test_memory_legacy_cleanup.py@@ -2,13 +2,38 @@ from __future__ import annotationsimport jsonimport os+from dataclasses import replacefrom pathlib import Path+from unittest.mock import Mock, callimport pytestfrom core import memory_legacy_cleanup as cleanup[email protected](autouse=True)+def _forbid_host_process_access(monkeypatch: pytest.MonkeyPatch) -> None:+ def reject(*_args, **_kwargs):+ pytest.fail("Released Memory fixtures must not inspect or signal host processes")++ monkeypatch.setattr(cleanup.psutil, "Process", reject)+ monkeypatch.setattr(cleanup.psutil, "process_iter", reject)+ monkeypatch.setattr(cleanup.os, "kill", reject)+++def process_observations(monkeypatch: pytest.MonkeyPatch) -> tuple[Mock, Mock, Mock]:+ inspect = Mock(return_value=None)+ group_members = Mock(return_value=[])+ signal_and_wait = Mock()+ monkeypatch.setattr(cleanup, "_inspect", inspect)+ monkeypatch.setattr(cleanup, "_group_members", group_members)+ monkeypatch.setattr(cleanup, "_signal_and_wait", signal_and_wait)+ if hasattr(cleanup.os, "getpgrp"):+ monkeypatch.setattr(cleanup.os, "getpgrp", lambda: 1)+ return inspect, group_members, signal_and_wait++def _sidecar_record(home: Path) -> tuple[Path, dict[str, object]]:provider_root = home / "memory" / "everos-root"socket_path = home / "memory" / ".rt" / "everos.sock"@@ -86,7 +111,10 @@ def _sync_record(home: Path) -> Path:@pytest.mark.asyncio-async def test_core_reaper_retires_gone_released_sidecar(tmp_path: Path) -> None:+async def test_core_reaper_retires_gone_released_sidecar(+ tmp_path: Path,+ process_observations: tuple[Mock, Mock, Mock],+) -> None:home = tmp_path / "home"home.mkdir(mode=0o700)path, _record = _sidecar_record(home)@@ -97,11 +125,18 @@ async def test_core_reaper_retires_gone_released_sidecar(tmp_path: Path) -> Noneawait reaper.reconcile_orphans()+ inspect, group_members, signal_and_wait = process_observations+ inspect.assert_called_once_with(451)+ group_members.assert_not_called()+ signal_and_wait.assert_called_once_with([], reaper._timeout)assert not path.exists()@pytest.mark.asyncio-async def test_core_reaper_retires_gone_released_sync(tmp_path: Path) -> None:+async def test_core_reaper_retires_gone_released_sync(+ tmp_path: Path,+ process_observations: tuple[Mock, Mock, Mock],+) -> None:home = tmp_path / "home"home.mkdir(mode=0o700)path = _sync_record(home)@@ -112,9 +147,58 @@ async def test_core_reaper_retires_gone_released_sync(tmp_path: Path) -> None:await reaper.reconcile_orphans()+ inspect, group_members, signal_and_wait = process_observations+ assert inspect.call_args_list == [call(99999999), call(451)]+ assert group_members.call_args_list == [call(451), call(451)]+ signal_and_wait.assert_called_once_with([], reaper._timeout)assert not path.exists()[email protected]("owned", [True, False], ids=["owned-survivor", "foreign-member"])+async def test_core_reaper_preserves_sync_record_with_surviving_group_member(+ tmp_path: Path,+ process_observations: tuple[Mock, Mock, Mock],+ owned: bool,+) -> None:+ home = tmp_path / "home"+ home.mkdir(mode=0o700)+ path = _sync_record(home)+ original = path.read_bytes()+ member = replace(+ _identity(home),+ pid=452,+ process_group=451,+ environment={+ "EVEROS_ROOT": str(home / "memory" / "everos-root"),+ "AVIBE_MEMORY_CHILD_ROLE": "cascade_sync" if owned else "foreign",+ "AVIBE_MEMORY_SYNC_NONCE": "a" * 64,+ "AVIBE_MEMORY_SYNC_PARENT_PID": "99999999",+ "AVIBE_MEMORY_SYNC_PARENT_CREATE_TIME": float(8.25).hex(),+ "AVIBE_MEMORY_SYNC_PARENT_UID": str(os.getuid()) if hasattr(os, "getuid") else "",+ },+ )+ inspect, group_members, signal_and_wait = process_observations+ group_members.return_value = [member]+ reaper = cleanup.ReleasedEverOSOrphanReconciler(+ provider_root=home / "memory" / "everos-root",+ effective_home=home,+ )++ error = "process group did not exit" if owned else "identity is unavailable"+ with pytest.raises(RuntimeError, match=error):+ await reaper.reconcile_orphans()++ assert inspect.call_args_list == [call(99999999), call(451)]+ if owned:+ signal_and_wait.assert_called_once_with([member], reaper._timeout)+ assert group_members.call_args_list == [call(451), call(451)]+ else:+ signal_and_wait.assert_not_called()+ group_members.assert_called_once_with(451)+ assert path.read_bytes() == original++@pytest.mark.asyncioasync def test_core_reaper_signals_only_an_exact_released_identity(tmp_path: Path,diff --git a/ui/e2e/g-guards-copy.spec.ts b/ui/e2e/g-guards-copy.spec.tsindex bfa1f04d4..b002cb6c4 100644--- a/ui/e2e/g-guards-copy.spec.ts+++ b/ui/e2e/g-guards-copy.spec.ts@@ -32,23 +32,23 @@ test.describe('G · supply guards and failure copy', () => {`The precondition source ${source.display_name} came back with no models, so no route can reach it.`,).toBeDefined();- // Arrange the one state a guard exists for: this source is the ONLY hop of a- // configured route, so removing it leaves that model with no supply. The- // chain is captured first and put back in teardown — the instance's real- // routing is not this spec's to keep. Real routing is also all it captures:- // the source deleted below may already be a hop here, and restoring a hop- // this spec is about to delete is how the whole restore gets refused.+ // Pruning the last manual hop inherits defaults. Both authorities must+ // depend solely on this owned source for deletion to create a genuine gap.+ const originalDefaults = await api.defaultSourceOrder(gateway.backend);const original = await captureAgentChain(api, gateway);+ const failures: unknown[] = [];try {- // Entered BEFORE the arranged PUT, not after it succeeds: a response- // lost to a timeout or disconnect rejects that await with the chain- // already replaced server-side, and a finally outside it would leave- // the user's route swapped for the arrangement — then the fixture's- // source sweep empties it entirely.- const arranged = await api.putAgentChain(gateway.backend, gateway.model, [- { source_id: source.id, model_id: supplied! },- ]);+ // Protect both writes even when persistence succeeds but its response is lost.+ await api.setDefaultSourceOrder(gateway.backend, [source.id]);+ expect(await api.defaultSourceOrder(gateway.backend), 'B7 requires only the owned deletion source in defaults')+ .toEqual([source.id]);+ const hops = [{ source_id: source.id, model_id: supplied! }];+ const arranged = await api.putAgentChain(gateway.backend, gateway.model, hops);expect(arranged, 'The instance refused the arranged route, so no guard can be raised.').toBe(true);+ const readback = await api.agentChain(gateway.backend, gateway.model);+ expect(readback.manual_override, 'B7 requires the exact saved one-hop manual route').toEqual({ hops });+ expect(readback.chain.map(({ source_id, model_id }) => ({ source_id, model_id })),+ 'B7 requires the owned source to be the only effective manual hop').toEqual(hops);await hub.goto();await hub.openSource(source.id);@@ -95,12 +95,29 @@ test.describe('G · supply guards and failure copy', () => {await expect.poll(async () => (await api.sources()).some((s) => s.id === source.id), { timeout: 15_000 }).toBe(false);+ } catch (error) {+ failures.push(error);} finally {- // The delete that just ran means nothing downstream can put this chain- // back, so `restoreAgentChain`'s refusal-is-a-failure contract is the- // whole guarantee here.- await restoreAgentChain(api, gateway, original);+ try {+ await restoreAgentChain(api, gateway, original);+ } catch (error) {+ failures.push(error);+ }+ try {+ const remaining = new Set((await api.sources()).map((item) => item.id));+ expect(originalDefaults.filter((id) => id !== source.id && !remaining.has(id)),+ 'B7 cannot restore defaults while unrelated captured sources are missing').toEqual([]);+ // Only this exact owned deletion may change the captured membership.+ const expected = originalDefaults.filter((id) => id !== source.id || remaining.has(id));+ await api.setDefaultSourceOrder(gateway.backend, expected);+ expect(await api.defaultSourceOrder(gateway.backend), 'B7 must restore exact default membership and order')+ .toEqual(expected);+ } catch (error) {+ failures.push(error);+ }}+ if (failures.length === 1) throw failures[0];+ if (failures.length) throw new AggregateError(failures, 'B7 failed with independent restoration errors');});// G1 (fix-first) — "guard echo with a gap missing `agents` → no confirm-loop".diff --git a/ui/e2e/model-route-cleanup.spec.ts b/ui/e2e/model-route-cleanup.spec.tsindex 676897deb..8290f54c4 100644--- a/ui/e2e/model-route-cleanup.spec.ts+++ b/ui/e2e/model-route-cleanup.spec.ts@@ -1,10 +1,188 @@+import { readFileSync } from 'node:fs';+import vm from 'node:vm';import { expect, test, type APIRequestContext, type Page } from '@playwright/test';+import ts from 'typescript';import type { AgentChain, HubApi } from './support/api';import { HubApi as HubApiClient } from './support/api';import { ModelHubPage } from './support/hub';import { captureAgentChain, restoreAgentChain } from './support/restore';+const b7Title = 'B7 · removing the only source of a route is refused, explained, then reported';+const guardSource = ts.createSourceFile('g-guards-copy.spec.ts',+ readFileSync(new URL('./g-guards-copy.spec.ts', import.meta.url), 'utf8'), ts.ScriptTarget.Latest, true);+const b7Callbacks: ts.Expression[] = [];+function collectB7(node: ts.Node): void {+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'test'+ && node.arguments[0] && ts.isStringLiteral(node.arguments[0]) && node.arguments[0].text === b7Title) {+ b7Callbacks.push(node.arguments[1]);+ }+ ts.forEachChild(node, collectB7);+}+collectB7(guardSource);++type B7Options = {+ defaultWrite?: 'rejected' | 'ambiguous' | 'false-success';+ routeWrite?: 'rejected' | 'ambiguous' | 'false-success';+ effectiveMismatch?: boolean;+ original?: AgentChain['manual_override'];+ deleted?: boolean;+ missingOther?: boolean;+ restoreDefaultsFails?: boolean;+ restoreRouteFails?: boolean;+};++// Consume the actual B7 callback without registering its live fixtures. The+// deliberate page-entry failure exercises its real finally block, not a copy.+function b7Fixture(options: B7Options = {}) {+ expect(b7Callbacks).toHaveLength(1);+ const owned = 'src_owned_delete';+ const originalDefaults = ['src_operator_b', owned, 'src_operator_a', 'src_other_owned'];+ const original = options.original === undefined+ ? { hops: [{ source_id: 'src_operator_a', model_id: 'operator/retained' }] }+ : options.original;+ const arrangedHops = [{ source_id: owned, model_id: 'e2e-supplied' }];+ let defaults = [...originalDefaults];+ let manual = structuredClone(original);+ const remaining = new Set(originalDefaults);+ const calls: string[] = [];+ const defaultWrites: string[][] = [];+ const browserBoundary = new Error('B7 synthetic browser boundary');+ let browserEntries = 0;+ const api = {+ sources: async () => [...remaining].map((id) => ({ id })),+ defaultSourceOrder: async () => { calls.push('read defaults'); return [...defaults]; },+ setDefaultSourceOrder: async (_backend: string, order: string[]) => {+ defaultWrites.push([...order]);+ const arranging = defaultWrites.length === 1;+ calls.push(arranging ? 'arrange defaults' : 'restore defaults');+ if (arranging && options.defaultWrite === 'rejected') throw new Error('initial default write rejected');+ if (!arranging && options.restoreDefaultsFails) throw new Error('default restoration refused');+ if (!(arranging && options.defaultWrite === 'false-success')) defaults = [...order];+ if (arranging && options.defaultWrite === 'ambiguous') throw new Error('default response lost after persistence');+ },+ agentChain: async () => {+ calls.push('read route');+ return {+ manual_override: structuredClone(manual),+ chain: options.effectiveMismatch && manual?.hops[0]?.source_id === owned+ ? [{ source_id: 'src_operator_b', model_id: 'unexpected-fallback' }]+ : structuredClone(manual?.hops ?? []),+ };+ },+ putAgentChain: async (_backend: string, _model: string, hops: NonNullable<AgentChain['manual_override']>['hops']) => {+ const arranging = JSON.stringify(hops) === JSON.stringify(arrangedHops);+ calls.push(arranging ? 'arrange route' : 'restore route');+ if (arranging && options.routeWrite === 'rejected') return false;+ if (!arranging && options.restoreRouteFails) throw new Error('route restoration refused');+ if (!(arranging && options.routeWrite === 'false-success')) manual = { hops: structuredClone(hops) };+ if (arranging && options.routeWrite === 'ambiguous') throw new Error('route response lost after persistence');+ return true;+ },+ deleteAgentChain: async () => {+ calls.push('restore route');+ if (options.restoreRouteFails) throw new Error('route restoration refused');+ manual = null;+ return true;+ },+ } as unknown as HubApi;+ const callback = new vm.Script(ts.transpileModule(`(${b7Callbacks[0].getText(guardSource)})`, {+ compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.None },+ }).outputText).runInNewContext({ expect, captureAgentChain, restoreAgentChain, AggregateError }) as+ (fixtures: unknown) => Promise<void>;+ return {+ calls, defaultWrites, originalDefaults, original, browserBoundary,+ state: () => ({ defaults, manual, browserEntries }),+ run: async () => {+ try {+ await callback({+ api,+ gateway: { backend: 'claude', model: 'menu-model', sources: [+ { id: owned, display_name: 'e2e-owned-delete', models: [{ id: 'e2e-supplied' }] },+ ] },+ hub: { goto: async () => {+ browserEntries += 1;+ expect(defaults, 'Browser must start with an actual inherited supply gap').toEqual([owned]);+ expect(manual).toEqual({ hops: arrangedHops });+ if (options.deleted) remaining.delete(owned);+ if (options.missingOther) remaining.delete('src_operator_b');+ throw browserBoundary;+ } },+ });+ } catch (error) { return error; }+ throw new Error('The synthetic browser boundary must not complete');+ },+ };+}++test('B7 arranges a genuine inherited gap and restores exact independent authorities', async () => {+ const fixture = b7Fixture();+ expect(await fixture.run()).toBe(fixture.browserBoundary);+ expect(fixture.state()).toEqual({ defaults: fixture.originalDefaults, manual: fixture.original, browserEntries: 1 });+ expect(fixture.defaultWrites).toEqual([['src_owned_delete'], fixture.originalDefaults]);+ expect(fixture.calls.indexOf('read defaults')).toBeLessThan(fixture.calls.indexOf('arrange defaults'));+ expect(fixture.calls.indexOf('read route')).toBeLessThan(fixture.calls.indexOf('arrange defaults'));+});++for (const authority of ['default', 'route'] as const) {+ for (const response of ['rejected', 'ambiguous', 'false-success'] as const) {+ test(`B7 restores both snapshots after ${authority} ${response} arrangement`, async () => {+ const fixture = b7Fixture(authority === 'default' ? { defaultWrite: response } : { routeWrite: response });+ const failure = await fixture.run();+ expect(failure).toBeInstanceOf(Error);+ expect(failure).not.toBe(fixture.browserBoundary);+ expect(fixture.state()).toEqual({ defaults: fixture.originalDefaults, manual: fixture.original, browserEntries: 0 });+ expect(fixture.calls).toContain('restore defaults');+ expect(fixture.calls).toContain('restore route');+ });+ }+}++test('B7 rejects a no-gap effective readback before entering the browser', async () => {+ const fixture = b7Fixture({ effectiveMismatch: true });+ expect(await fixture.run()).not.toBe(fixture.browserBoundary);+ expect(fixture.state()).toEqual({ defaults: fixture.originalDefaults, manual: fixture.original, browserEntries: 0 });+});++for (const original of [null, { hops: [] }, { hops: [{ source_id: 'src_operator_a', model_id: 'dormant/retained' }] }]) {+ test(`B7 preserves canonical ${original === null ? 'absent' : original.hops.length ? 'nonempty dormant' : 'legacy empty'} intent after owned deletion`, async () => {+ const fixture = b7Fixture({ original, deleted: true });+ expect(await fixture.run()).toBe(fixture.browserBoundary);+ const expectedDefaults = ['src_operator_b', 'src_operator_a', 'src_other_owned'];+ expect(fixture.state()).toEqual({+ defaults: expectedDefaults, manual: original?.hops.length ? original : null, browserEntries: 1,+ });+ expect(fixture.defaultWrites).toEqual([['src_owned_delete'], expectedDefaults]);+ });+}++test('B7 refuses to filter an unrelated missing source and still restores the route', async () => {+ const fixture = b7Fixture({ deleted: true, missingOther: true });+ const failure = await fixture.run();+ expect(failure).toBeInstanceOf(AggregateError);+ expect((failure as AggregateError).errors[0]).toBe(fixture.browserBoundary);+ expect(String((failure as AggregateError).errors[1])).toContain('src_operator_b');+ expect(fixture.defaultWrites).toEqual([['src_owned_delete']]);+ expect(fixture.state().manual).toEqual(fixture.original);+ expect(fixture.calls).toContain('restore route');+});++for (const authority of ['route', 'defaults', 'both'] as const) {+ test(`B7 attempts independent restoration and retains primary failure when ${authority} cleanup fails`, async () => {+ const fixture = b7Fixture({+ restoreRouteFails: authority !== 'defaults', restoreDefaultsFails: authority !== 'route',+ });+ const failure = await fixture.run();+ expect(failure).toBeInstanceOf(AggregateError);+ expect((failure as AggregateError).errors[0]).toBe(fixture.browserBoundary);+ expect((failure as AggregateError).errors).toHaveLength(authority === 'both' ? 3 : 2);+ expect(fixture.calls).toContain('restore route');+ expect(fixture.calls).toContain('restore defaults');+ if (authority === 'route') expect(fixture.state().defaults).toEqual(fixture.originalDefaults);+ if (authority === 'defaults') expect(fixture.state().manual).toEqual(fixture.original);+ });+}+type CleanupReply = { status: number; body: unknown };const ownedSession = 'sess_owned';const ownedAgent = 'e2e-recorded-owned';diff --git a/ui/src/components/settings/models/SourceOrderDrawer.test.tsx b/ui/src/components/settings/models/SourceOrderDrawer.test.tsxindex ff9d9222d..26a469a19 100644--- a/ui/src/components/settings/models/SourceOrderDrawer.test.tsx+++ b/ui/src/components/settings/models/SourceOrderDrawer.test.tsx@@ -6,6 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { ToastProvider } from '@/context/ToastProvider';import i18n from '@/i18n';+import { PROTOCOL_COPY_KEYS } from './addApiKeyState';import { createSourceCollectionReadAuthority } from './collectionReadAuthority';import { ApiCallError, modelsApi } from './modelsApi';import { SourceOrderDrawer } from './SourceOrderDrawer';@@ -41,8 +42,8 @@ const agent: AgentSupply = {},};-const renderDrawer = (overrides: Partial<React.ComponentProps<typeof SourceOrderDrawer>> = {}) => render(- <I18nextProvider i18n={i18n}>+const renderDrawer = (overrides: Partial<React.ComponentProps<typeof SourceOrderDrawer>> = {}, locale = i18n) => render(+ <I18nextProvider i18n={locale}><ToastProvider><SourceOrderDraweropen@@ -69,6 +70,72 @@ beforeEach(() => {});describe('SourceOrderDrawer keyboard ordering', () => {+ const longSources = ['alpha', 'omega', 'held-out'].map((suffix, index) => ({+ ...source(`same-long-exact-source-identity-prefix-${suffix}`, `same-long-display-name-with-distinct-suffix-${suffix}`),+ protocol: 'openai_responses' as const,+ models: index === 0 ? [{ id: 'exact-model', origin: 'discovered' as const, reasoning_efforts: [], reasoning_efforts_source: null }] : [],+ }));+ const longAgent: AgentSupply = { ...agent, backend: 'codex', sources: {+ order: longSources.slice(0, 2).map((item) => item.id),+ eligibility: longSources.map((item) => ({ source_id: item.id, eligible: true })),+ } };+ const expectFullIdentity = (row: Element, name: string, detail?: string) => {+ const identity = row.querySelector('.model-hub-order-identity');+ expect(identity).not.toBeNull();+ expect(identity?.querySelector('.model-hub-order-name')?.textContent).toBe(name);+ if (detail) expect(identity?.querySelector('.model-hub-order-meta')?.textContent).toBe(detail);+ // Real drawer markup must use the shared wrapping owner, not title-only truncation.+ expect(identity?.querySelectorAll('.truncate, .line-clamp-1, .overflow-hidden')).toHaveLength(0);+ expect(identity?.querySelectorAll('[hidden], [aria-hidden="true"]')).toHaveLength(0);+ };++ it.each(['en', 'zh'] as const)('keeps full ordered and held-out identities with a shared next-line explanation in %s', async (lng) => {+ const locale = i18n.cloneInstance({ lng });+ vi.spyOn(modelsApi, 'getAgentSources').mockResolvedValue(longAgent);+ vi.mocked(modelsApi.listSources).mockResolvedValue(longSources);+ renderDrawer({ agent: longAgent, sources: longSources }, locale);+ await screen.findByRole('button', { name: locale.t('settings.models.order.action.include') });+ const rows = [...document.querySelectorAll('.model-hub-order-row')];+ expect(rows).toHaveLength(3);+ longSources.forEach((item, index) => {+ const inventory = item.models.length ? locale.t('settings.models.sources.modelCount', { count: item.models.length }) : locale.t('settings.models.routing.inventoryNotProvided');+ expectFullIdentity(rows[index], item.display_name, `${locale.t(PROTOCOL_COPY_KEYS[item.protocol])} · ${inventory}`);+ expect(rows[index].classList.contains(index < 2 ? 'model-hub-order-row--ordered' : 'model-hub-order-row--held')).toBe(true);+ expect(rows[index].querySelector('.model-hub-order-row-actions')).not.toBeNull();+ });+ for (const kind of ['ordered', 'heldOut']) {+ const note = screen.getByText(locale.t(`settings.models.order.section.${kind}.note`));+ expect(note.classList.contains('model-hub-order-section-explanation')).toBe(true);+ expect(note.parentElement?.classList.contains('model-hub-order-section-head')).toBe(true);+ expect(note.previousElementSibling?.tagName).toBe('H3');+ expect(note.hasAttribute('hidden')).toBe(false);+ }+ });++ it.each(['en', 'zh'] as const)('keeps known and missing source identities complete during reconciliation in %s', async (lng) => {+ const locale = i18n.cloneInstance({ lng });+ const regroupedAgent = deferred<AgentSupply>();+ const regroupedSources = deferred<Source[]>();+ const reads = vi.spyOn(modelsApi, 'getAgentSources').mockResolvedValueOnce(longAgent).mockReturnValueOnce(regroupedAgent.promise);+ vi.mocked(modelsApi.listSources).mockResolvedValueOnce([longSources[0]]).mockReturnValueOnce(regroupedSources.promise);+ renderDrawer({ agent: longAgent, sources: [longSources[0]] }, locale);+ await screen.findByText(longSources[1].id);+ const rows = [...document.querySelectorAll('.model-hub-order-row')];+ expect(rows).toHaveLength(2);+ expect(rows[0].closest('section')?.getAttribute('aria-busy')).toBe('true');+ expectFullIdentity(rows[0], longSources[0].display_name,+ `${locale.t(PROTOCOL_COPY_KEYS.openai_responses)} · ${locale.t('settings.models.sources.modelCount', { count: 1 })}`);+ expectFullIdentity(rows[1], longSources[1].id);+ expect(rows[1].querySelector('.model-hub-order-meta')).toBeNull();+ await act(async () => {+ regroupedAgent.resolve(longAgent);+ regroupedSources.resolve(longSources);+ });+ await screen.findByRole('button', { name: locale.t('settings.models.order.action.include') });+ expect(reads).toHaveBeenCalledTimes(2);+ expectFullIdentity(document.querySelectorAll('.model-hub-order-row')[1], longSources[1].display_name);+ });+it('uses the same compact action owner for ordered controls and held-out include without losing hints or boundaries', async () => {const available = [...sources, source('src_c', 'Manual only')];const codex: AgentSupply = { ...agent, backend: 'codex', sources: {diff --git a/ui/src/components/settings/models/SourceOrderDrawer.tsx b/ui/src/components/settings/models/SourceOrderDrawer.tsxindex 06c2a8b6c..5129c9c1b 100644--- a/ui/src/components/settings/models/SourceOrderDrawer.tsx+++ b/ui/src/components/settings/models/SourceOrderDrawer.tsx@@ -33,8 +33,8 @@ const SourceIdentity: React.FC<{ source: Source }> = ({ source }) => {return (<><span className="model-hub-order-identity">- <span className="model-hub-order-name truncate" title={source.display_name}>{source.display_name}</span>- {detail && <span className="model-hub-order-meta truncate" title={detail}>{detail}</span>}+ <span className="model-hub-order-name" title={source.display_name}>{source.display_name}</span>+ {detail && <span className="model-hub-order-meta" title={detail}>{detail}</span>}</span></>);@@ -341,7 +341,7 @@ export const SourceOrderDrawer: React.FC<{{orderedSource? <SourceIdentity source={orderedSource} />: <span className="model-hub-order-identity">- <span className="model-hub-order-name truncate font-mono" title={id}>{id}</span>+ <span className="model-hub-order-name font-mono" title={id}>{id}</span></span>}</div>))}@@ -359,7 +359,7 @@ export const SourceOrderDrawer: React.FC<{<section className="model-hub-order-section"><div className="model-hub-order-section-head"><h3>{t('settings.models.order.section.ordered')}</h3>- <span>{t('settings.models.order.section.ordered.note')}</span>+ <span className="model-hub-order-section-explanation">{t('settings.models.order.section.ordered.note')}</span></div>{ordered.length === 0? <div className="model-hub-order-empty">{t('settings.models.order.empty.ordered')}</div>@@ -388,7 +388,7 @@ export const SourceOrderDrawer: React.FC<{</Reorder.Group>}</section><section className="model-hub-order-section">- <div className="model-hub-order-section-head model-hub-order-section-head--held-out">+ <div className="model-hub-order-section-head"><h3>{t('settings.models.order.section.heldOut')}</h3><span className="model-hub-order-section-explanation">{t('settings.models.order.section.heldOut.note')}</span></div>diff --git a/ui/src/components/settings/models/modelHubStylePolicy.test.ts b/ui/src/components/settings/models/modelHubStylePolicy.test.tsindex 761ad4153..037c85080 100644--- a/ui/src/components/settings/models/modelHubStylePolicy.test.ts+++ b/ui/src/components/settings/models/modelHubStylePolicy.test.ts@@ -37,6 +37,42 @@ describe('Model Hub theme token policy', () => {});describe('Model Hub visual token policy', () => {+ it('contains full Default Routing text in stretched columns and growing rows', () => {+ const root = postcss.parse(surfaceCss);+ const declarations = (selector: string) => {+ const result: Record<string, string> = {};+ root.walkRules((rule) => {+ if (rule.parent?.type === 'root' && rule.selectors.includes(selector)) {+ rule.walkDecls((decl) => { result[decl.prop] = decl.value; });+ }+ });+ return result;+ };+ // Source-order checks of the actual shared owners, not JSDOM geometry.+ expect(declarations('.model-hub-order-identity')).toMatchObject({+ display: 'flex', flex: '1', 'min-width': '0', 'flex-direction': 'column', 'align-items': 'stretch',+ });+ for (const selector of ['.model-hub-order-name', '.model-hub-order-meta']) {+ expect(declarations(selector)).toMatchObject({ 'white-space': 'normal', 'overflow-wrap': 'anywhere' });+ }+ const row = declarations('.model-hub-order-row');+ expect(row).toMatchObject({+ height: 'auto', 'min-height': 'var(--model-hub-order-row-height)',+ '--model-hub-order-row-padding-y': '8px', 'padding-block': 'var(--model-hub-order-row-padding-y)',+ 'padding-inline': 'var(--model-hub-order-row-padding-x)',+ });+ expect(row.overflow ?? '').not.toMatch(/hidden|clip/);+ expect(surfaceCss).toContain('--model-hub-order-row-height: 58px;');+ expect(declarations('.model-hub-order-section-head')).toMatchObject({ 'flex-wrap': 'wrap', 'row-gap': '4px' });+ expect(declarations('.model-hub-order-section-head > .model-hub-order-section-explanation')).toMatchObject({+ display: 'block', flex: '1 1 100%', 'min-width': '0', padding: '0', border: '0',+ 'border-radius': '0', background: 'transparent', color: 'var(--muted)',+ 'font-size': 'var(--model-hub-order-meta-size)', 'font-weight': '400',+ 'line-height': '15px', 'white-space': 'normal', 'overflow-wrap': 'anywhere',+ });+ expect(declarations('.model-hub-order-section-head > span')).toEqual({});+ });+it('keeps Default Routing actions at the shared compact size after drawer styles apply', () => {const root = postcss.parse(surfaceCss);const declarations = (...selectors: string[]) => {diff --git a/ui/src/components/settings/models/modelHubSurface.css b/ui/src/components/settings/models/modelHubSurface.cssindex 0e771b154..7e153254d 100644--- a/ui/src/components/settings/models/modelHubSurface.css+++ b/ui/src/components/settings/models/modelHubSurface.css@@ -1755,32 +1755,14 @@align-items: center;justify-content: flex-start;gap: 6px;+ flex-wrap: wrap;+ row-gap: 4px;font-size: var(--model-hub-order-section-size);font-weight: 700;letter-spacing: 1.1px;color: var(--model-hub-ink-73);}-.model-hub-order-section-head > span {- display: inline-flex;- flex: none;- align-items: center;- justify-content: flex-start;- gap: 0;- padding: 3px 8px;- border: 1px solid var(--model-hub-wash-14);- border-radius: 999px;- background: var(--model-hub-wash-0a);- color: var(--muted);- font-size: 10px;- font-weight: 600;- letter-spacing: 0;- line-height: normal;-}-.model-hub-order-section-head--held-out {- flex-wrap: wrap;- row-gap: 4px;-}-.model-hub-order-section-head--held-out > .model-hub-order-section-explanation {+.model-hub-order-section-head > .model-hub-order-section-explanation {display: block;flex: 1 1 100%;min-width: 0;@@ -1793,12 +1775,17 @@font-weight: 400;letter-spacing: 0;line-height: 15px;+ white-space: normal;+ overflow-wrap: anywhere;}.model-hub-order-row {--model-hub-order-row-gap: 10px;--model-hub-order-row-padding-x: 12px;- height: var(--model-hub-order-row-height);+ --model-hub-order-row-padding-y: 8px;+ min-height: var(--model-hub-order-row-height);+ height: auto;padding-inline: var(--model-hub-order-row-padding-x);+ padding-block: var(--model-hub-order-row-padding-y);display: flex;align-items: center;gap: var(--model-hub-order-row-gap);@@ -1846,12 +1833,17 @@font-size: var(--model-hub-order-name-size);font-weight: 600;}+.model-hub-order-name,+.model-hub-order-meta {+ white-space: normal;+ overflow-wrap: anywhere;+}.model-hub-order-identity {display: flex;min-width: 0;flex: 1;flex-direction: column;- align-items: flex-start;+ align-items: stretch;justify-content: flex-start;gap: 3px;}