Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(model-hub): move switch history into logs (#1654)

Call White20fb5f304daf
diff --git a/docs/plans/model-hub-fidelity-audit.md b/docs/plans/model-hub-fidelity-audit.md
index 8a40eb613..546aa4f67 100644
--- a/docs/plans/model-hub-fidelity-audit.md
+++ b/docs/plans/model-hub-fidelity-audit.md
@@ -55,7 +55,7 @@ Recorded so a later pass does not "fix" a conforming value:
| 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`) |
+| A4 | Undesigned overview surfaces — resolved 2026-08-23 | frame 01 correctly ends after its graph body and legend | `高级` was deleted; `最近切换` moved out of the overview and into the registered `日志` tab, whose read is lazy and independent of first paint |
A3 consequences, all observed:
@@ -180,10 +180,13 @@ 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
+- **A4 is closed.** The dead 高级 placeholder no longer ships. Switch history is
+ registered as the Logs-tab surface instead of extending frame 01 below its designed
+ boundary.
+
- ~~**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
diff --git a/docs/plans/model-hub-ui-spec.md b/docs/plans/model-hub-ui-spec.md
index 574eee951..a9325ad2e 100644
--- a/docs/plans/model-hub-ui-spec.md
+++ b/docs/plans/model-hub-ui-spec.md
@@ -1047,12 +1047,12 @@ and 12 reuse 06 and 01 respectively as exhibit backgrounds; the 04 paste-back cr
frame 13 are component exhibits. Specifying the shell once is not a shortcut: a shell
copied into every section is one that will drift in all but one of them.
-**Two parts of the shell are conditional, and the frames disagree about them on
-purpose.** Frames 09 and 10 draw the header but **no tab strip and no `cols`
-track** — in the direct-only state there is no gateway module to put in the second
-column and no second section to tab to, so the chrome that organizes those things is
-absent rather than empty. Read the tab strip as a property of the gateway-adopted
-layout, not of the page. §1.8 states the condition.
+**The tabs belong to the overview shell, while the source detail replaces them with
+Back.** Usage and switch history both outlive the current Source inventory, so every
+overview landing keeps the three-tab strip even when the Sources & gateway body is
+frame 09's direct-only state. Frames 09 and 10 predate this section navigation and
+remain authoritative for their bodies, not for whether the shell exposes its other
+sections. §1.8 states the direct-only body condition.
**Geometry** `[frame]`
@@ -1078,12 +1078,21 @@ layout, not of the page. §1.8 states the condition.
| --- | --- | --- | --- | --- |
| `title` + info icon | Page name | static | icon: hover, focus **and** activation `[derived]` | Tooltip: `shell.gatewayInfo.body`, which is the icon's accessible description; `shell.gatewayInfo.label` is its accessible name |
| Run pill | Engine liveness | `runtime-dependency.schema.json` → `status.health` `[contract]` | see the mapping below | see the mapping below |
-| Tabs ×2 | Section switch | — | yes | 来源与网关 / 用量与额度; the active one gets the mint underline. **Which route these correspond to is not specified by these frames** (§0.1) |
+| Tabs ×3 | Section switch | — | yes | 来源与网关 / 用量 / 日志; the active one gets the mint underline |
| Upstream module | Source inventory | `GET /api/models/sources` `[spec]` | rows: yes | Open 06 for that source |
| Dispatch rail | That upstream feeds gateway | derived, decorative | no | — |
| Gateway module | One group per backend, each with model rows | per-backend supply + chains `[spec]` | rows, collapse, 「来源顺序」, mode switch | Open 02 / expand / open 03 for **that backend** / open 10's confirm |
| Legend | Colour → meaning | static; kept in bijection with the inks the page draws | no | — |
+**The Logs tab owns the switch-history feed** `[derived]`. It is absent from the
+Sources & gateway body and is read only when Logs is opened, so event history cannot
+delay the routing surface. Each activation refreshes the head through
+`GET /api/models/events?limit=20`; the card shows three rows initially, 查看全部 expands
+the held rows and follows the `before` cursor until exhausted, and 收起 returns to three.
+An unread feed keeps the card and its retry action distinct from the authoritative
+暂无切换记录 empty state. The removed 高级 placeholder has no surviving surface or copy:
+request logging and diagnostics must return as real capabilities, not as a dead row.
+
**The info icon is a control, and its string is this file's** `[derived]`. Hover is not
an affordance a keyboard or a touch user has, and this tooltip is the only place the page
says what the gateway *is* — so the icon is a focusable button, activating it toggles the
@@ -1371,7 +1380,17 @@ unable to outlive its surface, which is the cheaper answer wherever it is availa
| `install.fail.title` `[derived]` | 安装没有完成 | The install did not finish |
| `install.retry` `[derived]` | 重试 | Try again |
| `shell.tab.hub` | 来源与网关 | Sources & gateway |
-| `shell.tab.usage` | 用量与额度 | Usage & quota |
+| `shell.tab.usage` | 用量 | Usage |
+| `shell.tab.logs` | 日志 | Logs |
+| `recent.title` | 最近切换 | Recent switches |
+| `recent.viewAll` | 查看全部 | View all |
+| `recent.collapse` | 收起 | Collapse |
+| `recent.loadMore` | 加载更早的记录 | Load older entries |
+| `recent.loadingMore` | 加载中… | Loading… |
+| `recent.today` | 今天 | Today |
+| `recent.yesterday` | 昨天 | Yesterday |
+| `recent.empty` | 暂无切换记录 | No switches yet |
+| `recent.deletedSource` | 已删除 | deleted |
| `upstream.heading` | 来源 | Sources |
| `upstream.count_one` | {{count}} 个 | {{count}} source |
| `upstream.count_other` | {{count}} 个 | {{count}} sources |
@@ -4523,11 +4542,12 @@ becomes 01」 describes a one-way trip, and this document specifies the return t
elsewhere. A rule that reads correctly forward and silently drops a state on the way back
is not caught by reading it forward again.
-**Two things about that switch are easy to get wrong, and the frames settle both.**
-First, the tab strip is *not* chrome that is always there with an empty second tab: 09
-draws no `KB3N9` / `ag5OQ` pair at all, because 用量与额度 has nothing to report when
-nothing has ever been supplied, and a tab that opens on an empty page is worse than a
-tab that does not exist. Second, this frame does not survive as a block inside 01 — but
+**Two things about that switch are easy to get wrong; the owner ruling of 2026-08-23
+settles the first, and the frames settle the second.** First, the tab strip is page
+chrome across every overview landing: the usage ledger and switch log outlive the
+Sources they name, so deleting the last Source cannot delete the only route to either
+history. Frame 09 predates those sections and supplies the Sources & gateway body under
+that strip. Second, this frame does not survive as a block inside 01 — but
its *function* does, relocated. The three backend rows here each carry 切换到网关; on 01
and 08 the same action rides on the still-direct backend's own group header (`g3Wh0P`
on 01, `lcPvy` on 08, next to the 「直连」 subtitle). So partial adoption keeps every
@@ -4540,8 +4560,9 @@ things they would gain — not from whether they have ever adopted one. A user w
reverted and deleted their sources sees it again, and it is still true when they do. That
is the difference between an onboarding card and an empty state, and this is the second.
-**What the shell drops, and why** `[frame]`. Frame 09 renders the header but **no tab
-strip, no three-column `cols` track, no dispatch rail, no wire layer and no legend.**
+**What the Sources & gateway body drops, and why** `[frame]`. Frame 09 renders **no
+three-column `cols` track, no dispatch rail, no wire layer and no legend.** The overview
+shell still keeps the three-tab strip for the two independent history sections.
There is no gateway module to occupy the second column, no supply relations to draw, and
therefore no inks to explain. An empty gateway column with a placeholder would be worse
than its absence: it would assert that a thing exists here and is currently broken,
@@ -4550,7 +4571,7 @@ which is the opposite of the truth.
**The page and the module have different names, and neither is 「模型网关」** `[frame]`.
Measured across the original full-page set: the page title is 「模型」 (`oPD53` here, `YkN0P` on 01,
`VaXos` on 08, and so on), the first tab — the module this document specifies — is
-「来源与网关」, and the second is 「用量与额度」. The string 「模型网关」 is **not rendered
+「来源与网关」, the second is 「用量」, and the third is 「日志」. The string 「模型网关」 is **not rendered
anywhere in the product surface**; it appears only in the design file's own frame names
(「模型网关 09 — …」), which are canvas labels for the author, not copy. This is worth
recording because the plan documents use 「模型网关」 as the project's name for the whole
diff --git a/ui/src/components/settings/models/AdvancedRow.tsx b/ui/src/components/settings/models/AdvancedRow.tsx
deleted file mode 100644
index e3757f8e0..000000000
--- a/ui/src/components/settings/models/AdvancedRow.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-// The single 高级 placeholder row (frame 01r): cross-vendor auto-substitution
-// (default-off) · request log · diagnostics. The detail surfaces are future
-// work; the row explains itself until they land.
-import * as React from 'react';
-import { ChevronRight, SlidersHorizontal } from 'lucide-react';
-import { useTranslation } from 'react-i18next';
-
-import { useToast } from '@/context/ToastContext';
-
-export const AdvancedRow: React.FC = () => {
- const { t } = useTranslation();
- const { showToast } = useToast();
-
- return (
- <button
- type="button"
- onClick={() => showToast(t('settings.models.advanced.comingSoon') as string, 'warning')}
- className="flex w-full items-center gap-3 rounded-xl border border-border bg-background px-4 py-4 text-left sm:px-5 transition-colors hover:border-border-strong"
- >
- <SlidersHorizontal className="size-4 shrink-0 text-muted" />
- <span className="flex min-w-0 flex-1 flex-wrap items-baseline gap-x-2 gap-y-0.5">
- <span className="text-[14px] font-medium text-foreground">{t('settings.models.advanced.title')}</span>
- <span className="text-[12px] text-muted">{t('settings.models.advanced.detail')}</span>
- </span>
- <ChevronRight className="size-4 shrink-0 text-muted" />
- </button>
- );
-};
diff --git a/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx b/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx
index 5e2a19e24..ad559a729 100644
--- a/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx
+++ b/ui/src/components/settings/models/SettingsModelsPage.render.test.tsx
@@ -193,7 +193,7 @@ describe('SettingsModelsPage surface branches', () => {
// Frame 09 is what the `sources` tab shows here — not what the Hub shows
// instead of its tabs. It is still Frame 09's body: none of the gateway
// overview leaks in beside it.
- expect(screen.getAllByRole('tab')).toHaveLength(2);
+ expect(screen.getAllByRole('tab')).toHaveLength(3);
expect(screen.queryByText(/^Recent switches$|^最近切换$/i)).toBeNull();
});
@@ -269,10 +269,26 @@ describe('SettingsModelsPage surface branches', () => {
renderPage([retainedSource]);
expect(await screen.findByText('Retained source')).toBeTruthy();
- expect(screen.getAllByRole('tab')).toHaveLength(2);
+ expect(screen.getAllByRole('tab')).toHaveLength(3);
expect(screen.queryByText(/^Switch to the gateway and you gain three things$|^切换到网关,你会多出三件事$/i)).toBeNull();
});
+ it('moves recent switches into the Logs tab and removes the Advanced placeholder', async () => {
+ renderPage([retainedSource]);
+
+ await screen.findByText('Retained source');
+ const events = vi.mocked(modelsApi.listEvents);
+ expect(events).not.toHaveBeenCalled();
+ expect(screen.queryByText(/^Recent switches$|^最近切换$/i)).toBeNull();
+ expect(screen.queryByText(/Cross-vendor auto-substitution|跨厂商自动顶替/i)).toBeNull();
+
+ await userEvent.click(await screen.findByRole('tab', { name: /^Logs$|^日志$/i }));
+
+ expect(await screen.findByText(/^Recent switches$|^最近切换$/i)).toBeTruthy();
+ expect(screen.queryByText('Retained source')).toBeNull();
+ await waitFor(() => expect(events).toHaveBeenCalledTimes(1));
+ });
+
it('opens the subscription vendor picker and OAuth flow from the Sources card', async () => {
renderPage([retainedSource]);
@@ -454,8 +470,7 @@ describe('SettingsModelsPage surface branches', () => {
await waitFor(() => expect(reauth).toHaveBeenCalledTimes(2));
});
- it('lands the operational overview without waiting for event history', async () => {
- const pendingEvents = deferred<[]>();
+ it('lands the operational overview without reading hidden event history', async () => {
vi.spyOn(modelsApi, 'listSources').mockResolvedValue([]);
vi.spyOn(modelsApi, 'listAgents').mockResolvedValue([
directAgent('claude'),
@@ -463,7 +478,7 @@ describe('SettingsModelsPage surface branches', () => {
directAgent('opencode'),
]);
vi.spyOn(modelsApi, 'getRuntimeStatus').mockResolvedValue(runtime);
- vi.spyOn(modelsApi, 'listEvents').mockReturnValue(pendingEvents.promise);
+ const events = vi.spyOn(modelsApi, 'listEvents').mockResolvedValue([]);
render(
<ToastProvider>
@@ -475,10 +490,7 @@ describe('SettingsModelsPage surface branches', () => {
expect(await screen.findByText(/^Currently: direct$|^当前:直连$/i)).toBeTruthy();
expect(screen.getAllByRole('button', { name: /^Switch to Gateway$|^切换到网关$/i })).toHaveLength(3);
- await act(async () => {
- pendingEvents.resolve([]);
- await pendingEvents.promise;
- });
+ expect(events).not.toHaveBeenCalled();
});
it('counts a recoverable reroute once per backend in Frame 08', async () => {
@@ -528,6 +540,7 @@ describe('SettingsModelsPage surface branches', () => {
</ToastProvider>,
);
+ await userEvent.click(await screen.findByRole('tab', { name: /^Logs$|^日志$/i }));
expect((await screen.findAllByText(/Couldn't refresh, please retry|刷新失败,请重试/i)).length).toBeGreaterThan(0);
expect(screen.queryByText(/^No switches yet$|^暂无切换记录$/i)).toBeNull();
await userEvent.click(screen.getByRole('button', { name: /^Retry$|^重试$/i }));
@@ -951,7 +964,7 @@ describe('SettingsModelsPage usage region', () => {
vi.restoreAllMocks();
renderPage(sources);
- await waitFor(() => expect(screen.getAllByRole('tab'), landing).toHaveLength(2));
+ await waitFor(() => expect(screen.getAllByRole('tab'), landing).toHaveLength(3));
await openUsage();
await waitFor(() => expect(vi.mocked(modelsApi.getUsageSummary), landing).toHaveBeenCalledWith(30));
}
diff --git a/ui/src/components/settings/models/SettingsModelsPage.tsx b/ui/src/components/settings/models/SettingsModelsPage.tsx
index c703bf715..d48825ed9 100644
--- a/ui/src/components/settings/models/SettingsModelsPage.tsx
+++ b/ui/src/components/settings/models/SettingsModelsPage.tsx
@@ -1,5 +1,5 @@
import * as React from 'react';
-import { ArrowLeft, Gauge, LoaderCircle, Route } from 'lucide-react';
+import { ArrowLeft, Gauge, LoaderCircle, Route, ScrollText } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Badge } from '@/components/ui/badge';
@@ -9,7 +9,6 @@ import { useToast } from '@/context/ToastContext';
import { cn } from '@/lib/utils';
import { AddApiKeyDialog } from './AddApiKeyDialog';
import { OAuthConnectDialog } from './OAuthConnectDialog';
-import { AdvancedRow } from './AdvancedRow';
import { EnableGatewayDialog } from './EnableGatewayDialog';
import { GatewayModule } from './GatewayModule';
import { InstallGatewayDialog } from './InstallGatewayDialog';
@@ -224,14 +223,16 @@ const ModelHubShell: React.FC<{ actions?: React.ReactNode; detailBack?: () => vo
);
};
-const HubTabs: React.FC<{ tab: 'sources' | 'usage'; onChange: (tab: 'sources' | 'usage') => void }> = ({ tab, onChange }) => {
+type HubTab = 'sources' | 'usage' | 'logs';
+
+const HubTabs: React.FC<{ tab: HubTab; onChange: (tab: HubTab) => void }> = ({ tab, onChange }) => {
const { t } = useTranslation();
return (
<div role="tablist" className="flex h-[39px] items-end gap-1 border-b border-border">
- {(['sources', 'usage'] as const).map((id) => (
+ {(['sources', 'usage', 'logs'] as const).map((id) => (
<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'}`)}
+ {id === 'sources' ? <Route className="size-3.5" /> : id === 'usage' ? <Gauge className="size-3.5" /> : <ScrollText className="size-3.5" />}
+ {t(`settings.models.shell.tab.${id === 'sources' ? 'hub' : id}`)}
</button>
))}
</div>
@@ -294,7 +295,7 @@ export const SettingsModelsPage: React.FC = () => {
const [runtimeRead, setRuntimeRead] = React.useState<RegionRead<RuntimeDependency>>(loadingRegion);
const [eventsRead, setEventsRead] = React.useState<RegionRead<EventFeed>>(loadingRegion);
const [loadingEvents, setLoadingEvents] = React.useState(false);
- const [tab, setTab] = React.useState<'sources' | 'usage'>('sources');
+ const [tab, setTab] = React.useState<HubTab>('sources');
const [usageRead, setUsageRead] = React.useState<RegionRead<UsageSummary>>(loadingRegion);
const [usageWindow, setUsageWindow] = React.useState<UsageWindowOption>(USAGE_DEFAULT_WINDOW_DAYS);
const [startingRuntime, setStartingRuntime] = React.useState(false);
@@ -564,6 +565,11 @@ export const SettingsModelsPage: React.FC = () => {
});
}, [eventReadAuthority]);
+ React.useEffect(() => {
+ if (tab !== 'logs') return;
+ void refreshEventHead();
+ }, [refreshEventHead, tab]);
+
const [refreshAuthority] = React.useState(() => createLatestAsyncAuthority<AuthorizedSurfaceLanding>(({ landing, sourceSnapshot }) => {
if (!aliveRef.current) return;
const freshSources = foldRegionRead<Source[], Source[] | null>(landing.sources, {
@@ -586,7 +592,6 @@ export const SettingsModelsPage: React.FC = () => {
const refresh = React.useCallback(async (
affectedChains: ModelChainRequest[] = [],
): Promise<SourceMutationLanding> => {
- void refreshEventHead();
const outcome: { landing: SourceMutationLandingReads | null } = { landing: null };
const result = await refreshAuthority.run(async () => {
const sourceSnapshot = sourceEntityAuthority.beginSnapshot();
@@ -607,7 +612,7 @@ export const SettingsModelsPage: React.FC = () => {
showToast(t('settings.models.toast.refreshFailed') as string, 'error');
}
return landing;
- }, [agentCollectionReads, refreshAffectedChains, refreshAuthority, refreshEventHead, showToast, sourceCollectionReads, sourceEntityAuthority, t]);
+ }, [agentCollectionReads, refreshAffectedChains, refreshAuthority, showToast, sourceCollectionReads, sourceEntityAuthority, t]);
const trackSourceMutation = React.useCallback((sourceId: string): TrackSourceMutation => async <T,>(work: (source: Source, settlement: SourceMutationSettlement) => Promise<T>): Promise<T> => {
let result!: T;
@@ -1060,15 +1065,13 @@ export const SettingsModelsPage: React.FC = () => {
: <section className="rounded-xl border border-border bg-surface px-5 py-12 text-center text-[12px] text-muted">{t('settings.models.sourceDetail.gone')}</section>
: <div className="space-y-[22px]">
{/* The tab strip belongs to the Hub, not to the source
- inventory. The ledger outlives the Sources it metered — it
- retains its window and the report names a deleted Source by
- its id — so deleting the last one may not take the only route
- to that history with it. Frame 09 is drawn without tabs
- because it predates this tab, not because usage stops
- existing once the inventory is empty; what the frame decides
- is the body of `sources`, which is still Frame 09 there. */}
+ inventory. Usage and switch history both outlive the Sources
+ they name, so deleting the last Source may not remove the only
+ route to either record. Frame 09 predates these tabs; it still
+ owns the direct-only body of `sources`. */}
<HubTabs tab={tab} onChange={setTab} />
{tab === 'usage' ? <UsageTab usage={usageRead} windowDays={usageWindow} onWindowChange={setUsageWindow} onRetry={retryUsage} />
+ : tab === 'logs' ? <RecentSwitchesCard events={eventsRead} sources={sourcesRead} onRetry={retryEvents} loadingMore={loadingEvents} onLoadMore={loadOlderEvents} />
: directEmpty ? <DirectHome agents={installedAgents} onSwitch={setAdoptAgent} />
: <div className="model-hub-overview">
<div className="model-hub-overview-body">
@@ -1164,8 +1167,6 @@ export const SettingsModelsPage: React.FC = () => {
</div>
<SupplyLegend relations={supplyRelations} />
</div>
- <RecentSwitchesCard events={eventsRead} sources={sourcesRead} onRetry={retryEvents} loadingMore={loadingEvents} onLoadMore={loadOlderEvents} />
- <AdvancedRow />
</div>}
</div>}
<SourceMutationReport
diff --git a/ui/src/components/settings/models/SupplyGraph.test.tsx b/ui/src/components/settings/models/SupplyGraph.test.tsx
index 4e3060b08..6a242ba75 100644
--- a/ui/src/components/settings/models/SupplyGraph.test.tsx
+++ b/ui/src/components/settings/models/SupplyGraph.test.tsx
@@ -22,13 +22,11 @@ const rect = (left: number, top: number, width: number, height: number): DOMRect
const Fixture: React.FC = () => {
const ref = React.useRef<HTMLDivElement>(null);
- const [mounted, setMounted] = React.useState(false);
- React.useLayoutEffect(() => setMounted(true), []);
return (
<div ref={ref} data-testid="graph-root">
<div data-source-id="src_a" />
<div data-agent-backend="claude" />
- {mounted && <SupplyGraph containerRef={ref} relations={[relation]} />}
+ <SupplyGraph containerRef={ref} relations={[relation]} />
</div>
);
};
@@ -39,7 +37,7 @@ afterEach(() => {
});
describe('SupplyGraph', () => {
- it('re-measures wires when a nested card scrolls without resizing the shell', async () => {
+ it('draws on the shared mount and re-measures when a nested card scrolls', async () => {
let sourceTop = 10;
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function bounds() {
if (this.dataset.testid === 'graph-root') return rect(0, 0, 120, 100);
diff --git a/ui/src/components/settings/models/SupplyGraph.tsx b/ui/src/components/settings/models/SupplyGraph.tsx
index 473534ffe..7ab221508 100644
--- a/ui/src/components/settings/models/SupplyGraph.tsx
+++ b/ui/src/components/settings/models/SupplyGraph.tsx
@@ -20,7 +20,7 @@ export const SupplyGraph: React.FC<{
}> = ({ containerRef, relations }) => {
const [drawing, setDrawing] = React.useState<{ width: number; height: number; railX: number; wires: DrawnRelation[] } | null>(null);
- React.useLayoutEffect(() => {
+ React.useEffect(() => {
const container = containerRef.current;
if (!container) return undefined;
const measure = () => {
diff --git a/ui/src/components/settings/models/eventFeed.test.ts b/ui/src/components/settings/models/eventFeed.test.ts
index 59563aa8e..98b213de2 100644
--- a/ui/src/components/settings/models/eventFeed.test.ts
+++ b/ui/src/components/settings/models/eventFeed.test.ts
@@ -1,10 +1,8 @@
// The feed merge, in both directions.
//
-// The regression these pin: 最近切换 was fetched once at mount, so a write that
-// filed an event (a failing 试跑 cooling its own head down) changed the source row
-// while the line explaining that change stayed invisible until a full reload. The
-// post-write refresh now re-reads the head — which is only safe if it cannot throw
-// away the rows 加载更早 已经 paged in, and cannot splice a hole into the sequence.
+// The feed is loaded only while its Logs tab is visible. A fresh tab open re-reads
+// the head, which is only safe if it cannot throw away the rows 加载更早 已经
+// paged in, and cannot splice a hole into the sequence.
//
// And the follow-on: the rows and 「is there anything older」 are one fact. Moving
// only the rows is how the replace branch left 加载更早 claiming an end it had just
@@ -203,10 +201,15 @@ describe('the page reads the feed through this owner', () => {
const firstPaint = readFileSync(join(__dirname, 'firstPaintRegions.ts'), 'utf8');
const mutationSettlement = readFileSync(join(__dirname, 'mutationSettlement.ts'), 'utf8');
- it('re-reads events in the shared post-write refresh', () => {
- // The whole point: the refresh every mutation site already calls is what has
- // to move the feed, not a probe-only twin bolted onto one call site.
- expect(page).toMatch(/const refresh = React\.useCallback[\s\S]*?void refreshEventHead\(\)[\s\S]*?refreshAuthority\.run/);
+ it('reads events only while the Logs tab is visible', () => {
+ // Hidden history is not part of the operational first-paint or source mutation
+ // barrier. Reopening Logs refreshes the head while preserving paged-in rows.
+ expect(page).toMatch(/React\.useEffect\(\(\) => \{\s*if \(tab !== 'logs'\) return;\s*void refreshEventHead\(\);\s*\}, \[refreshEventHead, tab\]\)/);
+ const sharedRefresh = page.slice(
+ page.indexOf('const refresh = React.useCallback'),
+ page.indexOf('\n\n const trackSourceMutation'),
+ );
+ expect(sharedRefresh).not.toMatch(/refreshEventHead/);
expect(page).toMatch(/eventReadAuthority\.run[\s\S]*?modelsApi\.listEvents\(EVENT_PAGE\)/);
expect(page).toMatch(/setEventsRead[\s\S]*?foldRegionRead<ResolutionEvent\[\],[\s\S]*?\(incoming,[\s\S]*?feedAfterHeadRead\(previousFeed, freshEvents\)/);
expect(page).toMatch(/feedAfterTailRead\(emptyFeed, freshEvents, EVENT_PAGE, null\)/);
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index a1fcd8d82..1ef93a334 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -657,7 +657,8 @@
},
"tab": {
"hub": "Sources & gateway",
- "usage": "Usage"
+ "usage": "Usage",
+ "logs": "Logs"
}
},
"direct": {
@@ -1099,11 +1100,6 @@
"empty": "No switches yet",
"deletedSource": "deleted"
},
- "advanced": {
- "title": "Advanced",
- "detail": "Cross-vendor auto-substitution (off) · Request log · Diagnostics",
- "comingSoon": "Advanced settings are coming soon"
- },
"addKey": {
"title": "Add API key",
"subtitle": "Add connects once: it identifies the interface and fetches the model list",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index a1cb52f93..e53578182 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -657,7 +657,8 @@
},
"tab": {
"hub": "来源与网关",
- "usage": "用量"
+ "usage": "用量",
+ "logs": "日志"
}
},
"direct": {
@@ -1099,11 +1100,6 @@
"empty": "暂无切换记录",
"deletedSource": "已删除"
},
- "advanced": {
- "title": "高级",
- "detail": "跨厂商自动顶替(默认关)· 请求日志 · 诊断",
- "comingSoon": "高级设置即将上线"
- },
"addKey": {
"title": "添加 API Key",
"subtitle": "「添加」时自动连一次:认出接口 + 拉取型号列表",