Skip to content

Commit c84be87

Browse files
committed
Surface live workflow agent activity
1 parent 0a6bd35 commit c84be87

14 files changed

Lines changed: 663 additions & 76 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ from Codex or from the CLI.
4343
- `release-diff-review`: release-blocker review against a branch or diff.
4444
- `security-auth-review`: auth, permission, injection, secret, sandbox, and MCP
4545
boundary review.
46-
- Live dashboard with phases, agent rows, token/tool/time metrics, detail view,
47-
pause/resume/stop/restart/save controls, and final report path.
46+
- Live dashboard with phases, agent rows, token/tool/time metrics, recent
47+
worker activity, detail view, pause/resume/stop/restart/save controls, and
48+
final report path. Token totals show as pending until Codex emits usage
49+
metadata; command/tool/message/stderr activity updates as events arrive.
4850
- Workflow definitions can explicitly request up to 64 concurrent workers and
4951
2000 total agents.
5052
- Durable run state under `${CODEX_HOME:-~/.codex}/codex-workflows/projects/<project-hash>/runs/<run-id>/`

‎packages/cli/src/dashboard.test.tsx‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,19 @@ const fixture: RunSummary = {
5151
attempts: 1,
5252
startedAt: new Date(Date.now() - 2 * 60 * 1000).toISOString(),
5353
lastActivityAt: new Date(Date.now() - 15 * 1000).toISOString(),
54-
lastMessage: "command_execution"
54+
lastMessage: "completed: command rg",
55+
activity: [
56+
{
57+
at: new Date(Date.now() - 45 * 1000).toISOString(),
58+
kind: "command",
59+
text: "started: command rg --files"
60+
},
61+
{
62+
at: new Date(Date.now() - 15 * 1000).toISOString(),
63+
kind: "message",
64+
text: "completed: agent_message {\"findings\":[]}"
65+
}
66+
]
5567
}
5668
],
5769
totals: {
@@ -85,6 +97,7 @@ describe("DashboardFrame", () => {
8597
);
8698
expect(lastFrame()).toContain("tok pending");
8799
expect(lastFrame()).toContain("idle");
88-
expect(lastFrame()).toContain("command_execution");
100+
expect(lastFrame()).toContain("started: command");
101+
expect(lastFrame()).toContain("agent_message");
89102
});
90103
});

‎packages/cli/src/dashboard.tsx‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ const formatActivity = (at?: string) => {
6868
return `idle ${formatDuration(Math.max(0, Date.now() - new Date(at).getTime()))}`;
6969
};
7070

71+
const formatActivityLine = (activity: NonNullable<AgentSummary["activity"]>[number]) => {
72+
const age = formatDuration(Math.max(0, Date.now() - new Date(activity.at).getTime()));
73+
return `${age} ago · ${activity.kind} · ${activity.text}`;
74+
};
75+
7176
export function DashboardFrame({
7277
summary,
7378
width,
@@ -121,6 +126,10 @@ export function DashboardFrame({
121126
.map((line) => line.replace(/^#{1,6}\s*/, "").replace(/^\s*[-*]\s*/, "").trim())
122127
.filter(Boolean)
123128
.slice(detailOffset, detailOffset + detailLineBudget);
129+
const activityLineBudget = Math.max(0, detailLineBudget - 1);
130+
const activityLines = selectedAgent?.activity
131+
?.slice(-activityLineBudget)
132+
.map(formatActivityLine);
124133

125134
return (
126135
<Box flexDirection="column" width={width}>
@@ -211,6 +220,22 @@ export function DashboardFrame({
211220
{truncateMiddle(line, width - 4)}
212221
</Text>
213222
))
223+
) : activityLines && activityLines.length > 0 ? (
224+
<>
225+
<Text color="gray">
226+
{truncateMiddle(
227+
`${selectedAgent.status === "running" ? "Agent is running" : selectedAgent.status}. ${formatActivity(
228+
selectedAgent.lastActivityAt ?? selectedAgent.startedAt
229+
)}. ${formatAgentTokens(selectedAgent)}.`,
230+
width - 4
231+
)}
232+
</Text>
233+
{activityLines.map((line) => (
234+
<Text key={line} color="gray">
235+
{truncateMiddle(line, width - 4)}
236+
</Text>
237+
))}
238+
</>
214239
) : (
215240
<>
216241
<Text color="gray">

‎packages/codex-adapter/src/index.test.ts‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ describe("SimulatedCodexAdapter", () => {
3333
expectedTools: 3,
3434
durationMs: 1
3535
},
36-
(event) => progress.push(event)
36+
(event) => {
37+
progress.push(event);
38+
}
3739
);
3840

3941
expect(progress.length).toBeGreaterThan(0);
@@ -84,7 +86,9 @@ describe("SimulatedCodexAdapter", () => {
8486
fakeCodex,
8587
[
8688
"#!/bin/sh",
87-
"echo '{\"type\":\"item.completed\",\"item\":{\"type\":\"command_execution\"}}'",
89+
"echo 'worker warning' >&2",
90+
"echo '{\"type\":\"item.started\",\"item\":{\"type\":\"command_execution\",\"command\":\"rg --files\"}}'",
91+
"echo '{\"type\":\"item.completed\",\"item\":{\"type\":\"command_execution\",\"command\":\"rg --files\",\"exit_code\":0}}'",
8892
"echo '{\"type\":\"item.completed\",\"item\":{\"type\":\"agent_message\",\"text\":\"{\\\\\"findings\\\\\":[]}\"}}'",
8993
"echo '{\"type\":\"turn.completed\",\"usage\":{\"input_tokens\":10,\"output_tokens\":4,\"reasoning_output_tokens\":6}}'",
9094
"exit 0",
@@ -104,14 +108,31 @@ describe("SimulatedCodexAdapter", () => {
104108
cwd: root,
105109
sandbox: "read-only"
106110
},
107-
(event) => progress.push(event)
111+
(event) => {
112+
progress.push(event);
113+
}
108114
);
109115

110116
expect(result.output).toBe('{"findings":[]}');
111117
expect(result.tokens).toBe(20);
112118
expect(result.tools).toBe(1);
113119
expect(progress).toContainEqual(expect.objectContaining({ tokens: 20 }));
114120
expect(progress).toContainEqual(expect.objectContaining({ tools: 1 }));
121+
expect(progress).toContainEqual(
122+
expect.objectContaining({
123+
activity: expect.objectContaining({ kind: "command", text: expect.stringContaining("rg --files") })
124+
})
125+
);
126+
expect(progress).toContainEqual(
127+
expect.objectContaining({
128+
activity: expect.objectContaining({ kind: "message", text: expect.stringContaining("agent_message") })
129+
})
130+
);
131+
expect(progress).toContainEqual(
132+
expect.objectContaining({
133+
activity: expect.objectContaining({ kind: "stderr", text: "worker warning" })
134+
})
135+
);
115136
});
116137

117138
it("falls back from unavailable SDK launch to exec in auto mode", async () => {

0 commit comments

Comments
 (0)