refactor(client-runtime): remove unused subagent selectors (#9992)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-05 00:19:29 -07:00
1 parent da1bebbb11
commit 3bcde91f82
2 files changed
-117

No files matched your search

@@ -5,10 +5,6 @@ import {
foldSubagentActivities,
formatSubagentModelLabel,
formatSubagentTokenCount,
isAgentAttributedToolActivity,
isSubagentActivityKind,
isTimelineBypassActivity,
workflowCardMembers,
} from "./subagentRuntime.ts";
let sequence = 0;
@@ -557,64 +553,6 @@ describe("deriveAgentPanelModel", () => {
});
});
describe("workflowCardMembers", () => {
it("orders by urgency (failed, running, waiting) and reports overflow", () => {
const roster = fold([
activity("task.started", { taskId: "wf-1", taskType: "local_workflow" }),
...[..."abcdefghij"].map((letter, index) =>
activity("task.progress", {
taskId: `wf-1:wf:${index}`,
title: `agent-${letter}`,
status: index === 3 ? "failed" : index < 3 ? "completed" : "running",
...(index === 3 ? { error: "died" } : {}),
parentAgentId: "wf-1",
agentIndex: index,
phaseIndex: 0,
phaseTitle: "Work",
}),
),
]);
const model = deriveAgentPanelModel({ agents: roster });
const { visible, overflow } = workflowCardMembers(model.workflows[0]!, 8);
expect(visible).toHaveLength(8);
expect(overflow).toBe(2);
expect(visible[0]!.status).toBe("failed");
expect(visible.filter((agent) => agent.status === "completed").length).toBeLessThanOrEqual(2);
});
});
describe("timeline predicates", () => {
it("recognizes subagent activity kinds as fold input", () => {
for (const kind of [
"task.started",
"task.progress",
"task.updated",
"task.completed",
"tool.progress",
]) {
expect(isSubagentActivityKind(kind)).toBe(true);
}
expect(isSubagentActivityKind("tool.completed")).toBe(false);
});
it("attributed tool rows are re-homed; unattributed rows stay in the timeline", () => {
expect(isAgentAttributedToolActivity(activity("tool.completed", { agentId: "task-1" }))).toBe(
true,
);
expect(isAgentAttributedToolActivity(activity("tool.completed", {}))).toBe(false);
expect(isAgentAttributedToolActivity(activity("tool.completed", { agentId: " " }))).toBe(
false,
);
});
it("timelineBypass rows never render in the parent chat", () => {
expect(isTimelineBypassActivity(activity("task.progress", { timelineBypass: true }))).toBe(
true,
);
expect(isTimelineBypassActivity(activity("task.progress", {}))).toBe(false);
});
});
describe("formatSubagentTokenCount", () => {
it("formats plain counters", () => {
expect(formatSubagentTokenCount(950)).toBe("950");
@@ -861,61 +861,6 @@ export function deriveAgentPanelModel({
};
}
/**
* Members ordered by urgency for the capped inline workflow card: running and
* failed first, then waiting, then most recently updated.
*/
export function workflowCardMembers(
group: AgentPanelWorkflowGroup,
limit: number,
): { readonly visible: ReadonlyArray<RuntimeSubagent>; readonly overflow: number } {
const all = [...group.phases.flatMap((phase) => phase.members), ...group.unphasedMembers];
const urgency = (agent: RuntimeSubagent): number => {
if (agent.status === "failed") return 0;
if (agent.status === "running") return 1;
if (agent.status === "waiting") return 2;
return 3;
};
const ordered = all
.slice()
.sort((a, b) => urgency(a) - urgency(b) || b.updatedAt.localeCompare(a.updatedAt));
return {
visible: ordered.slice(0, limit),
overflow: Math.max(0, ordered.length - limit),
};
}
/** Kinds the timeline should not render as generic rows (fold input only). */
export function isSubagentActivityKind(kind: string): boolean {
return (
kind === "task.started" ||
kind === "task.progress" ||
kind === "task.updated" ||
kind === "task.completed" ||
kind === "tool.progress"
);
}
/**
* Quiet-timeline guarantee: tool rows attributed to an owning agent belong in
* the Agents surface, not the parent chat. Unattributed rows must stay.
*/
export function isAgentAttributedToolActivity(activity: OrchestrationThreadActivity): boolean {
if (typeof activity.payload !== "object" || activity.payload === null) {
return false;
}
const payload = activity.payload as Record<string, unknown>;
return typeof payload.agentId === "string" && payload.agentId.trim().length > 0;
}
/** Timeline-bypassing synthesized rows (Codex children, workflow members). */
export function isTimelineBypassActivity(activity: OrchestrationThreadActivity): boolean {
if (typeof activity.payload !== "object" || activity.payload === null) {
return false;
}
return (activity.payload as Record<string, unknown>).timelineBypass === true;
}
/**
* Compact model chip text: strips vendor prefixes/date-or-context suffixes
* ("claude-sonnet-5[1m]" → "sonnet-5[1m]", "claude-opus-4-20250514" →