Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(runtimes): exclude archived agents from counts (#2166)

Thanh Minh0b64f09c1243
diff --git a/packages/views/runtimes/components/runtime-list.test.ts b/packages/views/runtimes/components/runtime-list.test.ts
new file mode 100644
index 0000000000..546e396483
--- /dev/null
+++ b/packages/views/runtimes/components/runtime-list.test.ts
@@ -0,0 +1,73 @@
+import { describe, expect, it } from "vitest";
+import type { Agent, AgentTask } from "@multica/core/types";
+import { buildWorkloadIndex } from "./runtime-list";
+
+function makeAgent(overrides: Partial<Agent> = {}): Agent {
+ return {
+ id: "agent-1",
+ workspace_id: "ws-1",
+ runtime_id: "runtime-1",
+ name: "Agent",
+ description: "",
+ instructions: "",
+ avatar_url: null,
+ runtime_mode: "local",
+ runtime_config: {},
+ custom_env: {},
+ custom_args: [],
+ custom_env_redacted: false,
+ visibility: "private",
+ status: "idle",
+ max_concurrent_tasks: 1,
+ model: "gpt-5.4",
+ owner_id: "user-1",
+ skills: [],
+ created_at: "2026-01-01T00:00:00Z",
+ updated_at: "2026-01-01T00:00:00Z",
+ archived_at: null,
+ archived_by: null,
+ ...overrides,
+ };
+}
+
+function makeTask(overrides: Partial<AgentTask> = {}): AgentTask {
+ return {
+ id: "task-1",
+ agent_id: "agent-1",
+ issue_id: "issue-1",
+ status: "running",
+ priority: 1,
+ dispatched_at: null,
+ started_at: null,
+ completed_at: null,
+ result: null,
+ error: null,
+ created_at: "2026-01-01T00:00:00Z",
+ runtime_id: "runtime-1",
+ attempt: 1,
+ ...overrides,
+ };
+}
+
+describe("buildWorkloadIndex", () => {
+ it("excludes archived agents from runtime agent counts and workload", () => {
+ const activeAgent = makeAgent({ id: "active-agent" });
+ const archivedAgent = makeAgent({
+ id: "archived-agent",
+ archived_at: "2026-01-02T00:00:00Z",
+ });
+
+ const tasks = [
+ makeTask({ id: "active-task", agent_id: activeAgent.id, status: "running" }),
+ makeTask({ id: "archived-task", agent_id: archivedAgent.id, status: "queued" }),
+ ];
+
+ const workload = buildWorkloadIndex([activeAgent, archivedAgent], tasks).get("runtime-1");
+
+ expect(workload).toEqual({
+ agentIds: [activeAgent.id],
+ runningCount: 1,
+ queuedCount: 0,
+ });
+ });
+});
diff --git a/packages/views/runtimes/components/runtime-list.tsx b/packages/views/runtimes/components/runtime-list.tsx
index 37733e6b44..c63a8336e5 100644
--- a/packages/views/runtimes/components/runtime-list.tsx
+++ b/packages/views/runtimes/components/runtime-list.tsx
@@ -39,7 +39,7 @@ const EMPTY_WORKLOAD: RuntimeWorkload = {
// the avatar stack; .length doubles as the agent count) plus task counts
// split by status. Built once per render off the workspace-wide
// agents / agent-task-snapshot caches; filtered locally — no extra requests.
-function buildWorkloadIndex(
+export function buildWorkloadIndex(
agents: Agent[],
tasks: AgentTask[],
): Map<string, RuntimeWorkload> {
@@ -47,7 +47,7 @@ function buildWorkloadIndex(
const agentToRuntime = new Map<string, string>();
for (const a of agents) {
- if (!a.runtime_id) continue;
+ if (!a.runtime_id || a.archived_at) continue;
agentToRuntime.set(a.id, a.runtime_id);
const entry =
result.get(a.runtime_id) ?? {