From 388771a43414f5b368ff31b785553d7b9f75d24a Mon Sep 17 00:00:00 2001 From: vkpdeveloper Date: Thu, 26 Nov 2026 03:57:30 +0530 Subject: [PATCH 1/2] feat(web): show sessions' agents and model names as T3 lists them --- apps/server/src/admin.ts | 16 +++++++--- apps/server/src/gateway/agents.ts | 6 ++++ apps/server/test/sessions.test.ts | 49 +++++++++++++++++++++++++++++++ apps/web/src/Canvas.tsx | 37 +++++++++++++++++++---- packages/contracts/src/index.ts | 9 +++++- 5 files changed, 106 insertions(+), 11 deletions(-) create mode 100644 apps/server/test/sessions.test.ts diff --git a/apps/server/src/admin.ts b/apps/server/src/admin.ts index c30496f..64bd168 100644 --- a/apps/server/src/admin.ts +++ b/apps/server/src/admin.ts @@ -25,7 +25,8 @@ import type { Hub } from "./gateway/hub.ts"; import { keptIconHeaders, projectIcon } from "./gateway/icons.ts"; import type { T3Gateway } from "./gateway/http.ts"; import { githubName } from "./gateway/repos.ts"; -import { isWorking } from "./gateway/types.ts"; +import { agentKind, agentName } from "./gateway/agents.ts"; +import { isWorking, str } from "./gateway/types.ts"; import { hasScreen, providers } from "./providers/index.ts"; import { envVars, machineName, saveEnvVars, type Secrets, type Settings } from "./settings.ts"; import { InstructionsError, isInstructionName } from "./instructions.ts"; @@ -674,6 +675,8 @@ export class Admin { const skills = this.deps.skills.state(); const screenSkills = this.deps.skills.state(true); const problems = this.deps.traffic.problems(); + // What T3 lists for each agent, from the VMs' last reports: its name and its models' names. + const agentReports = new Map(hub.agents().map((report) => [report.instanceId, report])); const vms = store .vms() .filter((vm) => vm.state !== "gone") @@ -696,13 +699,18 @@ export class Admin { sleepsAt: idle ? (vm.lastActivityAt ?? vm.createdAt) + idleMs : null, projects: projects.filter((project) => project.vms.some((entry) => entry.vmId === vm.id)).map((project) => project.id), sessions: hub.vmThreads(vm.id).map((thread) => { - const model = thread.modelSelection as { model?: unknown } | undefined; + const selection = thread.modelSelection as { model?: unknown; provider?: unknown } | undefined; + const instance = str(thread.providerInstanceId) ?? str(selection?.provider); + const report = instance ? agentReports.get(instance) : undefined; + const driver = report?.driver ?? instance; + const slug = str(selection?.model) ?? null; + const listed = (report?.models as { slug?: unknown; name?: unknown }[] | undefined)?.find((model) => model.slug === slug); return { threadId: thread.id, title: String(thread.title ?? "Untitled"), projectId: typeof thread.projectId === "string" ? thread.projectId : null, - model: typeof model?.model === "string" ? model.model : null, - provider: typeof thread.providerInstanceId === "string" ? thread.providerInstanceId : null, + model: str(listed?.name) ?? slug, + agent: driver ? { kind: agentKind(driver), name: report?.displayName ?? agentName(driver) } : null, status: String(thread.status ?? "idle"), working: isWorking(thread), updatedAt: typeof thread.updatedAt === "string" ? thread.updatedAt : null, diff --git a/apps/server/src/gateway/agents.ts b/apps/server/src/gateway/agents.ts index 09210c8..fb45f51 100644 --- a/apps/server/src/gateway/agents.ts +++ b/apps/server/src/gateway/agents.ts @@ -1,3 +1,4 @@ +import type { AgentKind } from "@vmbridge/contracts"; import type { ProviderPreference } from "../settings.ts"; import type { ProviderEntry, Wire } from "./types.ts"; @@ -6,6 +7,11 @@ const names: Record = { codex: "Codex", claudeAgent: "Claude", o /** An agent's display name from its T3 driver or instance ID. */ export const agentName = (id: string) => names[id] ?? id; +const kinds: Record = { codex: "codex", claudeAgent: "claude", opencode: "opencode" }; + +/** Which of the agents VM Bridge has a logo for a T3 driver is, if any. */ +export const agentKind = (driver: string): AgentKind | null => kinds[driver] ?? null; + /** Agents every VM gets installed, so T3 lists them before any VM has reported. */ export const defaultAgents = ["codex", "claudeAgent"]; diff --git a/apps/server/test/sessions.test.ts b/apps/server/test/sessions.test.ts new file mode 100644 index 0000000..1d4a8f5 --- /dev/null +++ b/apps/server/test/sessions.test.ts @@ -0,0 +1,49 @@ +import { afterEach, expect, test } from "bun:test"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import type { Overview } from "@vmbridge/contracts"; +import { openDatabase } from "../src/bun/sqlite.ts"; +import { dashboardKey, databasePath, start } from "../src/index.ts"; + +const password = "sessions test password"; +let cleanup = async () => {}; +afterEach(() => cleanup()); + +test("a VM's sessions name their agent and model as T3 lists them", async () => { + const dir = mkdtempSync(join(tmpdir(), "vmbridge-sessions-")); + const keys = dashboardKey(dir); + await keys.set(password); + keys.close(); + const db = openDatabase(databasePath(dir)); + db.run("INSERT INTO vms (id, provider, name, size, state, created_at) VALUES ('a1b2c3d4e5f6', 'e2b', 'vm1', 'medium', 'sleeping', 0)"); + const config = { + environment: { environmentId: "env1", orchestrationProtocolVersion: 2 }, + providers: [ + { instanceId: "claudeAgent", driver: "claudeAgent", enabled: true, models: [{ slug: "claude-opus-5-5", name: "Claude Opus 5.5" }] }, + { instanceId: "codex", driver: "codex", enabled: true, models: [] }, + ], + }; + const thread = (id: string, provider: string, model: string) => ({ id, projectId: null, title: id, status: "idle", providerInstanceId: provider, modelSelection: { provider, model } }); + const shell = { snapshotSequence: 1, projects: [], threads: [thread("t1", "claudeAgent", "claude-opus-5-5"), thread("t2", "codex", "gpt-6"), thread("t3", "pi", "pi-1")], archivedThreads: [] }; + for (const id of ["t1", "t2", "t3"]) db.run("INSERT INTO threads (id, vm_id) VALUES (?, 'a1b2c3d4e5f6')", id); + db.run("INSERT INTO vm_snapshots (vm_id, config, shell) VALUES ('a1b2c3d4e5f6', ?, ?)", JSON.stringify(config), JSON.stringify(shell)); + db.close(); + + const bridge = await start({ dir, host: "127.0.0.1", port: 0 }); + cleanup = async () => { + await bridge.stop(); + rmSync(dir, { recursive: true, force: true }); + }; + const base = `http://127.0.0.1:${bridge.port}`; + const login = await fetch(`${base}/admin/api/login`, { method: "POST", headers: { "content-type": "application/json", origin: base }, body: JSON.stringify({ key: password }) }); + const cookie = login.headers.get("set-cookie")!.split(";")[0]!; + const overview = (await (await fetch(`${base}/admin/api/overview`, { headers: { cookie } })).json()) as Overview; + + expect(overview.vms[0]!.sessions.map(({ agent, model }) => ({ agent, model }))).toEqual([ + { agent: { kind: "claude", name: "Claude" }, model: "Claude Opus 5.5" }, + // A model its agent does not list keeps its ID. An agent VM Bridge has no logo for keeps its name. + { agent: { kind: "codex", name: "Codex" }, model: "gpt-6" }, + { agent: { kind: null, name: "Pi" }, model: "pi-1" }, + ]); +}); diff --git a/apps/web/src/Canvas.tsx b/apps/web/src/Canvas.tsx index 4cd4edb..f212888 100644 --- a/apps/web/src/Canvas.tsx +++ b/apps/web/src/Canvas.tsx @@ -17,7 +17,7 @@ import { } from "@xyflow/react"; import { HugeiconsIcon } from "@hugeicons/react"; import { Add01Icon, Alert02Icon, Cancel01Icon, CenterFocusIcon, Delete02Icon, InformationCircleIcon, LaptopIcon, Message01Icon, Moon02Icon, PowerIcon, ZoomInIcon, ZoomOutIcon } from "@hugeicons/core-free-icons"; -import { vmSizes, type BridgeUpdate, type ClientInfo, type Overview, type ProjectInfo, type ProviderId, type TrafficEvent, type Usage, type VmInfo, type VmSize, type VmState, type VmStats } from "@vmbridge/contracts"; +import { vmSizes, type BridgeUpdate, type ClientInfo, type Overview, type ProjectInfo, type ProviderId, type SessionAgent, type TrafficEvent, type Usage, type VmInfo, type VmSize, type VmState, type VmStats } from "@vmbridge/contracts"; import { AlertDialog, AlertDialogAction, @@ -54,7 +54,7 @@ import { useAction } from "@/hooks/use-action"; import { sinceText } from "@/lib/devices"; import { cn } from "@/lib/utils"; import { ago, api, useTick } from "./api.ts"; -import { Logo, ProjectIcon, ProviderLogo } from "./brand.tsx"; +import { AgentLogo, Logo, ProjectIcon, ProviderLogo } from "./brand.tsx"; import { CopyButton } from "./CopyButton.tsx"; /** A connection animates while it carried a request this recently. */ @@ -223,6 +223,25 @@ function CloudflareUpdate({ version }: { version: string }) { ); } +/** An agent's logo, or its first letter when VM Bridge has no logo for it. */ +function AgentAvatar({ agent, className }: { agent: SessionAgent; className?: string }) { + if (agent.kind) return ; + return {agent.name.slice(0, 1).toUpperCase()}; +} + +/** Every agent with a session on a VM, once each, overlapping like avatars. */ +function AgentStack({ agents }: { agents: SessionAgent[] }) { + const unique = [...new Map(agents.map((agent) => [agent.kind ?? agent.name, agent])).values()]; + if (!unique.length) return null; + return ( + agent.name).join(", ")}> + {unique.map((agent) => ( + + ))} + + ); +} + function VmCard({ data }: NodeProps) { const { vm, projects, selected } = data; const state = vmStates[vm.state]; @@ -245,9 +264,12 @@ function VmCard({ data }: NodeProps) {
{vm.sizeLabel}
{vm.sessions.length > 0 && ( - - - {vm.sessions.length} + + (session.agent ? [session.agent] : []))} /> + + + {vm.sessions.length} + )} @@ -845,7 +867,10 @@ function VmDetails({ vm, overview, now, onClose }: { vm: VmInfo; overview: Overv {session.title} {session.status} - {[session.provider, session.model].filter(Boolean).join(" · ") || "No model"} + + {session.agent && } + {[session.agent?.name, session.model].filter(Boolean).join(" · ") || "No model"} + ); diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.ts index cbd318e..4d79fd3 100644 --- a/packages/contracts/src/index.ts +++ b/packages/contracts/src/index.ts @@ -167,12 +167,19 @@ export interface ClientInfo { export type VmState = "provisioning" | "starting" | "ready" | "busy" | "sleeping" | "error" | "gone"; +/** The agent running a session: the name T3 shows, and which logo it has, when VM Bridge knows it. */ +export interface SessionAgent { + kind: AgentKind | null; + name: string; +} + export interface VmSession { threadId: string; title: string; projectId: string | null; + /** The model's name as its agent lists it, such as "Claude Opus 5.5", or its ID when the agent does not list it. */ model: string | null; - provider: string | null; + agent: SessionAgent | null; status: string; /** A turn is running, queued, or waiting on an approval. */ working: boolean; From 1d898bb26b1a3278849a885691337cb5b9627ca5 Mon Sep 17 00:00:00 2001 From: vkpdeveloper Date: Thu, 26 Nov 2026 04:00:44 +0530 Subject: [PATCH 2/2] feat(web): agent logos without tiles beside sessions and on VM cards --- apps/web/src/Canvas.tsx | 10 +++++----- apps/web/src/brand.tsx | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/web/src/Canvas.tsx b/apps/web/src/Canvas.tsx index f212888..0db10a5 100644 --- a/apps/web/src/Canvas.tsx +++ b/apps/web/src/Canvas.tsx @@ -225,18 +225,18 @@ function CloudflareUpdate({ version }: { version: string }) { /** An agent's logo, or its first letter when VM Bridge has no logo for it. */ function AgentAvatar({ agent, className }: { agent: SessionAgent; className?: string }) { - if (agent.kind) return ; - return {agent.name.slice(0, 1).toUpperCase()}; + if (agent.kind) return ; + return {agent.name.slice(0, 1).toUpperCase()}; } -/** Every agent with a session on a VM, once each, overlapping like avatars. */ +/** Every agent with a session on a VM, once each, side by side: without tiles, overlapping logos would run together. */ function AgentStack({ agents }: { agents: SessionAgent[] }) { const unique = [...new Map(agents.map((agent) => [agent.kind ?? agent.name, agent])).values()]; if (!unique.length) return null; return ( - agent.name).join(", ")}> + agent.name).join(", ")}> {unique.map((agent) => ( - + ))} ); diff --git a/apps/web/src/brand.tsx b/apps/web/src/brand.tsx index c5c2cbb..0bd9514 100644 --- a/apps/web/src/brand.tsx +++ b/apps/web/src/brand.tsx @@ -57,8 +57,10 @@ const agentLogos: Record; return (