diff --git a/ui/src/lib/utils.test.ts b/ui/src/lib/utils.test.ts index dd6cf96..34b1161 100644 --- a/ui/src/lib/utils.test.ts +++ b/ui/src/lib/utils.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { statusTone, toneClasses } from './utils'; +import { statusTone, toneClasses, formatActivityMeta } from './utils'; describe('statusTone', () => { it('returns theme-adaptive light-dark() colors', () => { @@ -24,3 +24,19 @@ describe('toneClasses', () => { expect(toneClasses('neutral')).toBe('bg-surface-2 text-slate-700 border-hairline'); }); }); + +describe('formatActivityMeta (backend-primary labels)', () => { + it('shows the physical backend as the worker with a via-proxy suffix', () => { + expect(formatActivityMeta('aao-gateway', 'quality', 'gpu-rtx-a')) + .toBe('worker: gpu-rtx-a (via aao-gateway) · mode: quality'); + }); + + it('falls back to the plain worker name when no backend tag exists', () => { + expect(formatActivityMeta('my-worker', null, null)).toBe('worker: my-worker'); + }); + + it('ignores a backend equal to the worker id (direct worker echo)', () => { + expect(formatActivityMeta('gpu-a', 'auto', 'gpu-a')) + .toBe('worker: gpu-a · mode: auto'); + }); +}); diff --git a/ui/src/lib/utils.ts b/ui/src/lib/utils.ts index 4a7b390..c04c3a5 100644 --- a/ui/src/lib/utils.ts +++ b/ui/src/lib/utils.ts @@ -120,12 +120,16 @@ export interface ActivityEvent { } export function formatActivityMeta(workerId: string | null, mode: string | null, backendId?: string | null): string { - return [ - workerId ? `worker: ${workerPill(workerId)}` : '', - // Show the physical backend when it differs from the (proxy) worker name. - backendId && backendId !== workerId ? `backend: ${workerPill(backendId)}` : '', - mode ? `mode: ${mode}` : '', - ].filter(Boolean).join(' · '); + // For proxy workers (AAO gateway) the interesting name is the PHYSICAL + // backend behind the gateway — show it as the worker, with the proxy + // relegated to a "via" suffix. Lines without a backend tag (direct + // workers, or logs written before the backend tag existed) keep the + // plain worker name. + const hasBackend = !!backendId && backendId !== workerId; + const workerLabel = hasBackend + ? `worker: ${workerPill(backendId!)}${workerId ? ` (via ${workerId})` : ''}` + : workerId ? `worker: ${workerPill(workerId)}` : ''; + return [workerLabel, mode ? `mode: ${mode}` : ''].filter(Boolean).join(' · '); } export function parseActivityLog(logText: string): ActivityEvent[] { @@ -215,7 +219,7 @@ export function buildActivitySteps(events: ActivityEvent[]): Array<{ label: stri let currentMovement: string | null = null; for (const event of events) { - const meta = formatActivityMeta(event.workerId, event.mode); + const meta = formatActivityMeta(event.workerId, event.mode, event.backendId); const suffix = meta ? ` · ${meta}` : ''; if (event.kind === 'movement_start') {