mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Focus agent live summaries on running agents
This commit is contained in:
parent
21d9b466a8
commit
a009ae4dfa
3 changed files with 20 additions and 31 deletions
|
|
@ -5,7 +5,6 @@ import { agentActivitySummaryLabel, agentMessagePreview } from "./labels";
|
|||
import { classifyExecutionState } from "./state";
|
||||
|
||||
const ACTIVE_AGENT_PREVIEW_LIMIT = 96;
|
||||
const ACTIVE_AGENT_PREVIEW_COUNT = 3;
|
||||
type AgentRunState = "running" | "completed" | "failed";
|
||||
type CollabAgentToolCallItem = Extract<ThreadItem, { type: "collabAgentToolCall" }>;
|
||||
|
||||
|
|
@ -60,13 +59,14 @@ export function activeAgentRunSummary(items: readonly DisplayItem[], activeTurnI
|
|||
|
||||
if (summary.running === 0 && summary.failed === 0) return null;
|
||||
|
||||
const visibleAgents = agents.sort(compareActiveAgentStates).slice(0, ACTIVE_AGENT_PREVIEW_COUNT);
|
||||
summary.agents = visibleAgents.map((agent) => ({
|
||||
threadId: agent.threadId,
|
||||
status: agent.status,
|
||||
messagePreview: agentMessagePreview(agent.message, ACTIVE_AGENT_PREVIEW_LIMIT),
|
||||
}));
|
||||
summary.additionalAgents = Math.max(0, agents.length - visibleAgents.length);
|
||||
summary.agents = agents
|
||||
.filter((agent) => agentRunState(agent.status) === "running")
|
||||
.sort((a, b) => a.threadId.localeCompare(b.threadId))
|
||||
.map((agent) => ({
|
||||
threadId: agent.threadId,
|
||||
status: agent.status,
|
||||
messagePreview: agentMessagePreview(agent.message, ACTIVE_AGENT_PREVIEW_LIMIT),
|
||||
}));
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
|
@ -96,15 +96,3 @@ function collabAgentExecutionState(status: string, receiverThreadIds: string[],
|
|||
function agentRunState(status: string): AgentRunState {
|
||||
return classifyExecutionState({ status }) ?? "running";
|
||||
}
|
||||
|
||||
function compareActiveAgentStates(a: AgentStateDisplay, b: AgentStateDisplay): number {
|
||||
const stateDiff = agentRunStatePriority(agentRunState(a.status)) - agentRunStatePriority(agentRunState(b.status));
|
||||
if (stateDiff !== 0) return stateDiff;
|
||||
return a.threadId.localeCompare(b.threadId);
|
||||
}
|
||||
|
||||
function agentRunStatePriority(state: AgentRunState): number {
|
||||
if (state === "failed") return 0;
|
||||
if (state === "running") return 1;
|
||||
return 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1068,11 +1068,7 @@ describe("display block grouping keeps work logs subordinate to conversation mes
|
|||
running: 1,
|
||||
completed: 1,
|
||||
failed: 1,
|
||||
agents: [
|
||||
{ threadId: "failed", status: "errored", messagePreview: null },
|
||||
{ threadId: "running", status: "running", messagePreview: null },
|
||||
{ threadId: "done", status: "completed", messagePreview: null },
|
||||
],
|
||||
agents: [{ threadId: "running", status: "running", messagePreview: null }],
|
||||
additionalAgents: 0,
|
||||
});
|
||||
expect(activeAgentRunSummary(items, null)).toBeNull();
|
||||
|
|
@ -1104,7 +1100,7 @@ describe("display block grouping keeps work logs subordinate to conversation mes
|
|||
tool: "wait",
|
||||
status: "running",
|
||||
senderThreadId: "parent",
|
||||
receiverThreadIds: ["a", "b", "c"],
|
||||
receiverThreadIds: ["a", "b", "c", "d", "e"],
|
||||
prompt: null,
|
||||
model: null,
|
||||
reasoningEffort: null,
|
||||
|
|
@ -1112,20 +1108,24 @@ describe("display block grouping keeps work logs subordinate to conversation mes
|
|||
{ threadId: "a", status: "running", message: "\n Inspecting renderer tests \nmore details" },
|
||||
{ threadId: "b", status: "failed", message: "Could not reproduce" },
|
||||
{ threadId: "c", status: "running", message: null },
|
||||
{ threadId: "d", status: "running", message: "Reviewing details" },
|
||||
{ threadId: "e", status: "running", message: "Checking scroll behavior" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
expect(activeAgentRunSummary(items, "t1")).toMatchObject({
|
||||
running: 3,
|
||||
running: 5,
|
||||
completed: 0,
|
||||
failed: 1,
|
||||
agents: [
|
||||
{ threadId: "b", status: "failed", messagePreview: "Could not reproduce" },
|
||||
{ threadId: "a", status: "running", messagePreview: "Inspecting renderer tests" },
|
||||
{ threadId: "c", status: "running", messagePreview: null },
|
||||
{ threadId: "d", status: "running", messagePreview: "Reviewing details" },
|
||||
{ threadId: "e", status: "running", messagePreview: "Checking scroll behavior" },
|
||||
{ threadId: "fallback-child", status: "inProgress", messagePreview: null },
|
||||
],
|
||||
additionalAgents: 1,
|
||||
additionalAgents: 0,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2159,7 +2159,7 @@ describe("work log renderer decisions", () => {
|
|||
expect(summary.textContent).toContain("agents");
|
||||
expect(summary.textContent).toContain("Agents 1 running, 1 done");
|
||||
expect(summary.textContent).toContain("runningrunning: Inspecting renderer");
|
||||
expect(summary.textContent).toContain("donecompleted");
|
||||
expect(summary.textContent).not.toContain("donecompleted");
|
||||
});
|
||||
|
||||
it("renders the compact live agent summary as a React block", () => {
|
||||
|
|
@ -2300,7 +2300,8 @@ describe("work log renderer decisions", () => {
|
|||
|
||||
expect(summary.classList.contains("codex-panel__execution--failed")).toBe(true);
|
||||
expect(summary.textContent).toContain("Agents 1 failed, 1 running");
|
||||
expect(summary.textContent).toContain("failederrored: Failed");
|
||||
expect(summary.textContent).toContain("runningrunning");
|
||||
expect(summary.textContent).not.toContain("failederrored: Failed");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue