Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8406 fix(onboarding): count computers and scope model discovery (#9730)
ZIce40e42d157266
diff --git a/packages/core/api/client.test.ts b/packages/core/api/client.test.tsindex eb80e8b10e..cd77e7b40b 100644--- a/packages/core/api/client.test.ts+++ b/packages/core/api/client.test.ts@@ -1,5 +1,6 @@import { afterEach, describe, expect, it, vi } from "vitest";import { createAuthStore } from "../auth";+import { setCurrentWorkspace } from "../platform/workspace-storage";import { configStore } from "../config";import type { StorageAdapter, User } from "../types";import { ApiClient, ApiError, CHAT_DRAFT_RESTORE_CAPABILITY, clientErrorMessage } from "./client";@@ -2243,7 +2244,7 @@ describe("ApiClient model discovery response schema", () => {function stubJSON(body: unknown) {vi.stubGlobal("fetch",- vi.fn().mockResolvedValue(+ vi.fn().mockImplementation(() =>new Response(JSON.stringify(body), {status: 200,headers: { "Content-Type": "application/json" },@@ -2252,6 +2253,39 @@ describe("ApiClient model discovery response schema", () => {);}+ it.each([null, "other-workspace"])(+ "targets onboarding workspace for discovery and polling with active route %s",+ async (activeSlug) => {+ setCurrentWorkspace(activeSlug, null);+ try {+ stubJSON(completed);+ const client = new ApiClient("https://api.example.test");+ await client.initiateListModels("rt-1", { force: true }, "new-workspace");+ await client.getListModelsResult("rt-1", "req-1", "new-workspace");+ for (const [, init] of vi.mocked(fetch).mock.calls) {+ expect(new Headers(init?.headers).get("X-Workspace-Slug")).toBe("new-workspace");+ }+ } finally {+ setCurrentWorkspace(null, null);+ }+ },+ );++ it("keeps the active workspace header when no override is supplied", async () => {+ setCurrentWorkspace("existing-workspace", null);+ try {+ stubJSON(completed);+ const client = new ApiClient("https://api.example.test");+ await client.initiateListModels("rt-1");+ await client.getListModelsResult("rt-1", "req-1");+ for (const [, init] of vi.mocked(fetch).mock.calls) {+ expect(new Headers(init?.headers).get("X-Workspace-Slug")).toBe("existing-workspace");+ }+ } finally {+ setCurrentWorkspace(null, null);+ }+ });+it("parses a live completed discovery", async () => {stubJSON(completed);diff --git a/packages/core/api/client.ts b/packages/core/api/client.tsindex 9a8353ca53..e21cb3b25e 100644--- a/packages/core/api/client.ts+++ b/packages/core/api/client.ts@@ -2724,12 +2724,14 @@ export class ApiClient {async initiateListModels(runtimeId: string,options: { force?: boolean } = {},+ workspaceSlug?: string,): Promise<RuntimeModelListRequest> {const query = options.force === true ? "?force=true" : "";const raw = await this.fetch<unknown>(`/api/runtimes/${runtimeId}/models${query}`,{method: "POST",+ headers: workspaceHeader(workspaceSlug),},);return parseWithFallback<RuntimeModelListRequest>(@@ -2743,9 +2745,11 @@ export class ApiClient {async getListModelsResult(runtimeId: string,requestId: string,+ workspaceSlug?: string,): Promise<RuntimeModelListRequest> {const raw = await this.fetch<unknown>(`/api/runtimes/${runtimeId}/models/${requestId}`,+ { headers: workspaceHeader(workspaceSlug) },);return parseWithFallback<RuntimeModelListRequest>(raw,diff --git a/packages/core/runtimes/models.test.ts b/packages/core/runtimes/models.test.tsindex e41fff67e8..9fbeff6758 100644--- a/packages/core/runtimes/models.test.ts+++ b/packages/core/runtimes/models.test.ts@@ -18,9 +18,10 @@ vi.mock("../api", () => ({initiateListModels: (runtimeId: string,options?: { force?: boolean },- ) => initiateListModels(runtimeId, options),- getListModelsResult: (runtimeId: string, requestId: string) =>- getListModelsResult(runtimeId, requestId),+ workspaceSlug?: string,+ ) => initiateListModels(runtimeId, options, workspaceSlug),+ getListModelsResult: (runtimeId: string, requestId: string, workspaceSlug?: string) =>+ getListModelsResult(runtimeId, requestId, workspaceSlug),},}));@@ -143,7 +144,7 @@ describe("resolveRuntimeModels", () => {expect(result.models).toEqual(catalog);expect(result.supported).toBe(true);expect(getListModelsResult).toHaveBeenCalledTimes(2);- expect(getListModelsResult).toHaveBeenLastCalledWith("rt-1", "req-1");+ expect(getListModelsResult).toHaveBeenLastCalledWith("rt-1", "req-1", undefined);});// MUL-6606 review: the client budget has to cover the server's pending AND@@ -297,7 +298,7 @@ describe("runtimeModelsOptions", () => {await refreshRuntimeModels(client, "rt-1");- expect(initiateListModels).toHaveBeenCalledWith("rt-1", { force: true });+ expect(initiateListModels).toHaveBeenCalledWith("rt-1", { force: true }, undefined);expect(client.getQueryData(runtimeModelsKeys.forRuntime("rt-1"))).toMatchObject({models: refreshedCatalog,cached: false,@@ -386,3 +387,29 @@ describe("runtimeModelsOptions", () => {expect(initiateListModels).toHaveBeenCalledTimes(2);});});+++describe("onboarding workspace context", () => {+ it("passes the target through initial query, polling, and forced refresh", async () => {+ vi.useFakeTimers();+ const client = new QueryClient();+ try {+ initiateListModels.mockResolvedValue(request({ status: "pending" }));+ getListModelsResult.mockResolvedValue(request({ status: "completed", models: catalog }));+ const initial = client.fetchQuery(runtimeModelsOptions("rt-1", "new-workspace"));+ await vi.advanceTimersByTimeAsync(500);+ await initial;+ expect(initiateListModels).toHaveBeenLastCalledWith("rt-1", undefined, "new-workspace");+ expect(getListModelsResult).toHaveBeenLastCalledWith("rt-1", "req-1", "new-workspace");+ const refresh = refreshRuntimeModels(client, "rt-1", "new-workspace");+ await vi.advanceTimersByTimeAsync(500);+ await refresh;+ expect(initiateListModels).toHaveBeenLastCalledWith("rt-1", { force: true }, "new-workspace");+ expect(getListModelsResult).toHaveBeenLastCalledWith("rt-1", "req-1", "new-workspace");+ expect(client.getQueryData(runtimeModelsKeys.forRuntime("rt-1"))).toMatchObject({ models: catalog });+ } finally {+ client.clear();+ vi.useRealTimers();+ }+ });+});diff --git a/packages/core/runtimes/models.ts b/packages/core/runtimes/models.tsindex 30472ef8fe..f068edb4aa 100644--- a/packages/core/runtimes/models.ts+++ b/packages/core/runtimes/models.ts@@ -67,12 +67,13 @@ export const MODELS_GC_TIME_MS = 30 * 60_000;// window past what the server itself promises.export async function resolveRuntimeModels(runtimeId: string,- options: { force?: boolean } = {},+ options: { force?: boolean; workspaceSlug?: string } = {},): Promise<RuntimeModelsResult> {- const initial =- options.force === true- ? await api.initiateListModels(runtimeId, { force: true })- : await api.initiateListModels(runtimeId);+ const initial = await api.initiateListModels(+ runtimeId,+ options.force === true ? { force: true } : undefined,+ options.workspaceSlug,+ );const start = Date.now();let current = initial;while (current.status === "pending" || current.status === "running") {@@ -80,7 +81,11 @@ export async function resolveRuntimeModels(throw new Error("model discovery timed out");}await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));- current = await api.getListModelsResult(runtimeId, initial.id);+ current = await api.getListModelsResult(+ runtimeId,+ initial.id,+ options.workspaceSlug,+ );}// Only an explicit `completed` is a catalog. Anything else — failed, timeout,// or a status this client does not know (newer server, or a response that fell@@ -119,12 +124,15 @@ export function staleTimeFor(data: RuntimeModelsResult | undefined): number {return data.cached ? 0 : LIVE_MODELS_STALE_TIME_MS;}-export function runtimeModelsOptions(runtimeId: string | null | undefined) {+export function runtimeModelsOptions(+ runtimeId: string | null | undefined,+ workspaceSlug?: string,+) {return queryOptions({queryKey: runtimeId? runtimeModelsKeys.forRuntime(runtimeId): runtimeModelsKeys.all(),- queryFn: () => resolveRuntimeModels(runtimeId as string),+ queryFn: () => resolveRuntimeModels(runtimeId as string, { workspaceSlug }),enabled: Boolean(runtimeId),staleTime: (query) => staleTimeFor(query.state.data),gcTime: MODELS_GC_TIME_MS,@@ -139,10 +147,11 @@ export function runtimeModelsOptions(runtimeId: string | null | undefined) {export function refreshRuntimeModels(queryClient: QueryClient,runtimeId: string,+ workspaceSlug?: string,): Promise<RuntimeModelsResult> {return queryClient.fetchQuery({- ...runtimeModelsOptions(runtimeId),- queryFn: () => resolveRuntimeModels(runtimeId, { force: true }),+ ...runtimeModelsOptions(runtimeId, workspaceSlug),+ queryFn: () => resolveRuntimeModels(runtimeId, { force: true, workspaceSlug }),staleTime: 0,});}diff --git a/packages/views/agents/components/agent-detail-inspector.runtime-access.test.tsx b/packages/views/agents/components/agent-detail-inspector.runtime-access.test.tsxindex 0e84ce6046..5177cfd786 100644--- a/packages/views/agents/components/agent-detail-inspector.runtime-access.test.tsx+++ b/packages/views/agents/components/agent-detail-inspector.runtime-access.test.tsx@@ -115,7 +115,7 @@ describe("AgentDetailInspector runtime access", () => {renderInspector(privateRuntime.owner_id);await waitFor(() => {- expect(mockInitiateListModels).toHaveBeenCalledWith(privateRuntime.id);+ expect(mockInitiateListModels).toHaveBeenCalledWith(privateRuntime.id, undefined, undefined);});});});diff --git a/packages/views/agents/components/model-dropdown.test.tsx b/packages/views/agents/components/model-dropdown.test.tsxindex 722a70797d..dc88be1380 100644--- a/packages/views/agents/components/model-dropdown.test.tsx+++ b/packages/views/agents/components/model-dropdown.test.tsx@@ -132,7 +132,7 @@ describe("ModelDropdown", () => {});it("offers an explicit refresh that requests the runtime's live catalog", async () => {- const { container } = renderDropdown();+ const { container } = renderDropdown({ workspaceSlug: "new-workspace" });openDropdown(container);await screen.findByText("GPT-5.6 Sol");@@ -143,6 +143,7 @@ describe("ModelDropdown", () => {expect(mockRefreshRuntimeModels).toHaveBeenCalledWith(expect.any(QueryClient),"rt-codex",+ "new-workspace",);});diff --git a/packages/views/agents/components/model-dropdown.tsx b/packages/views/agents/components/model-dropdown.tsxindex ef35fba5a3..e420d210f7 100644--- a/packages/views/agents/components/model-dropdown.tsx+++ b/packages/views/agents/components/model-dropdown.tsx@@ -34,6 +34,7 @@ import { ModelSearchHeader } from "./model-search-header";// needs when their runtime could not enumerate anything (MUL-6606).export function ModelDropdown({runtimeId,+ workspaceSlug,runtimeOnline,value,onChange,@@ -41,6 +42,8 @@ export function ModelDropdown({disabled,}: {runtimeId: string | null;+ /** Target workspace when rendered before a workspace route is active. */+ workspaceSlug?: string;runtimeOnline: boolean;value: string;onChange: (value: string) => void;@@ -54,7 +57,7 @@ export function ModelDropdown({const [search, setSearch] = useState("");const modelsQuery = useQuery(- runtimeModelsOptions(runtimeOnline ? runtimeId : null),+ runtimeModelsOptions(runtimeOnline ? runtimeId : null, workspaceSlug),);const supported = modelsQuery.data?.supported ?? true;@@ -116,7 +119,7 @@ export function ModelDropdown({const refresh = () => {if (!runtimeId || !runtimeOnline) return;- void refreshRuntimeModels(queryClient, runtimeId).catch(() => {+ void refreshRuntimeModels(queryClient, runtimeId, workspaceSlug).catch(() => {// React Query owns the error state rendered below. Swallow the returned// promise rejection so a failed manual refresh is not also unhandled.});diff --git a/packages/views/onboarding/steps/step-platform-fork.test.tsx b/packages/views/onboarding/steps/step-platform-fork.test.tsxindex 667bef7ca1..cc986a045a 100644--- a/packages/views/onboarding/steps/step-platform-fork.test.tsx+++ b/packages/views/onboarding/steps/step-platform-fork.test.tsx@@ -1,3 +1,4 @@+import { api } from "@multica/core/api";import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";import { act, cleanup, fireEvent, render, screen, within } from "@testing-library/react";import userEvent from "@testing-library/user-event";@@ -8,7 +9,13 @@ import { configStore } from "@multica/core/config";import enCommon from "../../locales/en/common.json";import enOnboarding from "../../locales/en/onboarding.json";-const TEST_RESOURCES = { en: { common: enCommon, onboarding: enOnboarding } };+import enAgents from "../../locales/en/agents.json";+vi.mock("@multica/core/api", async (importOriginal) => ({+ ...await importOriginal<typeof import("@multica/core/api")>(),+ api: { initiateListModels: vi.fn() },+}));++const TEST_RESOURCES = { en: { common: enCommon, onboarding: enOnboarding, agents: enAgents } };const mocks = vi.hoisted(() => ({pickerState: {@@ -80,6 +87,32 @@ function resetPicker(patch: Partial<typeof mocks.pickerState> = {}) {}describe("StepPlatformFork", () => {+ it("passes the onboarding workspace through the model chooser", async () => {+ const initiate = vi.spyOn(api, "initiateListModels").mockResolvedValue({+ id: "request-1", runtime_id: "rt_1", status: "completed", models: [],+ supported: true, created_at: "2026-10-30T00:00:00Z", updated_at: "2026-10-30T00:00:00Z",+ });+ const rt = makeRuntime();+ mocks.pickerState.runtimes = [rt];+ mocks.pickerState.selected = rt;+ mocks.pickerState.selectedId = rt.id;+ mocks.pickerState.hasRuntimes = true;+ renderFork({ wsSlug: "new-workspace" });+ await userEvent.click(screen.getByRole("button", { name: /show steps/i }));+ expect(initiate).toHaveBeenCalledWith(rt.id, undefined, "new-workspace");+ initiate.mockRestore();+ });++ it("shows one computer for six runtimes on the same daemon", async () => {+ resetPicker({+ runtimes: Array.from({ length: 6 }, (_, i) => makeRuntime({ id: `rt-${i}`, daemon_id: "daemon-1" })),+ hasRuntimes: true,+ });+ renderFork();+ await userEvent.click(screen.getByRole("button", { name: /show steps/i }));+ expect(screen.getByText("1 computer connected")).toBeInTheDocument();+ });+beforeEach(() => {configStore.getState().setDaemonConfig({ daemonSetupTarget: "cloud" });resetPicker();diff --git a/packages/views/onboarding/steps/step-platform-fork.tsx b/packages/views/onboarding/steps/step-platform-fork.tsxindex 700b90b523..28cc2a2e25 100644--- a/packages/views/onboarding/steps/step-platform-fork.tsx+++ b/packages/views/onboarding/steps/step-platform-fork.tsx@@ -24,6 +24,7 @@ import {MikaRuntimeChoice,type MikaRuntimeSelection,} from "../../runtimes/components/mika-runtime-choice";+import { countRuntimeMachines } from "../../runtimes/components/runtime-machines";import { useRuntimePicker } from "../components/use-runtime-picker";import { useT } from "../../i18n";@@ -163,6 +164,7 @@ export function StepPlatformFork({</StepFooter><CliInstallDialog+ workspaceSlug={wsSlug}open={dialog === "cli"}onClose={() => setDialog(null)}onConnect={handleCliConnect}@@ -279,6 +281,7 @@ function ForkAlt({* closes the dialog and fires the parent's `onConnect`.*/function CliInstallDialog({+ workspaceSlug,open,onClose,onConnect,@@ -291,6 +294,7 @@ function CliInstallDialog({connecting,cliInstructions,}: {+ workspaceSlug?: string;open: boolean;onClose: () => void;onConnect: () => void | Promise<void>;@@ -319,13 +323,14 @@ function CliInstallDialog({<div className="flex items-center gap-2 pt-1 text-body"><div className="h-2 w-2 rounded-full bg-success" /><span className="font-medium">- {t(($) => $.step_platform.runtimes_connected, { count: runtimes.length })}+ {t(($) => $.step_platform.runtimes_connected, { count: countRuntimeMachines(runtimes) })}</span></div>{/* Cap the runtime list at ~4 rows visible, scroll the rest.Keeps the commands above always reachable even whena user has many machines registered. */}<MikaRuntimeChoice+ workspaceSlug={workspaceSlug}layout="list"runtimes={runtimes}value={choice}diff --git a/packages/views/onboarding/steps/step-runtime-connect.test.tsx b/packages/views/onboarding/steps/step-runtime-connect.test.tsxindex 58e8a90a6f..2bbdf8e004 100644--- a/packages/views/onboarding/steps/step-runtime-connect.test.tsx+++ b/packages/views/onboarding/steps/step-runtime-connect.test.tsx@@ -1,3 +1,4 @@+import { api } from "@multica/core/api";import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";import { act, render, screen } from "@testing-library/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";@@ -6,7 +7,13 @@ import { I18nProvider } from "@multica/core/i18n/react";import enCommon from "../../locales/en/common.json";import enOnboarding from "../../locales/en/onboarding.json";-const TEST_RESOURCES = { en: { common: enCommon, onboarding: enOnboarding } };+import enAgents from "../../locales/en/agents.json";+vi.mock("@multica/core/api", async (importOriginal) => ({+ ...await importOriginal<typeof import("@multica/core/api")>(),+ api: { initiateListModels: vi.fn() },+}));++const TEST_RESOURCES = { en: { common: enCommon, onboarding: enOnboarding, agents: enAgents } };// Drive the runtime picker via a hoisted mock so the step renders without a// live daemon. (The onboarding_runtime_detected PostHog event this file used@@ -37,7 +44,7 @@ function makeRuntime(overrides: Partial<AgentRuntime> = {}): AgentRuntime {} as AgentRuntime;}-function renderStep(props: { runtimesPending?: boolean } = {}) {+function renderStep(props: { runtimesPending?: boolean; wsSlug?: string } = {}) {const onNext = vi.fn();const qc = new QueryClient({defaultOptions: { queries: { retry: false } },@@ -47,6 +54,7 @@ function renderStep(props: { runtimesPending?: boolean } = {}) {<I18nProvider locale="en" resources={TEST_RESOURCES}><StepRuntimeConnectwsId="ws_test"+ wsSlug={props.wsSlug}onNext={onNext}runtimesPending={props.runtimesPending}/>@@ -57,6 +65,22 @@ function renderStep(props: { runtimesPending?: boolean } = {}) {}describe("StepRuntimeConnect", () => {+ it("passes the onboarding workspace through the model chooser", async () => {+ const initiate = vi.spyOn(api, "initiateListModels").mockResolvedValue({+ id: "request-1", runtime_id: "rt_1", status: "completed", models: [],+ supported: true, created_at: "2026-10-30T00:00:00Z", updated_at: "2026-10-30T00:00:00Z",+ });+ const rt = makeRuntime();+ mocks.pickerState.runtimes = [rt];+ mocks.pickerState.selected = rt;+ mocks.pickerState.selectedId = rt.id;+ mocks.pickerState.hasRuntimes = true;+ renderStep({ wsSlug: "new-workspace" });+ await act(async () => { await vi.advanceTimersByTimeAsync(0); });+ expect(initiate).toHaveBeenCalledWith(rt.id, undefined, "new-workspace");+ initiate.mockRestore();+ });+beforeEach(() => {mocks.pickerState.runtimes = [];mocks.pickerState.selected = null;diff --git a/packages/views/onboarding/steps/step-runtime-connect.tsx b/packages/views/onboarding/steps/step-runtime-connect.tsxindex cab42fb3d0..ec61d562f0 100644--- a/packages/views/onboarding/steps/step-runtime-connect.tsx+++ b/packages/views/onboarding/steps/step-runtime-connect.tsx@@ -70,6 +70,7 @@ export function StepRuntimeConnect({return (<FancyView+ wsSlug={wsSlug}wsId={wsId}runtimes={runtimes}selected={selected}@@ -97,6 +98,7 @@ const EMPTY_TIMEOUT_MS = 5000;const EMPTY_HARD_TIMEOUT_MS = 20000;function FancyView({+ wsSlug,wsId,runtimes,selected,@@ -108,6 +110,7 @@ function FancyView({currentUserId,}: {wsId: string;+ wsSlug?: string;runtimes: AgentRuntime[];selected: AgentRuntime | null;selectedId: string | null;@@ -238,6 +241,7 @@ function FancyView({{phase === "scanning" && <ScanningView />}{phase === "found" && (<FoundView+ wsSlug={wsSlug}runtimes={runtimes}selectedId={selectedId}onSelect={setSelectedId}@@ -324,6 +328,7 @@ function ScanningView() {}function FoundView({+ wsSlug,runtimes,selectedId,onSelect,@@ -335,6 +340,7 @@ function FoundView({currentUserId,}: {runtimes: AgentRuntime[];+ wsSlug?: string;selectedId: string | null;onSelect: (id: string) => void;onlineCount: number;@@ -385,6 +391,7 @@ function FoundView({<div className="mt-6 flex flex-col gap-4"><MikaRuntimeChoice+ workspaceSlug={wsSlug}runtimes={runtimes}currentUserId={currentUserId}value={{ runtimeId: selectedId ?? "", model }}diff --git a/packages/views/runtimes/components/mika-runtime-choice.tsx b/packages/views/runtimes/components/mika-runtime-choice.tsxindex be3d19fce7..4c4f05478d 100644--- a/packages/views/runtimes/components/mika-runtime-choice.tsx+++ b/packages/views/runtimes/components/mika-runtime-choice.tsx@@ -27,6 +27,7 @@ export interface MikaRuntimeSelection {*/export function MikaRuntimeChoice({runtimes,+ workspaceSlug,runtimesLoading,currentUserId = null,value,@@ -35,6 +36,7 @@ export function MikaRuntimeChoice({layout = "dropdown",}: {runtimes: AgentRuntime[];+ workspaceSlug?: string;runtimesLoading?: boolean;/** Only used by the dropdown layout, to label runtime owners. */currentUserId?: string | null;@@ -82,6 +84,7 @@ export function MikaRuntimeChoice({/>)}<ModelDropdown+ workspaceSlug={workspaceSlug}runtimeId={value.runtimeId || null}runtimeOnline={selected?.status === "online"}value={value.model}diff --git a/packages/views/runtimes/components/runtime-machines.test.ts b/packages/views/runtimes/components/runtime-machines.test.tsindex 79a91581b2..28e714e426 100644--- a/packages/views/runtimes/components/runtime-machines.test.ts+++ b/packages/views/runtimes/components/runtime-machines.test.ts@@ -4,6 +4,7 @@ import { describe, expect, it } from "vitest";import type { AgentRuntime } from "@multica/core/types";import {buildRuntimeMachines,+ countRuntimeMachines,filterRuntimeMachines,runtimeMachineCounts,runtimeRowLabel,@@ -385,6 +386,31 @@ describe("runtime machine grouping", () => {});});+describe("countRuntimeMachines", () => {+ it("matches the machine grouping", () => {+ const cases: AgentRuntime[][] = [+ [],+ Array.from({ length: 6 }, (_, i) => makeRuntime({ id: `rt-${i}` })),+ [+ makeRuntime({ id: "rt-1", daemon_id: "daemon-1" }),+ makeRuntime({ id: "rt-2", daemon_id: "daemon-2" }),+ makeRuntime({ id: "rt-3", daemon_id: "daemon-2" }),+ ],+ [+ makeRuntime({ id: "rt-legacy-claude", daemon_id: null, name: "Claude (macbook)", device_info: "" }),+ makeRuntime({ id: "rt-legacy-codex", daemon_id: null, name: "Codex (macbook)", device_info: "" }),+ makeRuntime({ id: "rt-unnamed", daemon_id: null, name: "Claude", device_info: "" }),+ ],+ ];+ expect(cases.map(countRuntimeMachines)).toEqual([0, 1, 2, 2]);+ for (const runtimes of cases) {+ expect(countRuntimeMachines(runtimes)).toBe(+ buildRuntimeMachines(runtimes, { now: NOW }).length,+ );+ }+ });+});+describe("splitRuntimeName", () => {it("separates daemon host suffix from provider name", () => {expect(splitRuntimeName("Claude (build-server-01)")).toEqual({diff --git a/packages/views/runtimes/components/runtime-machines.ts b/packages/views/runtimes/components/runtime-machines.tsindex 9c20430375..e43c8893b9 100644--- a/packages/views/runtimes/components/runtime-machines.ts+++ b/packages/views/runtimes/components/runtime-machines.ts@@ -180,6 +180,11 @@ export function filterRuntimeMachines(});}+/** Number of machines `buildRuntimeMachines` would group these runtimes into. */+export function countRuntimeMachines(runtimes: AgentRuntime[]): number {+ return new Set(runtimes.map(runtimeMachineId)).size;+}+export function runtimeMachineCounts(machines: RuntimeMachine[]): {all: number;online: number;