Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

See what a bot is doing right now: the step, how it is going, and a Now card (#3736)

Milind Soni8eb759455a63
diff --git a/docs/verification/chat-ui.md b/docs/verification/chat-ui.md
index ab995dcc8b..0e2afd98a3 100644
--- a/docs/verification/chat-ui.md
+++ b/docs/verification/chat-ui.md
@@ -224,6 +224,53 @@ checks that the finished reply still moves a following transcript to its end.
pnpm exec vitest run src/state/store.test.ts src/components/ChatView.follow.test.ts
```
+## What a bot is doing right now
+
+While a step runs, the working line names it ("Running scrape.py", "Searching the
+web for “Biber Dammbau”", "Reading linkedin.com"), with the whole command on
+hover. Once the step has run past the quiet notice it adds how it is doing: the
+time since its last output, or what its own processes show ("waiting on the
+network", "busy, no output yet", "idle, no output yet"). A click on the line,
+or Enter on it, unfolds the **Now** card: the current ask's steps, a running
+command's last lines of output and **Open activity**, which opens the Activity
+panel at this run. A second click or Escape folds it. A working bot's sidebar
+row shows the same step in place of its last message.
+
+A scripted call with `hold` stays running until `FAKE_CLAUDE_RELEASE` exists;
+`hold: "busy"`, `"idle"` or `"network"` also keeps a stand-in process that
+burns CPU, sleeps or holds a loopback connection, as the call's command would.
+The quiet-status knobs cross into the fixture, so the sign of life shows in
+seconds:
+
+```sh
+OMB_ACP_QUIET_NOTICE_MS=10000 OMB_ACP_QUIET_TICK_MS=2000 FAKE_CLAUDE_RELEASE=/tmp/release \
+node --experimental-strip-types scripts/control-omb.ts ui launch --tool-calls \
+ '[{"name":"WebSearch","input":{"query":"Biber Dammbau"},"ok":true},
+ {"name":"Bash","input":{"command":"cd ~/biber && python3 scrape.py --pages 40"},"hold":"busy"}]'
+```
+
+Expected after a sent message: `Working · 15s · Running scrape.py · busy, no
+output yet`, the button `What Pepper is doing` with `aria-expanded="false"`,
+and, once clicked, a card listing `Searched the web for “Biber Dammbau”` and
+`Running scrape.py`. Claude Code prints a command's output only when it ends,
+so streamed output needs an engine that sends it: `--engine codex` adds the
+fake Codex app-server, and `FAKE_CODEX_COMMAND`, `FAKE_CODEX_COMMAND_OUTPUT`
+(JSON chunks), `FAKE_CODEX_COMMAND_OUTPUT_MS` and `FAKE_CODEX_COMMAND_GATE`
+script its command. A bot moved to the `codex` instance then shows `last
+output just now` and the command's last two lines in the card.
+
+| Before | After |
+| --- | --- |
+| ![Working · 1m 06s · Running a command](evidence/live-step/before-command-advanced-midnight.jpg) | ![Working · 1m 05s · Running scrape.py · busy, no output yet](evidence/live-step/after-command-advanced-midnight.jpg) |
+
+The checks are `server/step-summary.test.ts` (the words and their redaction),
+`server/harness/live-steps.test.ts` and `server/harness/bus.test.ts` (one path
+for every engine, the sign of life, the output's last lines),
+`server/bot-visibility.test.ts` (a step reaches only someone who may see the
+chat), `src/components/TurnPresence.test.ts`,
+`src/components/ChatView.live-status.test.ts` (the line and the card) and
+`src/components/Sidebar.simple-mode.test.ts` (the sidebar row).
+
## Bot setup and MCP access recipe
`scripts/testing/bot-tools-ui.e2e.test.ts` uses the same full-app launcher and
diff --git a/docs/verification/evidence/live-step/after-command-advanced-daylight.jpg b/docs/verification/evidence/live-step/after-command-advanced-daylight.jpg
new file mode 100644
index 0000000000..2941550044
Binary files /dev/null and b/docs/verification/evidence/live-step/after-command-advanced-daylight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-command-advanced-midnight-de.jpg b/docs/verification/evidence/live-step/after-command-advanced-midnight-de.jpg
new file mode 100644
index 0000000000..3e197d4c41
Binary files /dev/null and b/docs/verification/evidence/live-step/after-command-advanced-midnight-de.jpg differ
diff --git a/docs/verification/evidence/live-step/after-command-advanced-midnight.jpg b/docs/verification/evidence/live-step/after-command-advanced-midnight.jpg
new file mode 100644
index 0000000000..16ec2d1a1c
Binary files /dev/null and b/docs/verification/evidence/live-step/after-command-advanced-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-command-simple-daylight.jpg b/docs/verification/evidence/live-step/after-command-simple-daylight.jpg
new file mode 100644
index 0000000000..ad3fa3d5de
Binary files /dev/null and b/docs/verification/evidence/live-step/after-command-simple-daylight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-command-simple-midnight.jpg b/docs/verification/evidence/live-step/after-command-simple-midnight.jpg
new file mode 100644
index 0000000000..f5dc7345ed
Binary files /dev/null and b/docs/verification/evidence/live-step/after-command-simple-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-now-card-advanced-daylight.jpg b/docs/verification/evidence/live-step/after-now-card-advanced-daylight.jpg
new file mode 100644
index 0000000000..bae47523a4
Binary files /dev/null and b/docs/verification/evidence/live-step/after-now-card-advanced-daylight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-now-card-advanced-midnight.jpg b/docs/verification/evidence/live-step/after-now-card-advanced-midnight.jpg
new file mode 100644
index 0000000000..9c2f85f432
Binary files /dev/null and b/docs/verification/evidence/live-step/after-now-card-advanced-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-now-card-output-advanced-midnight.jpg b/docs/verification/evidence/live-step/after-now-card-output-advanced-midnight.jpg
new file mode 100644
index 0000000000..b6ea50e475
Binary files /dev/null and b/docs/verification/evidence/live-step/after-now-card-output-advanced-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-now-card-output-simple-daylight-de.jpg b/docs/verification/evidence/live-step/after-now-card-output-simple-daylight-de.jpg
new file mode 100644
index 0000000000..d7cada55f3
Binary files /dev/null and b/docs/verification/evidence/live-step/after-now-card-output-simple-daylight-de.jpg differ
diff --git a/docs/verification/evidence/live-step/after-now-card-simple-daylight-de.jpg b/docs/verification/evidence/live-step/after-now-card-simple-daylight-de.jpg
new file mode 100644
index 0000000000..3a9017120d
Binary files /dev/null and b/docs/verification/evidence/live-step/after-now-card-simple-daylight-de.jpg differ
diff --git a/docs/verification/evidence/live-step/after-now-card-simple-midnight.jpg b/docs/verification/evidence/live-step/after-now-card-simple-midnight.jpg
new file mode 100644
index 0000000000..9db7c68632
Binary files /dev/null and b/docs/verification/evidence/live-step/after-now-card-simple-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-open-activity-advanced-midnight.jpg b/docs/verification/evidence/live-step/after-open-activity-advanced-midnight.jpg
new file mode 100644
index 0000000000..8f5108c0b0
Binary files /dev/null and b/docs/verification/evidence/live-step/after-open-activity-advanced-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-page-advanced-midnight.jpg b/docs/verification/evidence/live-step/after-page-advanced-midnight.jpg
new file mode 100644
index 0000000000..d65adf4fcd
Binary files /dev/null and b/docs/verification/evidence/live-step/after-page-advanced-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-web-advanced-midnight.jpg b/docs/verification/evidence/live-step/after-web-advanced-midnight.jpg
new file mode 100644
index 0000000000..31815549d0
Binary files /dev/null and b/docs/verification/evidence/live-step/after-web-advanced-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/after-web-simple-daylight-de.jpg b/docs/verification/evidence/live-step/after-web-simple-daylight-de.jpg
new file mode 100644
index 0000000000..e662a4dabc
Binary files /dev/null and b/docs/verification/evidence/live-step/after-web-simple-daylight-de.jpg differ
diff --git a/docs/verification/evidence/live-step/before-command-advanced-daylight.jpg b/docs/verification/evidence/live-step/before-command-advanced-daylight.jpg
new file mode 100644
index 0000000000..0a804d159d
Binary files /dev/null and b/docs/verification/evidence/live-step/before-command-advanced-daylight.jpg differ
diff --git a/docs/verification/evidence/live-step/before-command-advanced-midnight-de.jpg b/docs/verification/evidence/live-step/before-command-advanced-midnight-de.jpg
new file mode 100644
index 0000000000..a885a64fc1
Binary files /dev/null and b/docs/verification/evidence/live-step/before-command-advanced-midnight-de.jpg differ
diff --git a/docs/verification/evidence/live-step/before-command-advanced-midnight.jpg b/docs/verification/evidence/live-step/before-command-advanced-midnight.jpg
new file mode 100644
index 0000000000..b0bbf3dca0
Binary files /dev/null and b/docs/verification/evidence/live-step/before-command-advanced-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/before-command-simple-daylight.jpg b/docs/verification/evidence/live-step/before-command-simple-daylight.jpg
new file mode 100644
index 0000000000..1dbf345afe
Binary files /dev/null and b/docs/verification/evidence/live-step/before-command-simple-daylight.jpg differ
diff --git a/docs/verification/evidence/live-step/before-command-simple-midnight.jpg b/docs/verification/evidence/live-step/before-command-simple-midnight.jpg
new file mode 100644
index 0000000000..e4272317d6
Binary files /dev/null and b/docs/verification/evidence/live-step/before-command-simple-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/before-page-advanced-midnight.jpg b/docs/verification/evidence/live-step/before-page-advanced-midnight.jpg
new file mode 100644
index 0000000000..7f2152ccda
Binary files /dev/null and b/docs/verification/evidence/live-step/before-page-advanced-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/before-web-advanced-midnight.jpg b/docs/verification/evidence/live-step/before-web-advanced-midnight.jpg
new file mode 100644
index 0000000000..1395d08f29
Binary files /dev/null and b/docs/verification/evidence/live-step/before-web-advanced-midnight.jpg differ
diff --git a/docs/verification/evidence/live-step/before-web-simple-daylight-de.jpg b/docs/verification/evidence/live-step/before-web-simple-daylight-de.jpg
new file mode 100644
index 0000000000..3c904dd9d1
Binary files /dev/null and b/docs/verification/evidence/live-step/before-web-simple-daylight-de.jpg differ
diff --git a/scripts/control-omb.ts b/scripts/control-omb.ts
index a19fdeaa91..6903fc5b72 100644
--- a/scripts/control-omb.ts
+++ b/scripts/control-omb.ts
@@ -34,7 +34,7 @@ export interface ControlOmbDependencies {
}
export const HELP_UI = `renderer (needs a ui launch handle; every verb takes --ui HANDLE, never discovery):
- node --experimental-strip-types scripts/control-omb.ts ui launch [--entry threads] [--tool-calls JSON] [--mode happy]
+ node --experimental-strip-types scripts/control-omb.ts ui launch [--entry threads] [--tool-calls JSON] [--mode happy] [--engine codex]
ui snapshot --ui HANDLE [--interactive]
ui click --ui HANDLE (--ref @eN | --name NAME)
ui type --ui HANDLE (--ref @eN | --name NAME) --text TEXT
@@ -165,7 +165,7 @@ export function verificationServerEnvironment(parentEnv: NodeJS.ProcessEnv, data
// The fake engines' knobs are the one thing a caller may script into the child.
for (const [key, value] of Object.entries(parentEnv)) {
// FAKE_CLAUDE_DUMP stays the launcher's: assertions read fixtureDumpPath.
- if ((key.startsWith("FAKE_CLAUDE_") || key.startsWith("FAKE_CODEX_TEXT_")) && key !== "FAKE_CLAUDE_DUMP" && value) childEnv[key] = value;
+ if ((key.startsWith("FAKE_CLAUDE_") || key.startsWith("FAKE_CODEX_TEXT_") || key.startsWith("FAKE_CODEX_COMMAND")) && key !== "FAKE_CLAUDE_DUMP" && value) childEnv[key] = value;
}
// Enables POST /api/testing/org-library; the route does not exist without it.
if (parentEnv.OMB_TEST_ORG_LIBRARY_KEY) childEnv.OMB_TEST_ORG_LIBRARY_KEY = parentEnv.OMB_TEST_ORG_LIBRARY_KEY;
@@ -211,6 +211,10 @@ export function verificationServerEnvironment(parentEnv: NodeJS.ProcessEnv, data
if (parentEnv.OMB_TEST_STALL_CLOCK === "1") childEnv.OMB_TEST_STALL_CLOCK = "1";
// The first-reply rescue's delay in ms, so a check need not sit through 20 s of silence.
if (/^\d{1,6}$/.test(parentEnv.OMB_FIRST_REPLY_NOTICE_MS ?? "")) childEnv.OMB_FIRST_REPLY_NOTICE_MS = parentEnv.OMB_FIRST_REPLY_NOTICE_MS;
+ // The quiet-status knobs in ms, so a long tool call shows its sign of life without a minute's wait.
+ for (const knob of ["OMB_ACP_QUIET_NOTICE_MS", "OMB_ACP_QUIET_TICK_MS"] as const) {
+ if (/^\d{1,7}$/.test(parentEnv[knob] ?? "")) childEnv[knob] = parentEnv[knob];
+ }
// The UI checks drive this fixture from a real browser, as `pnpm dev` does; OMB_DEV_TRUST_LOCAL_BROWSER=0 tests the sign-in.
if (parentEnv.OMB_DEV_TRUST_LOCAL_BROWSER !== "0") childEnv.OMB_DEV_TRUST_LOCAL_BROWSER = "1";
// Desktop mode: the owner capability the app would hand the server.
diff --git a/scripts/testing/control-omb-ui.ts b/scripts/testing/control-omb-ui.ts
index e22b5ab9ba..a7632e3fab 100644
--- a/scripts/testing/control-omb-ui.ts
+++ b/scripts/testing/control-omb-ui.ts
@@ -424,7 +424,10 @@ export async function launchUi(
io: { stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream } = process,
fixtureOptions: { boatFixtureApi?: string } = {},
): Promise<void> {
- const values = parse("ui launch", args, { entry: { type: "string" }, "tool-calls": { type: "string" }, mode: { type: "string" } });
+ const values = parse("ui launch", args, { entry: { type: "string" }, "tool-calls": { type: "string" }, mode: { type: "string" }, engine: { type: "string" } });
+ if (values.engine !== undefined && values.engine !== "codex") {
+ throw new ControlOmbError(`unknown --engine ${JSON.stringify(values.engine)}`, "the fake Claude CLI always runs; --engine codex adds the fake Codex app-server beside it");
+ }
const entryName = typeof values.entry === "string" ? values.entry : "threads";
if (!Object.hasOwn(ENTRIES, entryName)) {
throw new ControlOmbError(`unknown --entry ${JSON.stringify(entryName)}`, `available entries: ${Object.keys(ENTRIES).join(", ")}`);
@@ -461,7 +464,7 @@ export async function launchUi(
const { binary, chrome } = await ensureUiBrowser(parentEnv, note);
checkpoint();
fixture = await launchVerificationServer({ ...parentEnv, ...fakeEnv }, startup.signal, undefined,
- { binaryPath: binary, executablePath: chrome ?? "" }, undefined, undefined, [], fixtureOptions.boatFixtureApi);
+ { binaryPath: binary, executablePath: chrome ?? "" }, undefined, undefined, values.engine === "codex" ? ["codex"] : [], fixtureOptions.boatFixtureApi);
checkpoint();
const api = fixtureApi(fixture.info.url);
await api("PATCH", "/api/config", { language: "en" });
diff --git a/server/activity.test.ts b/server/activity.test.ts
index c3dc1e20cc..d79eb3177f 100644
--- a/server/activity.test.ts
+++ b/server/activity.test.ts
@@ -130,6 +130,16 @@ describe("readBotActivity", () => {
]);
});
+ it("shows each run's step under it, the words the working line used, with the run's turn to open it at", () => {
+ event("t1", "2026-09-07T09:00:00.000Z", { type: "item.started", itemType: "tool", itemId: "i1", title: "Bash",
+ step: { activity: "command", target: "scrape.py", detail: "cd ~/biber && python3 scrape.py --pages 40" } });
+ event("t1", "2026-09-07T09:01:00.000Z", { type: "item.started", itemType: "tool", itemId: "i2", title: "WebFetch", step: { activity: "fetch", target: "linkedin.com" } });
+ expect(read().map((row) => [row.label, row.summary, row.turnId])).toEqual([
+ ["Fetched a page", "linkedin.com", "turn-1"],
+ ["Ran a command", "cd ~/biber && python3 scrape.py --pages 40", "turn-1"],
+ ]);
+ });
+
it("keeps reused provider item IDs separate across turns, including legacy no-turn events", () => {
for (const [turnId, tool, ok, minute] of [["turn-one", "Read", true, "00"], ["turn-two", "Bash", false, "01"], [undefined, "Edit", true, "02"]] as const) {
event("t1", `2026-09-07T09:${minute}:00.000Z`, { type: "item.started", itemType: "tool", itemId: "item_0", turnId, title: tool });
diff --git a/server/activity.ts b/server/activity.ts
index 902436c29d..72094b42dd 100644
--- a/server/activity.ts
+++ b/server/activity.ts
@@ -193,6 +193,7 @@ function readToolRuns(eventsDir: string, threadId: string): ActivityRow[] {
...(event.turnId ? { turnId: event.turnId } : {}),
// A bridged call reads as the tool it ran, only where the title itself names the agents server.
tool: bridgedCallName(event.title ?? "unknown", event.input, { serverNamed: true }),
+ ...(event.step ? { summary: event.step.detail ?? event.step.target } : {}),
outcome: "running",
}, event.input),
);
diff --git a/server/bot-visibility.test.ts b/server/bot-visibility.test.ts
index 3d7c83c520..e76b30c545 100644
--- a/server/bot-visibility.test.ts
+++ b/server/bot-visibility.test.ts
@@ -411,6 +411,21 @@ describe("a Team Cloud's audiences", () => {
expect(routineRunVisible({ botId: "pub", threadId: "t-pub" }, admin)).toBe(true);
});
+ it("sends what a bot is doing now only to someone who may see that chat, as the Activity panel does", () => {
+ const admin = new VisibleSet(open, openGroups, BEN_ADMIN, undefined, { of: audienceOf, person: BEN_KEY });
+ const ctx: FrameContext = { visible: admin, webhook: () => undefined, freshBot: () => undefined, freshGroup: () => undefined };
+ const seen: StreamSeen = { bots: new Set(open.map((bot) => bot.id)), groups: new Set(["room-pub"]) };
+ const step = (threadId: string) => ({ kind: "runtime", event: { type: "turn.progress", threadId, activity: "command", itemId: "c1",
+ target: "payroll.py", detail: "python3 payroll.py --month 10", quiet: { kind: "busy" }, tail: ["paid 12 of 40"] } });
+ const started = (threadId: string) => ({ kind: "runtime", event: { type: "item.started", itemType: "tool", threadId, itemId: "c1",
+ title: "Bash", step: { activity: "command", target: "payroll.py", detail: "python3 payroll.py --month 10" } } });
+ for (const frame of [step("t-pub-2"), started("t-pub-2"), { kind: "message", threadId: "t-pub-2", message: { tool: { name: "Bash", step: { activity: "command", target: "payroll.py" } } } }]) {
+ expect(frameForMember(frame, ctx, seen), JSON.stringify(frame)).toBeUndefined();
+ }
+ const own = step("t-pub");
+ expect(frameForMember(own, ctx, seen)).toBe(own);
+ });
+
it("finds every conversation a request names: a task in the path, the query and the body", () => {
expect(requestThreadIds("/api/bots/pub/tasks/t-pub-2", new URLSearchParams())).toEqual(["t-pub-2"]);
expect(requestThreadIds("/api/bots/pub/tasks/t-pub-2/title", new URLSearchParams("threadId=t-x"))).toEqual(["t-pub-2", "t-x"]);
diff --git a/server/contracts.ts b/server/contracts.ts
index b169f74505..74b2e8750b 100644
--- a/server/contracts.ts
+++ b/server/contracts.ts
@@ -280,6 +280,8 @@ export interface ProviderAdapter {
* A driver that cannot read an attached image refuses the whole steer. */
steer?(threadId: ThreadId, text: string, images?: readonly TurnImageInput[]): Promise<SteerOutcome>;
hasSession(threadId: ThreadId): boolean;
+ /** The local process running this thread's engine, while there is one: a long tool call's own processes are under it. */
+ enginePid?(threadId: ThreadId): number | undefined;
stopAll(): Promise<void>;
onEvent(listener: RuntimeEventListener): () => void;
/** `ping` sends one tool-less forked request without touching the thread's session; `hold` keeps the live session open until
diff --git a/server/drivers/acp/acp.test.ts b/server/drivers/acp/acp.test.ts
index 2fb8ef6972..027921684a 100644
--- a/server/drivers/acp/acp.test.ts
+++ b/server/drivers/acp/acp.test.ts
@@ -2033,6 +2033,25 @@ describe("ACP turns (fake CLI)", () => {
expect(types.lastIndexOf("turn.progress")).toBeLessThan(types.indexOf("item.completed"));
});
+ it("shows a running tool's output and names the agent process while the tool runs", async () => {
+ const gate = join(scratch, "slow-tool-done");
+ Object.assign(process.env, { FAKE_ACP_TOOL_GATE: gate, FAKE_ACP_TOOL_OUTPUT: "Collecting 12 items\npage 3 of 40" });
+ try {
+ await create(QwenAgentDriver, "slow-tool");
+ await instance.adapter.sendTurn({ threadId: "t-slow-output", text: "go" });
+ expect(await recorder.until(e => e.type === "item.output")).toMatchObject({ itemId: "tc-slow", text: "Collecting 12 items\npage 3 of 40", whole: true });
+ const pid = instance.adapter.enginePid?.("t-slow-output");
+ expect(pid).toEqual(expect.any(Number));
+ expect(() => process.kill(pid!, 0)).not.toThrow();
+ writeFileSync(gate, "done");
+ await recorder.until(e => e.type === "turn.completed");
+ expect(instance.adapter.enginePid?.("t-slow-output")).toBeUndefined();
+ } finally {
+ delete process.env.FAKE_ACP_TOOL_GATE;
+ delete process.env.FAKE_ACP_TOOL_OUTPUT;
+ }
+ });
+
it.each([GrokAgentDriver, QwenAgentDriver])("still fails $driverKind when it goes silent once its tool has finished", async (driver) => {
process.env.OPENMAUS_ACP_PROMPT_IDLE_TIMEOUT_MS = "150";
await create(driver, "stall-after-tool");
diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.ts
index c17a0281d2..0c5237f5bd 100644
--- a/server/drivers/acp/core.ts
+++ b/server/drivers/acp/core.ts
@@ -20,7 +20,7 @@ import { runAcpOneShot } from "./background-text.ts";
import { sanitizeAcpToolMessage } from "./tool-log.ts";
import { stripLeakedSystemHarnessMessages } from "../../../shared/system-message-guard.ts";
import {
- classifyQuiet, DEFAULT_QUIET_NOTICE_MS, describeQuiet, formatQuietLimit, lastSeenPhrase, LogTail, promptIdleTimeoutMs, quietKey, sampleProcessTree,
+ classifyQuiet, describeQuiet, formatQuietLimit, lastSeenPhrase, LogTail, promptIdleTimeoutMs, quietKey, quietNoticeMs, quietTickMs, sampleProcessTree,
type LogSignal, type ProcessSample, type QuietState,
} from "./quiet-status.ts";
import { readSessionReport } from "./session-reports.ts";
@@ -65,7 +65,7 @@ import { engineIdleMs, sessionIdlePolicy } from "../session-idle.ts";
import { classifyError } from "../retry.ts";
import { engineFailureKind, engineFailureMessage, stopCause } from "../engine-errors.ts";
import { narrowsNativeTools, parseToolScope } from "../../../shared/tool-scope.ts";
-import { acpMcpServers, type AcpMcpServer } from "../turn-mcp.ts"; import { acpToolProgress } from "../tool-progress.ts";
+import { acpMcpServers, type AcpMcpServer } from "../turn-mcp.ts"; import { acpToolOutput, acpToolProgress } from "../tool-progress.ts";
import { learnedToolCountLimit, mcpToolBudget, retryUnderToolLimit } from "../../tool-count-limit.ts"; import { instanceEnvNames } from "../../bot-box/env.ts";
/** Failures fixed on the provider account, not by retrying; the reporting process stays pooled. */
@@ -520,8 +520,8 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
});
const startQuietWatch = (threadId: string, session: AcpSession, current: AcpTurn) => {
- const noticeAfterMs = envOr("OMB_ACP_QUIET_NOTICE_MS", DEFAULT_QUIET_NOTICE_MS);
- const tickMs = envOr("OMB_ACP_QUIET_TICK_MS", 15_000);
+ const noticeAfterMs = quietNoticeMs();
+ const tickMs = quietTickMs();
const { sessionId } = session;
const logPath = support.statusLog && sessionId ? support.statusLog.path(session.env, sessionId) : null;
const tail = logPath ? new LogTail(logPath) : null;
@@ -968,7 +968,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
}
}
// A call still running (its kind, file and diff so far) feeds the chat's status line.
- const draft = acpToolProgress(u); if (draft) emit({ ...base(threadId, current.turnId), ...draft });
+ for (const live of [acpToolProgress(u), acpToolOutput(u)]) if (live) emit({ ...base(threadId, current.turnId), ...live });
};
const session: AcpSession = {
@@ -1739,6 +1739,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
return finish(decision.behavior, "user", decision.message, decision.always === true);
},
hasSession: (threadId) => active.has(threadId),
+ enginePid: (threadId) => (active.has(threadId) ? sessions.get(threadId)?.child.pid : undefined),
stopAll: async () => {
for (const { stop } of active.values()) stop();
for (const threadId of Array.from(sessions.keys())) closeSession(threadId, "stopAll");
diff --git a/server/drivers/acp/quiet-status.test.ts b/server/drivers/acp/quiet-status.test.ts
index 5121615320..037af908bd 100644
--- a/server/drivers/acp/quiet-status.test.ts
+++ b/server/drivers/acp/quiet-status.test.ts
@@ -1,3 +1,4 @@
+import { spawn } from "node:child_process";
import { appendFileSync, mkdtempSync, writeFileSync } from "node:fs";
import { createServer } from "node:net";
import { tmpdir } from "node:os";
@@ -6,7 +7,7 @@ import { describe, expect, it } from "vitest";
import { removeTempDir } from "../../testing/cleanup.ts";
import {
- classifyQuiet, describeQuiet, LogTail, parseOpenCodeLogLine, parseQwenLogLine, quietKey, sampleProcessTree, treePids,
+ classifyQuiet, describeQuiet, LogTail, parseOpenCodeLogLine, parseQwenLogLine, quietKey, sampleProcessTree, startedSince, treePids,
} from "./quiet-status.ts";
import { qwenDebugLogPath } from "./qwen.ts";
@@ -146,6 +147,34 @@ describe("process probe", () => {
expect(treePids([{ pid: 2, ppid: 1 }, { pid: 3, ppid: 2 }, { pid: 4, ppid: 9 }], 1)).toEqual([1, 2, 3]);
});
+ it("counts only what a tool call started: never the engine itself, nor the tool servers it started before", () => {
+ const rows = [
+ { pid: 10, ppid: 1, startedAt: 60_200 },
+ { pid: 11, ppid: 10, startedAt: 1_000 },
+ { pid: 12, ppid: 10, startedAt: 60_000 },
+ { pid: 13, ppid: 12, startedAt: 60_500 },
+ { pid: 14, ppid: 10, startedAt: null },
+ { pid: 20, ppid: 1, startedAt: 61_000 },
+ ];
+ expect(startedSince(rows, 10, 61_000), "an engine started for this very turn, as Codex's app-server is, is still not the call").toEqual([12, 13]);
+ expect(startedSince(rows, 10, 90_000)).toEqual([]);
+ });
+
+ it.skipIf(process.platform === "win32")("samples a tool call's own processes, and reads nothing it did not start as unknown", async () => {
+ const since = Date.now();
+ const child = spawn(process.execPath, ["-e", "const t = Date.now(); while (Date.now() - t < 2500) {} setInterval(() => {}, 1000);"], { stdio: "ignore" });
+ try {
+ await new Promise((resolve) => setTimeout(resolve, 2_700));
+ const own = await sampleProcessTree(process.pid, since);
+ // Linux procps prints TIME in whole seconds: 2.5 s of spinning reads at least one even on a busy runner.
+ expect(own.cpuMs).not.toBeNull();
+ expect(own.cpuMs!).toBeGreaterThanOrEqual(1_000);
+ expect(await sampleProcessTree(process.pid, Date.now() + 60_000)).toEqual({ cpuMs: null, connections: null });
+ } finally {
+ child.kill();
+ }
+ });
+
it.skipIf(process.platform === "win32")("counts this process's open connections and CPU", async () => {
const server = createServer(() => {});
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
diff --git a/server/drivers/acp/quiet-status.ts b/server/drivers/acp/quiet-status.ts
index 3e2cc10c4c..fa628e65dd 100644
--- a/server/drivers/acp/quiet-status.ts
+++ b/server/drivers/acp/quiet-status.ts
@@ -3,7 +3,8 @@
// probed from the agent's debug log and its process tree's connections and CPU.
import { execFile } from "node:child_process";
-import { closeSync, fstatSync, openSync, readSync } from "node:fs";
+import { closeSync, existsSync, fstatSync, openSync, readSync } from "node:fs";
+import { join } from "node:path";
import { redactSecretsInText } from "../../redact.ts";
@@ -22,6 +23,15 @@ export const formatQuietLimit = (ms: number): string =>
/** Silence before the first "what is it doing" notice (OMB_ACP_QUIET_NOTICE_MS overrides). */
export const DEFAULT_QUIET_NOTICE_MS = 60_000;
+/** How often a quiet turn or a long tool call is looked at again (OMB_ACP_QUIET_TICK_MS overrides). */
+export const DEFAULT_QUIET_TICK_MS = 15_000;
+
+const knob = (name: string, fallback: number): number => {
+ const ms = Number(process.env[name]);
+ return Number.isFinite(ms) && ms > 0 ? ms : fallback;
+};
+export const quietNoticeMs = (): number => knob("OMB_ACP_QUIET_NOTICE_MS", DEFAULT_QUIET_NOTICE_MS);
+export const quietTickMs = (): number => knob("OMB_ACP_QUIET_TICK_MS", DEFAULT_QUIET_TICK_MS);
export type LogSignal =
| { kind: "retry"; status: number | null; delayMs: number | null; attempt: number | null }
@@ -133,6 +143,19 @@ const run = (file: string, args: string[], timeoutMs = 4_000): Promise<string |
});
});
+// A server can run with a narrowed PATH (a sealed test fixture runs with node's folder alone); ps and lsof are still
+// found where the system keeps them.
+const SYSTEM_DIRS = ["/bin", "/usr/bin", "/usr/sbin", "/sbin"];
+const systemTools = new Map<string, string>();
+const systemTool = (name: string): string => {
+ let path = systemTools.get(name);
+ if (path === undefined) {
+ path = SYSTEM_DIRS.map((dir) => join(dir, name)).find((candidate) => existsSync(candidate)) ?? name;
+ systemTools.set(name, path);
+ }
+ return path;
+};
+
/** `ps` TIME: [[dd-]hh:]mm:ss[.cc] */
function psTimeMs(raw: string): number | null {
const m = /^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+(?:\.\d+)?)$/.exec(raw.trim());
@@ -159,35 +182,53 @@ export function treePids(rows: Array<{ pid: number; ppid: number }>, root: numbe
return out;
}
-async function samplePosix(root: number): Promise<ProcessSample> {
- const table = await run("ps", ["-A", "-o", "pid=,ppid=,time="]);
+/** A process start is read to the second (`ps` etime), so a call's own processes may look this much older than it. */
+const START_SLACK_MS = 2_000;
+
+/** What one tool call is running: the root's descendants that started since the call did, not the root itself. */
+export function startedSince(rows: Array<{ pid: number; ppid: number; startedAt: number | null }>, root: number, since: number): number[] {
+ const startOf = new Map(rows.map((r) => [r.pid, r.startedAt]));
+ return treePids(rows, root).filter((pid) => pid !== root && (startOf.get(pid) ?? -Infinity) >= since - START_SLACK_MS);
+}
+
+async function samplePosix(root: number, since?: number): Promise<ProcessSample> {
+ const table = await run(systemTool("ps"), ["-A", "-o", "pid=,ppid=,time=,etime="]);
if (table === null) return { cpuMs: null, connections: null };
- const rows: Array<{ pid: number; ppid: number; cpuMs: number | null }> = [];
+ const now = Date.now();
+ const rows: Array<{ pid: number; ppid: number; cpuMs: number | null; startedAt: number | null }> = [];
for (const line of table.split("\n")) {
- const [pid, ppid, time] = line.trim().split(/\s+/);
+ const [pid, ppid, time, elapsed] = line.trim().split(/\s+/);
if (!pid || !ppid || !time) continue;
- rows.push({ pid: Number(pid), ppid: Number(ppid), cpuMs: psTimeMs(time) });
+ const age = elapsed ? psTimeMs(elapsed) : null;
+ rows.push({ pid: Number(pid), ppid: Number(ppid), cpuMs: psTimeMs(time), startedAt: age === null ? null : now - age });
}
- const pids = treePids(rows, root);
if (!rows.some((r) => r.pid === root)) return { cpuMs: null, connections: null };
+ const pids = since === undefined ? treePids(rows, root) : startedSince(rows, root, since);
+ if (!pids.length) return { cpuMs: null, connections: null };
let cpuMs = 0;
for (const r of rows) if (pids.includes(r.pid)) cpuMs += r.cpuMs ?? 0;
- const lsof = await run("lsof", ["-nP", "-a", "-p", pids.join(","), "-iTCP", "-sTCP:ESTABLISHED", "-Fn"]);
+ const lsof = await run(systemTool("lsof"), ["-nP", "-a", "-p", pids.join(","), "-iTCP", "-sTCP:ESTABLISHED", "-Fn"]);
// -Fn prints one `n<addr>` line per connection
const connections = lsof === null ? null : lsof.split("\n").filter((l) => l.startsWith("n")).length;
return { cpuMs, connections };
}
-async function sampleWindows(root: number): Promise<ProcessSample> {
+async function sampleWindows(root: number, since?: number): Promise<ProcessSample> {
+ const own = since === undefined ? ""
+ : `$from=[DateTimeOffset]::FromUnixTimeMilliseconds(${Math.floor(since - START_SLACK_MS)}).LocalDateTime;` +
+ `$ids=@($all|Where-Object{($ids -contains $_.ProcessId) -and $_.ProcessId -ne ${root} -and $_.CreationDate -ge $from}|ForEach-Object{$_.ProcessId});` +
+ "if(-not $ids.Count){Write-Output 'none';exit};";
const script =
"$ErrorActionPreference='SilentlyContinue';" +
- "$all=Get-CimInstance Win32_Process|Select-Object ProcessId,ParentProcessId,KernelModeTime,UserModeTime;" +
+ "$all=Get-CimInstance Win32_Process|Select-Object ProcessId,ParentProcessId,KernelModeTime,UserModeTime,CreationDate;" +
`$ids=@(${root});$q=@(${root});` +
"while($q.Count){$p=$q[0];$q=@($q|Select-Object -Skip 1);foreach($c in $all|Where-Object{$_.ParentProcessId -eq $p}){if($ids -notcontains $c.ProcessId){$ids+=$c.ProcessId;$q+=$c.ProcessId}}};" +
+ own +
"$cpu=($all|Where-Object{$ids -contains $_.ProcessId}|ForEach-Object{[double]$_.KernelModeTime+[double]$_.UserModeTime}|Measure-Object -Sum).Sum/10000;" +
"$n=@(Get-NetTCPConnection -State Established|Where-Object{$ids -contains $_.OwningProcess}).Count;" +
"Write-Output \"$cpu $n\"";
const out = await run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], 8_000);
+ if (out?.trim() === "none") return { cpuMs: null, connections: null };
const [cpu, n] = (out ?? "").trim().split(/\s+/);
const cpuMs = Number(cpu);
const connections = Number(n);
@@ -197,9 +238,10 @@ async function sampleWindows(root: number): Promise<ProcessSample> {
};
}
-/** A missing tool or a refused query reads as null (unknown), never as idle. */
-export function sampleProcessTree(pid: number): Promise<ProcessSample> {
- return (process.platform === "win32" ? sampleWindows(pid) : samplePosix(pid))
+/** A missing tool or a refused query reads as null (unknown), never as idle. With `since`, only the processes the tree
+ * started from then on count, without the root: what one tool call is running, not the engine or its tool servers. */
+export function sampleProcessTree(pid: number, since?: number): Promise<ProcessSample> {
+ return (process.platform === "win32" ? sampleWindows(pid, since) : samplePosix(pid, since))
.catch(() => ({ cpuMs: null, connections: null }));
}
diff --git a/server/drivers/claude.test.ts b/server/drivers/claude.test.ts
index 170ce41ce1..87b7862af4 100644
--- a/server/drivers/claude.test.ts
+++ b/server/drivers/claude.test.ts
@@ -591,6 +591,21 @@ describe("ClaudeDriver turns (fake CLI)", () => {
expect(beat).toBeLessThan(types.lastIndexOf("item.completed"));
});
+ it("names the CLI process while a long tool runs, and no process once the turn is over", async () => {
+ const release = join(scratch, "release");
+ await create(undefined, {
+ FAKE_CLAUDE_TOOL_CALLS: JSON.stringify([{ name: "Bash", input: { command: "python3 scrape.py" }, hold: "idle" }]), FAKE_CLAUDE_RELEASE: release,
+ });
+ await instance.adapter.sendTurn({ threadId: "t-engine-pid", text: "scrape" });
+ await recorder.until((e) => e.type === "item.started" && e.itemType === "tool");
+ const pid = instance.adapter.enginePid?.("t-engine-pid");
+ expect(pid).toEqual(expect.any(Number));
+ expect(() => process.kill(pid!, 0), "the CLI running this turn").not.toThrow();
+ writeFileSync(release, "go");
+ await recorder.until((e) => e.type === "turn.completed");
+ expect(instance.adapter.enginePid?.("t-engine-pid")).toBeUndefined();
+ });
+
it("reports a long Write's input as it streams, after the bot's words and before its tool call", async () => {
await create("slow-write", { FAKE_CLAUDE_WRITE_BYTES: "6144", FAKE_CLAUDE_WRITE_STEP_MS: "5" });
await instance.adapter.sendTurn({ threadId: "t-slow-write", text: "build a dashboard" });
diff --git a/server/drivers/claude.ts b/server/drivers/claude.ts
index 1727c891a5..2b6e56e9ee 100644
--- a/server/drivers/claude.ts
+++ b/server/drivers/claude.ts
@@ -656,13 +656,7 @@ function decodeConfig(raw: unknown): ClaudeConfig {
function firstText(content: unknown): string {
if (typeof content === "string") return content;
- if (Array.isArray(content)) {
- return content
- .filter((b) => b?.type === "text" && b.text)
- .map((b) => b.text)
- .join("");
- }
- return "";
+ return Array.isArray(content) ? content.filter((b) => b?.type === "text" && b.text).map((b) => b.text).join("") : "";
}
/** A turn's cost from total_cost_usd, which is the process's running total (2.1.282): the growth
@@ -2091,6 +2085,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
return behavior === "allow" ? "allowed-once" : behavior === "answer" ? "answered" : "rejected";
},
hasSession: (threadId) => active.has(threadId),
+ enginePid: (threadId) => (active.has(threadId) ? sessions.get(threadId)?.child.pid : undefined),
cacheKeepWarm: {
ping: async (threadId, options) => {
const live = sessions.get(threadId);
diff --git a/server/drivers/codex-errors.ts b/server/drivers/codex-errors.ts
index b7caecf5d7..4b95123d27 100644
--- a/server/drivers/codex-errors.ts
+++ b/server/drivers/codex-errors.ts
@@ -91,3 +91,22 @@ export const CODEX_SIGN_IN_EXPIRED = "Codex's ChatGPT sign-in has expired. Sign
export function codexSignInExpired(raw: string): string {
return `${CODEX_SIGN_IN_EXPIRED} Codex said: ${raw.slice(0, 300)}`;
}
+
+export class CodexRpcError extends Error {
+ code: unknown;
+
+ constructor(error: { code?: unknown; message?: string }) {
+ super(error.message ?? JSON.stringify(error));
+ this.code = error.code;
+ }
+}
+
+export function missingNativeCodexThread(error: unknown, cursor: string): boolean {
+ // Codex's local thread/resume rejection, verified with an empty native home; unknown versions fail closed.
+ return error instanceof CodexRpcError && error.code === -32600 &&
+ error.message === `no rollout found for thread id ${cursor}`;
+}
+
+/** Codex refuses to resume an archived session: "session <id> is archived. Run `codex unarchive <id>` to unarchive it first." */
+export const archivedNativeCodexThread = (error: unknown, cursor: string): boolean =>
+ error instanceof CodexRpcError && error.message.includes(cursor) && /\bis archived\b/.test(error.message);
diff --git a/server/drivers/codex.test.ts b/server/drivers/codex.test.ts
index b75ec0a1b2..6d057124f0 100644
--- a/server/drivers/codex.test.ts
+++ b/server/drivers/codex.test.ts
@@ -1752,6 +1752,29 @@ process.stdout.write(JSON.stringify({jsonrpc:'2.0',id:m.id,result})+'\\n');});`)
expect(types.indexOf("turn.progress")).toBeGreaterThan(types.indexOf("item.started"));
});
+ it("streams a running command's output to the bus, and names its app-server while the turn runs", async () => {
+ const gate = join(scratch, "command-done");
+ Object.assign(process.env, { FAKE_CODEX_COMMAND: "/bin/zsh -lc 'pnpm test'", FAKE_CODEX_COMMAND_OUTPUT: JSON.stringify(["RUN v3\n", " ✓ a.test.ts\n"]), FAKE_CODEX_COMMAND_GATE: gate });
+ try {
+ await create();
+ await instance.adapter.sendTurn({ threadId: "t-output", text: "run the tests" });
+ await recorder.until((e) => e.type === "item.output" && e.text.includes("a.test.ts"));
+ const pid = instance.adapter.enginePid?.("t-output");
+ expect(pid).toEqual(expect.any(Number));
+ expect(() => process.kill(pid!, 0), "the app-server running this turn").not.toThrow();
+ writeFileSync(gate, "done");
+ await recorder.until((e) => e.type === "turn.completed");
+ expect(instance.adapter.enginePid?.("t-output"), "no engine once the turn is over").toBeUndefined();
+ } finally {
+ for (const key of ["FAKE_CODEX_COMMAND", "FAKE_CODEX_COMMAND_OUTPUT", "FAKE_CODEX_COMMAND_GATE"]) delete process.env[key];
+ }
+ expect(recorder.events.filter((e) => e.type === "item.output")).toEqual([
+ expect.objectContaining({ itemType: "tool", itemId: "i1", text: "RUN v3\n" }),
+ expect.objectContaining({ itemType: "tool", itemId: "i1", text: " ✓ a.test.ts\n" }),
+ ]);
+ expect(recorder.events.find((e) => e.type === "item.started" && e.itemType === "tool")).toMatchObject({ summary: "/bin/zsh -lc 'pnpm test'" });
+ });
+
it("tries thread/resume with a cursor and reuses the thread id", async () => {
await create({ mode: "resume" });
const dump = join(scratch, "dump.json");
diff --git a/server/drivers/codex.ts b/server/drivers/codex.ts
index f5e14c761a..008537dcd4 100644
--- a/server/drivers/codex.ts
+++ b/server/drivers/codex.ts
@@ -47,7 +47,7 @@ import { volatileContextNote, withContextNote } from "./prompt-split.ts";
import type { ApprovalMode } from "../../shared/approval-mode.ts";
import { CodexDeviceAuthController } from "./codex-device-auth.ts";
import { codexAccountEmail, codexHome } from "./codex-identity.ts";
-import { CODEX_MISSING_CREDENTIALS, CODEX_SIGN_IN_EXPIRED, codexLimitFacts, codexNotSignedIn, codexSignInExpired, codexSignInRefused, codexUserError, type CodexRoute } from "./codex-errors.ts";
+import { archivedNativeCodexThread, CODEX_MISSING_CREDENTIALS, CODEX_SIGN_IN_EXPIRED, codexLimitFacts, codexNotSignedIn, CodexRpcError, codexSignInExpired, codexSignInRefused, codexUserError, missingNativeCodexThread, type CodexRoute } from "./codex-errors.ts";
import { codexLoginCheck, codexLoginStatus, storedCodexLogin } from "./codex-login.ts";
import { keyRejected, noteKeyAccepted, noteKeyRejected } from "../key-rejections.ts";
import { classifyResumeFailure, mayReplay, rebuiltSessionNotice, recoveryPromptFor } from "../resume-recovery.ts";
@@ -60,31 +60,12 @@ import { effectiveApprovalPolicy, effectiveApprovalsReviewer } from "./codex-app
import { canUseMcpServer } from "../../shared/tool-scope.ts";
import { assertToolScopeSupported } from "../../shared/tool-scope-support.ts";
import { appMountFor, gateServer, mcpStdioServer } from "../mcp-gate-config.ts"; import { OWN_APPS_SERVER } from "../../shared/own-apps.ts";
-import { CALL_TOOL, DESCRIBE_TOOL, SEARCH_TOOL, directoryCallTarget } from "../mcp-directory.ts"; import { codexPatchProgress } from "./tool-progress.ts";
+import { CALL_TOOL, DESCRIBE_TOOL, SEARCH_TOOL, directoryCallTarget } from "../mcp-directory.ts"; import { codexCommandOutput, codexPatchProgress } from "./tool-progress.ts";
export { decodeCodexSelection, readCodexModelCatalog, STATIC_CODEX_MODELS } from "./codex-catalog.ts";
const DRIVER_KIND = "codex";
-class CodexRpcError extends Error {
- code: unknown;
-
- constructor(error: { code?: unknown; message?: string }) {
- super(error.message ?? JSON.stringify(error));
- this.code = error.code;
- }
-}
-
-function missingNativeCodexThread(error: unknown, cursor: string): boolean {
- // Codex's local thread/resume rejection, verified with an empty native home; unknown versions fail closed.
- return error instanceof CodexRpcError && error.code === -32600 &&
- error.message === `no rollout found for thread id ${cursor}`;
-}
-
-/** Codex refuses to resume an archived session: "session <id> is archived. Run `codex unarchive <id>` to unarchive it first." */
-const archivedNativeCodexThread = (error: unknown, cursor: string): boolean =>
- error instanceof CodexRpcError && error.message.includes(cursor) && /\bis archived\b/.test(error.message);
-
export interface CodexConfig {
cli: string;
fullAuto: boolean;
@@ -589,6 +570,7 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {
steer?: (text: string) => Promise<SteerOutcome>;
turnId: string;
asks: Map<string, CodexAsk>;
+ pid?: number;
}
const active = new Map<string, Turn>();
@@ -1214,6 +1196,7 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {
break;
}
case "item/fileChange/patchUpdated": { const draft = codexPatchProgress(p); if (draft) emit({ ...base(threadId, turnId), ...draft }); break; }
+ case "item/commandExecution/outputDelta": { const output = codexCommandOutput(p); if (output) emit({ ...base(threadId, turnId), ...output }); break; }
case "item/started": {
const item = p.item ?? {};
const runs = item.type === "mcpToolCall" && item.tool === CALL_TOOL && typeof item.server === "string" && directoryMounts.has(item.server)
@@ -1432,7 +1415,7 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {
void settle(false, "exit_before_result");
});
- active.set(threadId, { stop, turnId, asks, steer: steerActiveTurn });
+ active.set(threadId, { stop, turnId, asks, steer: steerActiveTurn, pid: child.pid });
if (attempt === 0 && !announced) emit({ ...base(threadId, turnId), type: "turn.started" });
try {
@@ -1808,6 +1791,7 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {
?? (decision.behavior === "allow" ? "allowed-once" : decision.behavior === "answer" ? "answered" : "rejected");
},
hasSession: (threadId) => active.has(threadId),
+ enginePid: (threadId) => active.get(threadId)?.pid,
stopAll: async () => {
await Promise.all([...active.values()].map(({ stop }) => stop()));
},
diff --git a/server/drivers/tool-progress.test.ts b/server/drivers/tool-progress.test.ts
index 6f4e708066..34255bb4fc 100644
--- a/server/drivers/tool-progress.test.ts
+++ b/server/drivers/tool-progress.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
-import { acpToolProgress, claudeToolDraft, codexPatchProgress } from "./tool-progress.ts";
+import { acpToolOutput, acpToolProgress, claudeToolDraft, codexCommandOutput, codexPatchProgress } from "./tool-progress.ts";
/** Claude Code's stream-json frames (2.1.306, --include-partial-messages) for one model message, as the CLI prints
* them: `{type: "stream_event", event}` around the API's own streaming events. */
@@ -108,3 +108,21 @@ describe("ACP: a tool call still running", () => {
expect(acpToolProgress({ sessionUpdate: "agent_message_chunk", content: { text: "hi" } })).toBeNull();
});
});
+
+describe("a running command's output, as engines stream it", () => {
+ it("Codex: item/commandExecution/outputDelta is the next chunk to append", () => {
+ expect(codexCommandOutput({ threadId: "t", turnId: "u", itemId: "call_1", delta: "page 3 of 40\n" }))
+ .toEqual({ type: "item.output", itemType: "tool", itemId: "call_1", text: "page 3 of 40\n" });
+ expect(codexCommandOutput({ itemId: "call_1", delta: "" })).toBeNull();
+ expect(codexCommandOutput({ delta: "orphan" })).toBeNull();
+ });
+
+ it("ACP: a running call's text content is all of its output so far, replaced on each update", () => {
+ expect(acpToolOutput({ sessionUpdate: "tool_call_update", toolCallId: "c1", status: "in_progress",
+ content: [{ type: "content", content: { type: "text", text: "Collecting 12 items" } }, { type: "diff", path: "a.ts", newText: "x" }] }))
+ .toEqual({ type: "item.output", itemType: "tool", itemId: "c1", text: "Collecting 12 items", whole: true });
+ expect(acpToolOutput({ sessionUpdate: "tool_call_update", toolCallId: "c1", status: "completed",
+ content: [{ type: "content", content: { type: "text", text: "done" } }] })).toBeNull();
+ expect(acpToolOutput({ sessionUpdate: "tool_call_update", toolCallId: "c1", status: "in_progress", content: [{ type: "terminal", terminalId: "t" }] })).toBeNull();
+ });
+});
diff --git a/server/drivers/tool-progress.ts b/server/drivers/tool-progress.ts
index edfc222d99..9630208f0a 100644
--- a/server/drivers/tool-progress.ts
+++ b/server/drivers/tool-progress.ts
@@ -94,6 +94,15 @@ export function codexPatchProgress(params: unknown): TurnProgressFields | null {
return report(activity, "edit", { bytes, ...(file ? { file } : {}), ...(typeof p?.itemId === "string" ? { itemId: p.itemId } : {}) });
}
+type OutputReport = { type: "item.output"; itemType: "tool"; itemId: string; text: string; whole?: true };
+
+/** Codex's item/commandExecution/outputDelta: the next chunk a running command printed. */
+export function codexCommandOutput(params: unknown): OutputReport | null {
+ const p = params as { itemId?: unknown; delta?: unknown } | null;
+ if (typeof p?.itemId !== "string" || !p.itemId || typeof p.delta !== "string" || !p.delta) return null;
+ return { type: "item.output", itemType: "tool", itemId: p.itemId, text: p.delta };
+}
+
const ACP_KINDS: Record<string, TurnProgressActivity> = {
edit: "edit",
delete: "edit",
@@ -128,3 +137,14 @@ export function acpToolProgress(update: unknown): TurnProgressFields | null {
...(typeof u.toolCallId === "string" && u.toolCallId ? { itemId: u.toolCallId } : {}),
});
}
+
+/** An ACP call still running with text in its content: ACP replaces a call's whole content on each update. */
+export function acpToolOutput(update: unknown): OutputReport | null {
+ const u = update as { sessionUpdate?: unknown; toolCallId?: unknown; status?: unknown; content?: unknown } | null;
+ if (u?.sessionUpdate !== "tool_call" && u?.sessionUpdate !== "tool_call_update") return null;
+ if (u.status === "completed" || u.status === "failed" || typeof u.toolCallId !== "string" || !u.toolCallId) return null;
+ const text = (Array.isArray(u.content) ? u.content as Array<{ type?: unknown; content?: { type?: unknown; text?: unknown } }> : [])
+ .flatMap((part) => (part?.type === "content" && part.content?.type === "text" && typeof part.content.text === "string" ? [part.content.text] : []))
+ .join("\n");
+ return text ? { type: "item.output", itemType: "tool", itemId: u.toolCallId, text, whole: true } : null;
+}
diff --git a/server/harness/bus.test.ts b/server/harness/bus.test.ts
index b3b2a3e867..0f163c01e0 100644
--- a/server/harness/bus.test.ts
+++ b/server/harness/bus.test.ts
@@ -557,4 +557,51 @@ describe("EventBus status-line progress", () => {
expect(seen.map((event) => event.threadId)).toEqual(["a", "b"]);
await bus.flush();
});
+
+ it("keeps a waiting report through a heartbeat or a token count, which the status line does not act on", async () => {
+ const bus = new EventBus();
+ const seen: RuntimeEvent[] = [];
+ bus.subscribe((event) => seen.push(event));
+ bus.publish(progress(2048));
+ bus.publish(progress(4096));
+ bus.publish(testEvent({ type: "item.updated", itemType: "tool", turnId: "turn-1" } as Partial<RuntimeEvent>));
+ bus.publish(testEvent({ type: "thread.token-usage.updated", input: 10, output: 5, turnId: "turn-1" } as Partial<RuntimeEvent>));
+ vi.advanceTimersByTime(1000);
+ expect(shown(seen)).toEqual(["progress:2048", "item.updated", "thread.token-usage.updated", "progress:4096"]);
+ await bus.flush();
+ });
+
+ it("names a tool call's step in a frame after its start, past the engine's token count, and logs the step with the start", async () => {
+ const bus = new EventBus();
+ const seen: RuntimeEvent[] = [];
+ bus.subscribe((event) => seen.push(event));
+ const command = "cd ~/biber && python3 scrape.py --pages 40";
+ bus.publish(progress(0, { threadId: "steps", activity: "command", file: undefined, itemId: "toolu_9" }));
+ bus.publish(testEvent({ threadId: "steps", type: "item.started", itemType: "tool", itemId: "toolu_9", turnId: "turn-1", title: "Bash",
+ summary: command, input: JSON.stringify({ command }) } as Partial<RuntimeEvent>));
+ bus.publish(testEvent({ threadId: "steps", type: "thread.token-usage.updated", input: 10, output: 5, turnId: "turn-1" } as Partial<RuntimeEvent>));
+ vi.advanceTimersByTime(1000);
+ const frame = seen.at(-1) as Extract<RuntimeEvent, { type: "turn.progress" }>;
+ expect(frame).toMatchObject({ type: "turn.progress", itemId: "toolu_9", activity: "command", target: "scrape.py", detail: command });
+ await bus.flush();
+ const logged = readFileSync(join(EVENTS_DIR, "steps.ndjson"), "utf8").trim().split("\n").map((line) => JSON.parse(line));
+ expect(logged.find((event) => event.type === "item.started")?.step).toEqual({ activity: "command", target: "scrape.py", detail: command });
+ expect(logged.some((event) => event.type === "turn.progress")).toBe(false);
+ });
+
+ it("folds a command's streamed output into its frame's last lines and neither logs nor forwards the output itself", async () => {
+ const bus = new EventBus();
+ const seen: RuntimeEvent[] = [];
+ bus.subscribe((event) => seen.push(event));
+ bus.publish(testEvent({ threadId: "out", type: "item.started", itemType: "tool", itemId: "cmd_1", turnId: "turn-1", title: "pnpm test",
+ summary: "pnpm test", input: JSON.stringify({ command: "pnpm test" }) } as Partial<RuntimeEvent>));
+ vi.advanceTimersByTime(1000);
+ bus.publish(testEvent({ threadId: "out", type: "item.output", itemType: "tool", itemId: "cmd_1", turnId: "turn-1", text: "✓ a.test.ts\n✓ b.test.ts\n" } as Partial<RuntimeEvent>));
+ vi.advanceTimersByTime(1000);
+ expect(seen.some((event) => event.type === "item.output")).toBe(false);
+ expect(seen.at(-1)).toMatchObject({ type: "turn.progress", itemId: "cmd_1", target: "pnpm test", tail: ["✓ a.test.ts", "✓ b.test.ts"] });
+ await bus.flush();
+ const logged = readFileSync(join(EVENTS_DIR, "out.ndjson"), "utf8").trim().split("\n").map((line) => JSON.parse(line).type);
+ expect(logged).toEqual(["item.started"]);
+ });
});
diff --git a/server/harness/bus.ts b/server/harness/bus.ts
index d7053a9ed3..3dfac158fa 100644
--- a/server/harness/bus.ts
+++ b/server/harness/bus.ts
@@ -5,7 +5,8 @@ import { join } from "node:path";
import { EVENTS_DIR } from "../config.ts";
import { redactSecrets } from "../redact.ts";
import { capThreadLog, currentThreadLogCap } from "../thread-log-rotation.ts";
-import { newId, type ProviderInstance, type RuntimeEvent, type RuntimeEventListener } from "../contracts.ts";
+import { newId, type ProviderAdapter, type ProviderInstance, type RuntimeEvent, type RuntimeEventListener } from "../contracts.ts";
+import { LiveSteps } from "./live-steps.ts";
import { ProgressGate } from "./progress-gate.ts";
const INCOMPLETE_LOG_MESSAGE =
@@ -35,6 +36,9 @@ function sameStream(a: TextDelta, b: TextDelta): boolean {
a.itemId === b.itemId && a.streamKind === b.streamKind && a.synthetic === b.synthetic;
}
+/** What changes the chat's status line, and so makes a waiting status report stale; a heartbeat or a token count does not. */
+const STATUS_LINE_EVENTS = new Set<RuntimeEvent["type"]>(["turn.started", "content.delta", "item.started", "item.completed", "request.opened"]);
+
function isTerminalEvent(event: RuntimeEvent): boolean {
if (event.type === "turn.completed" || event.type === "cap.exhausted" || event.type === "session.exited") {
return true;
@@ -59,6 +63,11 @@ export class EventBus {
if (this.pendingText.has(event.threadId)) this.flushThread(event.threadId);
this.deliver(event);
});
+ private readonly adapters = new Map<string, ProviderAdapter>();
+ private readonly steps = new LiveSteps({
+ offer: (event) => this.progress.offer(event),
+ enginePid: (event) => this.adapters.get(event.providerInstanceId ?? "")?.enginePid?.(event.threadId),
+ });
private readonly gate?: (event: RuntimeEvent) => boolean;
@@ -71,6 +80,7 @@ export class EventBus {
attach(instances: ProviderInstance[]) {
for (const instance of instances) {
this.detach(instance.instanceId);
+ this.adapters.set(instance.instanceId, instance.adapter);
const unsub = instance.adapter.onEvent((event) => {
// An adapter may only emit events for its own driver kind.
if (event.provider !== instance.driverKind) {
@@ -84,12 +94,17 @@ export class EventBus {
}
}
- publish(event: RuntimeEvent) {
- if (event.type === "turn.progress") {
- this.progress.offer(event);
+ publish(raw: RuntimeEvent) {
+ if (raw.type === "turn.progress") {
+ this.progress.offer(this.steps.progress(raw));
+ return;
+ }
+ if (raw.type === "item.output") {
+ this.steps.output(raw);
return;
}
- this.progress.supersede(event.threadId, isTerminalEvent(event));
+ const event = this.steps.observe(raw, isTerminalEvent(raw));
+ if (STATUS_LINE_EVENTS.has(event.type) || isTerminalEvent(event)) this.progress.supersede(event.threadId, isTerminalEvent(event));
const pending = this.pendingText.get(event.threadId);
if (event.type === "content.delta") {
if (pending && sameStream(pending.event, event)) {
@@ -104,6 +119,7 @@ export class EventBus {
}
if (pending) this.flushThread(event.threadId);
this.write(event);
+ this.steps.announce(event);
}
flush(): Promise<void> {
@@ -279,6 +295,7 @@ export class EventBus {
detach(instanceId: string) {
this.unsubscribes.get(instanceId)?.();
this.unsubscribes.delete(instanceId);
+ this.adapters.delete(instanceId);
void this.flush();
}
}
diff --git a/server/harness/live-steps.test.ts b/server/harness/live-steps.test.ts
new file mode 100644
index 0000000000..236d8aaf5a
--- /dev/null
+++ b/server/harness/live-steps.test.ts
@@ -0,0 +1,171 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import type { RuntimeEvent } from "../contracts.ts";
+import type { ProcessSample } from "../drivers/acp/quiet-status.ts";
+import { commandSummary, toolDetailPreview } from "../tool-summary.ts";
+import { LiveSteps, outputTail, TAIL_FRAME_MS } from "./live-steps.ts";
+import type { ProgressEvent } from "./progress-gate.ts";
+
+const NOTICE = 60_000;
+let clock = 0;
+let offered: ProgressEvent[];
+let samples: ProcessSample[];
+let sampled: Array<{ pid: number; since: number }>;
+let steps: LiveSteps;
+
+const base = (provider: string, extra: Partial<RuntimeEvent> = {}) => ({
+ eventId: `e${Math.random()}`, provider, providerInstanceId: provider, threadId: "t1", turnId: "turn-1", createdAt: "2026-10-28T12:00:00.000Z", ...extra,
+});
+const started = (provider: string, itemId: string, call: { title: string; summary?: string; input?: string }) =>
+ ({ ...base(provider, { itemId }), type: "item.started", itemType: "tool", ...call }) as RuntimeEvent;
+const bash = (command: string, itemId = "call-1") =>
+ started("claudeAgent", itemId, { title: "Bash", summary: commandSummary({ command }), input: toolDetailPreview({ command }) });
+
+beforeEach(() => {
+ vi.useFakeTimers();
+ clock = 1_000_000;
+ offered = [];
+ samples = [];
+ sampled = [];
+ steps = new LiveSteps({
+ offer: (event) => offered.push(event),
+ enginePid: (event) => (event.providerInstanceId === "claudeAgent" ? 4242 : undefined),
+ sample: async (pid, since) => {
+ sampled.push({ pid, since });
+ return samples.shift() ?? { cpuMs: null, connections: null };
+ },
+ now: () => clock,
+ noticeMs: () => NOTICE,
+ tickMs: () => 15_000,
+ });
+});
+
+afterEach(() => {
+ steps.stop();
+ vi.useRealTimers();
+});
+
+const last = () => offered.at(-1)!;
+
+describe("LiveSteps: what the call works on", () => {
+ it("stamps the start event with its step and sends the status line's frame for it", () => {
+ const event = bash("cd ~/biber && OPENAI_API_KEY=sk-proj-abcdefghijklmnopqrstuvwxyz python3 scrape.py --pages 40");
+ const stamped = steps.observe(event, false);
+ expect(stamped).toMatchObject({ step: { activity: "command", target: "scrape.py" } });
+ expect(offered).toEqual([]);
+ steps.announce(stamped);
+ expect(last()).toMatchObject({ type: "turn.progress", itemId: "call-1", activity: "command", target: "scrape.py", turnId: "turn-1" });
+ expect(last().detail).toBe("cd ~/biber && OPENAI_API_KEY=… python3 scrape.py --pages 40");
+ expect(JSON.stringify(offered)).not.toContain("sk-proj");
+ });
+
+ it("reads Claude, Codex and ACP calls through the same path", () => {
+ const codex = "/bin/zsh -lc 'pnpm test'";
+ steps.announce(steps.observe(started("codex", "codex-1", { title: codex, summary: commandSummary({ command: codex }), input: toolDetailPreview({ command: codex, cwd: "/w" }) }), false));
+ expect(last()).toMatchObject({ provider: "codex", activity: "command", target: "pnpm test" });
+ steps.announce(steps.observe(started("acpAgent", "acp-1", { title: "web_fetch", input: toolDetailPreview({ url: "https://www.linkedin.com/in/ada" }) }), false));
+ expect(last()).toMatchObject({ provider: "acpAgent", activity: "fetch", target: "linkedin.com" });
+ steps.announce(steps.observe(started("claudeAgent", "cl-1", { title: "WebSearch", input: toolDetailPreview({ query: "Biber Dammbau" }) }), false));
+ expect(last()).toMatchObject({ activity: "web", target: "Biber Dammbau" });
+ });
+
+ it("leaves a call it cannot name as it was", () => {
+ const event = started("claudeAgent", "ask-1", { title: "mcp__agents__ask_bot", input: toolDetailPreview({ bot: "Kai" }) });
+ expect(steps.observe(event, false)).toBe(event);
+ steps.announce(event);
+ expect(offered).toEqual([]);
+ });
+
+ it("gives an engine's own report about the call the call's words, and leaves other calls' reports alone", () => {
+ steps.observe(bash("python3 scrape.py"), false);
+ const own = { ...base("claudeAgent", { itemId: "call-1" }), type: "turn.progress", activity: "tool", tool: "Bash", bytes: 40 } as ProgressEvent;
+ expect(steps.progress(own)).toMatchObject({ activity: "command", target: "scrape.py", bytes: 40 });
+ expect(steps.progress(own).tool).toBeUndefined();
+ const other = { ...own, itemId: "call-9" } as ProgressEvent;
+ expect(steps.progress(other)).toBe(other);
+ });
+});
+
+describe("LiveSteps: a long call's sign of life", () => {
+ it("says nothing before the quiet notice, then what the call's processes show, once per change", async () => {
+ steps.announce(steps.observe(bash("python3 scrape.py"), false));
+ offered = [];
+ clock += NOTICE - 1;
+ await steps.tick();
+ expect(sampled).toEqual([]);
+ clock += 1;
+ samples.push({ cpuMs: 1_000, connections: 1 });
+ await steps.tick();
+ expect(sampled).toEqual([{ pid: 4242, since: 1_000_000 }]);
+ expect(last().quiet).toEqual({ kind: "network" });
+ clock += 15_000;
+ samples.push({ cpuMs: 9_000, connections: 0 });
+ await steps.tick();
+ expect(last().quiet).toEqual({ kind: "busy" });
+ clock += 15_000;
+ samples.push({ cpuMs: 9_050, connections: 0 });
+ await steps.tick();
+ expect(last().quiet).toEqual({ kind: "idle" });
+ const sent = offered.length;
+ clock += 15_000;
+ samples.push({ cpuMs: 9_060, connections: 0 });
+ await steps.tick();
+ expect(offered).toHaveLength(sent);
+ expect(last()).toMatchObject({ target: "scrape.py", activity: "command" });
+ });
+
+ it("does not guess for an engine with no process of its own", async () => {
+ steps.announce(steps.observe(started("openaiChat", "x-1", { title: "Bash", summary: "python3 scrape.py", input: "{}" }), false));
+ clock += NOTICE;
+ await steps.tick();
+ expect(sampled).toEqual([]);
+ expect(offered.every((frame) => frame.quiet === undefined)).toBe(true);
+ });
+
+ it("shows a running command's last lines at most once a second, and its last output once it has run a while", () => {
+ steps.announce(steps.observe(bash("pnpm test", "c1"), false));
+ const out = (text: string) => steps.output({ ...base("claudeAgent", { itemId: "c1" }), type: "item.output", itemType: "tool", text } as Extract<RuntimeEvent, { type: "item.output" }>);
+ out("RUN v3\n ✓ src/a.test.ts (3)\n");
+ expect(last().tail).toEqual(["RUN v3", "✓ src/a.test.ts (3)"]);
+ expect(last().quiet).toBeUndefined();
+ const sent = offered.length;
+ out(" ✓ src/b.test.ts (5)\n");
+ out(" ✓ src/c.test.ts (1)\n");
+ expect(offered).toHaveLength(sent);
+ clock += TAIL_FRAME_MS;
+ vi.advanceTimersByTime(TAIL_FRAME_MS);
+ expect(offered).toHaveLength(sent + 1);
+ expect(last().tail).toEqual(["✓ src/b.test.ts (5)", "✓ src/c.test.ts (1)"]);
+ clock += NOTICE;
+ out("export TOKEN=ghp_abcdefghijklmnopqrstuvwxyz0123 done\n");
+ expect(last().quiet).toEqual({ kind: "output", at: clock });
+ expect(JSON.stringify(last().tail)).not.toContain("ghp_abcdefghijklmnopqrstuvwxyz0123");
+ });
+
+ it("forgets a call when it ends, and everything when its turn ends", async () => {
+ steps.announce(steps.observe(bash("python3 scrape.py", "a"), false));
+ steps.announce(steps.observe(bash("python3 other.py", "b"), false));
+ steps.observe({ ...base("claudeAgent", { itemId: "a" }), type: "item.completed", itemType: "tool", ok: true } as RuntimeEvent, false);
+ const own = { ...base("claudeAgent", { itemId: "a" }), type: "turn.progress", activity: "command" } as ProgressEvent;
+ expect(steps.progress(own)).toBe(own);
+ steps.observe({ ...base("claudeAgent"), type: "turn.completed", ok: true } as RuntimeEvent, true);
+ offered = [];
+ clock += NOTICE * 2;
+ await steps.tick();
+ expect(sampled).toEqual([]);
+ expect(offered).toEqual([]);
+ });
+});
+
+describe("outputTail", () => {
+ it("keeps the last two lines as printed: no escape codes, a progress bar at its newest state, capped", () => {
+ expect(outputTail("\x1b[32mok\x1b[0m one\nfetching 10%\rfetching 55%\rfetching 90%\n\n")).toEqual(["ok one", "fetching 90%"]);
+ const [line] = outputTail("x".repeat(500));
+ expect(line!.length).toBeLessThanOrEqual(160);
+ });
+
+ it("keeps an environment variable's name and never its value, whatever its shape", () => {
+ expect(outputTail("PGHOST=db.internal\nexport STRIPE_RESTRICTED=hunter2\n")).toEqual(["PGHOST=…", "export STRIPE_RESTRICTED=…"]);
+ expect(outputTail("declare -x HOME=\"/Users/ada\"\n✓ 3 tests passed (x=1)\n")).toEqual(["declare -x HOME=…", "✓ 3 tests passed (x=1)"]);
+ });
+});
diff --git a/server/harness/live-steps.ts b/server/harness/live-steps.ts
new file mode 100644
index 0000000000..0d1846ff95
--- /dev/null
+++ b/server/harness/live-steps.ts
@@ -0,0 +1,225 @@
+// The status line's words for each running tool call, whatever the engine: what the call works on (its step), how a
+// long one is doing (its last output, or what its processes show), and a running command's last lines of output.
+import { stripVTControlCharacters } from "node:util";
+
+import { classifyQuiet, quietNoticeMs, quietTickMs, sampleProcessTree, type ProcessSample } from "../drivers/acp/quiet-status.ts";
+import { redactSecretsInText } from "../redact.ts";
+import { toolStep } from "../step-summary.ts";
+import { newId, type RuntimeEvent } from "../contracts.ts";
+import type { StepQuiet } from "../../shared/turn-progress.ts";
+import type { ProgressEvent } from "./progress-gate.ts";
+
+type OutputEvent = Extract<RuntimeEvent, { type: "item.output" }>;
+
+/** The least time between two frames that change only a call's output. */
+export const TAIL_FRAME_MS = 1_000;
+const TAIL_LINES = 2;
+const TAIL_LINE_MAX = 160;
+const OUTPUT_KEPT = 8 * 1024;
+
+interface Call {
+ frame: ProgressEvent;
+ startedAt: number;
+ output: string;
+ outputAt: number | null;
+ quiet?: StepQuiet;
+ tail?: string[];
+ sample: ProcessSample | null;
+ sampledAt: number;
+ sampling: boolean;
+ tailSentAt: number;
+ tailTimer: ReturnType<typeof setTimeout> | null;
+}
+
+export interface LiveStepsOptions {
+ offer(event: ProgressEvent): void;
+ /** The local process running the engine of this event's turn, when the engine has one. */
+ enginePid(event: Pick<RuntimeEvent, "threadId" | "providerInstanceId">): number | undefined;
+ sample?: (pid: number, since: number) => Promise<ProcessSample>;
+ now?: () => number;
+ noticeMs?: () => number;
+ tickMs?: () => number;
+}
+
+// Security: a line that sets an environment variable (`env`, `export -p`, a printed .env) keeps the name, never the value.
+const ENV_LINE = /^((?:export |declare -x |set )?[A-Za-z_][A-Za-z0-9_]*=).+$/;
+
+/** The last lines a command printed, as a person would read them: no escape codes, a progress bar at its latest state. */
+export function outputTail(output: string): string[] {
+ return stripVTControlCharacters(output).split(/\r?\n/)
+ .map((line) => (line.split("\r").filter((part) => part.trim()).pop() ?? "").replace(/\p{Cc}/gu, "").trim())
+ .filter(Boolean)
+ .slice(-TAIL_LINES)
+ .map((line) => {
+ const safe = redactSecretsInText(line).replace(ENV_LINE, "$1…");
+ return safe.length > TAIL_LINE_MAX ? `${safe.slice(0, TAIL_LINE_MAX - 1)}…` : safe;
+ });
+}
+
+function quietOf(call: Call, previous: ProcessSample | null, sinceMs: number, sample: ProcessSample): StepQuiet | undefined {
+ const state = classifyQuiet({ logged: null, context: null, sample, previous, sinceMs });
+ if (state.kind === "waiting-model") return { kind: "network" };
+ if (state.kind === "busy") return { kind: "busy" };
+ if (state.kind === "no-signs") return { kind: "idle" };
+ return call.quiet;
+}
+
+const sameQuiet = (a: StepQuiet | undefined, b: StepQuiet | undefined) =>
+ a?.kind === b?.kind && (a?.kind !== "output" || a.at === (b as { at?: number } | undefined)?.at);
+
+export class LiveSteps {
+ private readonly threads = new Map<string, Map<string, Call>>();
+ private readonly opts: LiveStepsOptions;
+ private timer: ReturnType<typeof setInterval> | null = null;
+
+ constructor(opts: LiveStepsOptions) {
+ this.opts = opts;
+ }
+
+ private now(): number {
+ return this.opts.now?.() ?? Date.now();
+ }
+
+ /** A tool call starting gets its step, if it has one; a call's end, or its turn's, forgets it. */
+ observe(event: RuntimeEvent, terminal: boolean): RuntimeEvent {
+ if (terminal) {
+ for (const call of this.threads.get(event.threadId)?.values() ?? []) this.drop(call);
+ this.threads.delete(event.threadId);
+ this.idleCheck();
+ return event;
+ }
+ if (event.type === "item.completed" && event.itemType === "tool" && event.itemId) {
+ const calls = this.threads.get(event.threadId);
+ const call = calls?.get(event.itemId);
+ if (call) this.drop(call);
+ calls?.delete(event.itemId);
+ if (calls?.size === 0) this.threads.delete(event.threadId);
+ this.idleCheck();
+ return event;
+ }
+ if (event.type !== "item.started" || event.itemType !== "tool" || !event.itemId) return event;
+ const step = toolStep(event);
+ if (!step) return event;
+ let calls = this.threads.get(event.threadId);
+ if (!calls) this.threads.set(event.threadId, (calls = new Map()));
+ const repeated = calls.get(event.itemId);
+ if (repeated) this.drop(repeated);
+ const frame: ProgressEvent = {
+ eventId: newId(), provider: event.provider, providerInstanceId: event.providerInstanceId, threadId: event.threadId,
+ createdAt: event.createdAt, turnId: event.turnId, itemId: event.itemId, type: "turn.progress", ...step,
+ };
+ calls.set(event.itemId, {
+ frame, startedAt: this.now(), output: "", outputAt: null, sample: null, sampledAt: 0, sampling: false, tailSentAt: 0, tailTimer: null,
+ });
+ this.timer ??= setInterval(() => void this.tick(), this.opts.tickMs?.() ?? quietTickMs());
+ this.timer.unref?.();
+ return { ...event, step };
+ }
+
+ /** The status-line frame of a call that just started, sent after the call's own start event. */
+ announce(event: RuntimeEvent): void {
+ const call = event.itemId ? this.threads.get(event.threadId)?.get(event.itemId) : undefined;
+ if (call && event.type === "item.started") this.send(call);
+ }
+
+ /** An engine's own report about a call carries the call's step, how it is doing and its output too. */
+ progress(event: ProgressEvent): ProgressEvent {
+ const call = event.itemId ? this.threads.get(event.threadId)?.get(event.itemId) : undefined;
+ if (!call) return event;
+ const { tool: _tool, ...rest } = event;
+ return { ...rest, ...this.words(call) };
+ }
+
+ output(event: OutputEvent): void {
+ const call = event.itemId ? this.threads.get(event.threadId)?.get(event.itemId) : undefined;
+ if (!call || !event.text || call.frame.activity !== "command") return;
+ const output = event.whole ? event.text : call.output + event.text;
+ call.output = output.length > OUTPUT_KEPT ? output.slice(-OUTPUT_KEPT) : output;
+ call.outputAt = this.now();
+ if (call.tailTimer) return;
+ const wait = call.tailSentAt + TAIL_FRAME_MS - this.now();
+ if (wait <= 0) {
+ this.sendTail(call);
+ return;
+ }
+ call.tailTimer = setTimeout(() => {
+ call.tailTimer = null;
+ this.sendTail(call);
+ }, wait);
+ call.tailTimer.unref?.();
+ }
+
+ private sendTail(call: Call): void {
+ if (!this.tracked(call)) return;
+ call.tailSentAt = this.now();
+ const tail = outputTail(call.output);
+ const noticed = this.now() - call.startedAt >= (this.opts.noticeMs?.() ?? quietNoticeMs());
+ const quiet: StepQuiet | undefined = noticed && call.outputAt !== null ? { kind: "output", at: call.outputAt } : call.quiet;
+ if (tail.join("\n") === call.tail?.join("\n") && sameQuiet(quiet, call.quiet)) return;
+ call.tail = tail;
+ call.quiet = quiet;
+ this.send(call);
+ }
+
+ private words(call: Call): Partial<ProgressEvent> {
+ const { activity, target, detail } = call.frame;
+ return { activity, target, ...(detail ? { detail } : {}), ...(call.quiet ? { quiet: call.quiet } : {}), ...(call.tail?.length ? { tail: call.tail } : {}) };
+ }
+
+ private send(call: Call): void {
+ this.opts.offer({ ...call.frame, eventId: newId(), createdAt: new Date(this.now()).toISOString(), ...this.words(call) });
+ }
+
+ private tracked(call: Call): boolean {
+ return this.threads.get(call.frame.threadId)?.get(call.frame.itemId ?? "") === call;
+ }
+
+ private drop(call: Call): void {
+ if (call.tailTimer) clearTimeout(call.tailTimer);
+ call.tailTimer = null;
+ }
+
+ private idleCheck(): void {
+ if (this.threads.size > 0 || !this.timer) return;
+ clearInterval(this.timer);
+ this.timer = null;
+ }
+
+ /** Each call that has run past the quiet notice gets its sign of life: its last output, else its processes' state. */
+ async tick(): Promise<void> {
+ const now = this.now();
+ const noticeMs = this.opts.noticeMs?.() ?? quietNoticeMs();
+ for (const calls of Array.from(this.threads.values())) {
+ for (const call of Array.from(calls.values())) {
+ if (now - call.startedAt < noticeMs || call.sampling) continue;
+ const quiet = call.outputAt !== null ? { kind: "output" as const, at: call.outputAt } : await this.processQuiet(call, now);
+ if (!this.tracked(call) || sameQuiet(quiet, call.quiet)) continue;
+ call.quiet = quiet;
+ this.send(call);
+ }
+ }
+ }
+
+ private async processQuiet(call: Call, now: number): Promise<StepQuiet | undefined> {
+ const pid = this.opts.enginePid(call.frame);
+ if (pid === undefined) return call.quiet;
+ call.sampling = true;
+ try {
+ const sample = await (this.opts.sample ?? sampleProcessTree)(pid, call.startedAt);
+ const previous = call.sample;
+ const sinceMs = previous ? now - call.sampledAt : 0;
+ call.sample = sample;
+ call.sampledAt = now;
+ return quietOf(call, previous, sinceMs, sample);
+ } finally {
+ call.sampling = false;
+ }
+ }
+
+ /** Tests only. */
+ stop(): void {
+ for (const calls of this.threads.values()) for (const call of calls.values()) this.drop(call);
+ this.threads.clear();
+ this.idleCheck();
+ }
+}
diff --git a/server/index.ts b/server/index.ts
index 1da2e1f842..ece0b882f6 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -6608,7 +6608,7 @@ bus.subscribe((event: RuntimeEvent) => {
const message = pushMessage({
role: "bot",
kind: "activity",
- tool: { name, spoken: narrateTool(name) ?? undefined, summary: event.summary, input: event.input, itemId: event.itemId ?? event.eventId },
+ tool: { name, spoken: narrateTool(name) ?? undefined, ...(event.step ? { step: event.step } : {}), summary: event.summary, input: event.input, itemId: event.itemId ?? event.eventId },
turnId: liveTurnId,
});
if (event.itemId) toolMessageByItem.set(`${event.threadId}:${event.itemId}`, message.id);
diff --git a/server/step-summary.test.ts b/server/step-summary.test.ts
new file mode 100644
index 0000000000..ec5ff3df6f
--- /dev/null
+++ b/server/step-summary.test.ts
@@ -0,0 +1,113 @@
+import { describe, expect, it } from "vitest";
+
+import { commandTarget, maskAssignments, STEP_TARGET_MAX, toolStep } from "./step-summary.ts";
+import { commandSummary, toolDetailPreview } from "./tool-summary.ts";
+
+const claudeBash = (command: string) => ({ title: "Bash", summary: commandSummary({ command }), input: toolDetailPreview({ command }) });
+
+describe("commandTarget", () => {
+ it.each([
+ ["python3 scrape.py --pages 40", "scrape.py"],
+ ["cd ~/projects/biber && python3 scrape.py --pages 40 --out leads.csv", "scrape.py"],
+ ["pnpm test", "pnpm test"],
+ ["npm run build", "npm run build"],
+ ["uv run scripts/report.py", "uv run report.py"],
+ ["python -m pytest tests/unit -x", "pytest"],
+ ["node ./scripts/build.mjs --prod", "build.mjs"],
+ ["bash scripts/deploy.sh staging", "deploy.sh"],
+ ["./scrape.py", "scrape.py"],
+ ["/bin/zsh -lc 'cd /work && make -j 8 build'", "make build"],
+ ["git -C /work/repo status --short", "git status"],
+ ["sudo -u www-data python3 /srv/app/migrate.py", "migrate.py"],
+ ["timeout -s KILL 300 node crawl.js", "crawl.js"],
+ ["cat leads.csv | python analyze.py", "analyze.py"],
+ ["curl -sS -H 'Accept: application/json' https://api.github.com/repos/x/y", "curl api.github.com"],
+ ["sleep 600", "sleep 600"],
+ ["ls -la", "ls"],
+ ["(cd web && pnpm build)", "pnpm build"],
+ ["powershell.exe -Command \"python C:\\work\\scrape.py\"", "scrape.py"],
+ ["python app.py 2>&1 | tee run.log", "app.py"],
+ ])("%s → %s", (command, target) => {
+ expect(commandTarget(command)).toBe(target);
+ });
+
+ it("never names an environment value, even one with no credential shape", () => {
+ expect(commandTarget("DATABASE_URL=postgres://ada:hunter2@db/leads REGION=eu python3 scrape.py")).toBe("scrape.py");
+ expect(commandTarget("export API_HOST=internal.example && env -i FOO=bar node run.js")).toBe("run.js");
+ expect(commandTarget("make deploy STAGE=prod")).toBe("make deploy");
+ });
+
+ it("keeps a long name to the cap", () => {
+ const target = commandTarget(`python3 ${"very_long_script_name_".repeat(6)}.py`)!;
+ expect(target.length).toBeLessThanOrEqual(STEP_TARGET_MAX);
+ expect(target.endsWith("…")).toBe(true);
+ });
+});
+
+describe("maskAssignments", () => {
+ it("keeps each name and drops its value", () => {
+ expect(maskAssignments("FOO=bar BAZ=\"two words\" python x.py --flag=keep")).toBe("FOO=… BAZ=… python x.py --flag=keep");
+ expect(maskAssignments("export TOKEN=abc && make PROFILE=release")).toBe("export TOKEN=… && make PROFILE=…");
+ });
+});
+
+describe("toolStep", () => {
+ it("names a command by its program and target, with the whole command for the hover", () => {
+ expect(toolStep(claudeBash("cd ~/projects/biber && python3 scrape.py --pages 40"))).toEqual({
+ activity: "command", target: "scrape.py", detail: "cd ~/projects/biber && python3 scrape.py --pages 40",
+ });
+ expect(toolStep(claudeBash("pnpm test"))).toEqual({ activity: "command", target: "pnpm test" });
+ });
+
+ it("sends no secret and no environment value, only redacted text", () => {
+ const step = toolStep(claudeBash("OPENAI_API_KEY=sk-proj-abcdefghijklmnopqrstuvwxyz0123 SECRET=hunter2 curl -H 'Authorization: Bearer abcdefghijklmnop123456' https://api.example.com/v1/run?token=abcdefgh12345678"));
+ const shown = JSON.stringify(step);
+ expect(step?.target).toBe("curl api.example.com");
+ for (const secret of ["sk-proj-abcdefghijklmnopqrstuvwxyz0123", "hunter2", "abcdefghijklmnop123456", "abcdefgh12345678"]) {
+ expect(shown).not.toContain(secret);
+ }
+ expect(step?.detail).toContain("OPENAI_API_KEY=… SECRET=… curl");
+ });
+
+ it("redacts again whatever reaches it, a query and a page too", () => {
+ const raw = "curl -H 'Authorization: Bearer abcdefghijklmnopqrstuvwxyz123456' https://api.example.com/run";
+ expect(JSON.stringify(toolStep({ title: "Bash", summary: raw }))).not.toContain("abcdefghijklmnopqrstuvwxyz123456");
+ expect(JSON.stringify(toolStep({ title: "WebSearch", input: JSON.stringify({ query: "token sk-ant-abcdefghijklmnopqrstuvwx leaked" }) }))).not.toContain("sk-ant-abcdefghijklmnopqrstuvwx");
+ expect(JSON.stringify(toolStep({ title: "WebFetch", input: JSON.stringify({ url: "https://ada:[email protected]/a?token=abcdefgh12345678" }) })))
+ .not.toMatch(/hunter2secret|abcdefgh12345678/);
+ });
+
+ it("caps the hover text", () => {
+ const step = toolStep(claudeBash(`python3 scrape.py ${"--page 1 ".repeat(80)}`))!;
+ expect(step.detail!.length).toBeLessThanOrEqual(200);
+ });
+
+ it("reads every engine's call the same way", () => {
+ const codexCommand = "/bin/zsh -lc 'python3 scrape.py --pages 40'";
+ expect(toolStep({ title: codexCommand, summary: commandSummary({ command: codexCommand }), input: toolDetailPreview({ command: codexCommand, cwd: "/w" }) })?.target).toBe("scrape.py");
+ const acp = { command: "python3 scrape.py", description: "Scrape" };
+ expect(toolStep({ title: "python3 scrape.py", summary: commandSummary(acp), input: toolDetailPreview(acp) })?.target).toBe("scrape.py");
+ expect(toolStep({ title: "WebSearch", input: toolDetailPreview({ query: "Biber Dammbau" }) })).toEqual({ activity: "web", target: "Biber Dammbau" });
+ expect(toolStep({ title: "web_search", input: toolDetailPreview("Biber Dammbau") })).toEqual({ activity: "web", target: "Biber Dammbau" });
+ expect(toolStep({ title: "google_web_search", input: toolDetailPreview({ query: "Biber Dammbau" }) })?.target).toBe("Biber Dammbau");
+ expect(toolStep({ title: "WebFetch", input: toolDetailPreview({ url: "https://www.linkedin.com/company/biber/about?trk=x", prompt: "Summarise" }) }))
+ .toEqual({ activity: "fetch", target: "linkedin.com", detail: "linkedin.com/company/biber/about" });
+ expect(toolStep({ title: "web_fetch", input: toolDetailPreview({ url: "https://ada:[email protected]/" }) })).toEqual({ activity: "fetch", target: "example.org" });
+ expect(toolStep({ title: "Write", input: toolDetailPreview({ file_path: "/work/report.md", content: "x" }) })).toEqual({ activity: "write", target: "report.md" });
+ expect(toolStep({ title: "edit", input: toolDetailPreview([{ path: "/w/web/index.html", kind: { type: "update" }, diff: "-a\n+b" }]) }))
+ .toEqual({ activity: "edit", target: "index.html" });
+ });
+
+ it("cuts a long query to the cap and keeps the rest for the hover", () => {
+ const query = "Biber Dammbau Genehmigung Niedersachsen Landkreis Wolfsburg Bauantrag Fristen 2026";
+ const step = toolStep({ title: "WebSearch", input: toolDetailPreview({ query }) })!;
+ expect(step.target.length).toBeLessThanOrEqual(STEP_TARGET_MAX);
+ expect(step.detail).toBe(query);
+ });
+
+ it("says nothing it cannot read", () => {
+ expect(toolStep({ title: "mcp__agents__ask_bot", input: toolDetailPreview({ bot: "Kai" }) })).toBeUndefined();
+ expect(toolStep({ title: "WebFetch", input: toolDetailPreview({ url: "file:///etc/passwd" }) })).toBeUndefined();
+ expect(toolStep({ title: "WebSearch" })).toBeUndefined();
+ });
+});
diff --git a/server/step-summary.ts b/server/step-summary.ts
new file mode 100644
index 0000000000..822826a728
--- /dev/null
+++ b/server/step-summary.ts
@@ -0,0 +1,276 @@
+// Security: every word here comes from the call's display summary and input preview, which are already redacted, and is
+// redacted again before it is cut. An environment assignment's value never leaves: the target skips assignments and the
+// detail masks their values.
+import { progressFile, type LiveStep } from "../shared/turn-progress.ts";
+import { redactSecretsInText } from "./redact.ts";
+import { COMMAND_SUMMARY_MAX } from "./tool-summary.ts";
+
+export const STEP_TARGET_MAX = 60;
+const ARG_MAX = 40;
+
+const cut = (text: string, limit: number): string => {
+ const clean = redactSecretsInText(text.replace(/\p{Cc}+/gu, " ").replace(/\s+/g, " ").trim());
+ return clean.length > limit ? `${clean.slice(0, limit - 1).trimEnd()}…` : clean;
+};
+
+const ASSIGNMENT = /(^|[\s;&|(`])([A-Za-z_][A-Za-z0-9_]*)=(?:«redacted \d+ chars»|"(?:[^"\\]|\\.)*"|'[^']*'|[^\s;&|)`]*)/g;
+
+export function maskAssignments(command: string): string {
+ return command.replace(ASSIGNMENT, "$1$2=…");
+}
+
+function splitSegments(command: string): string[] {
+ const out: string[] = [];
+ let current = "";
+ let quote: string | null = null;
+ let depth = 0;
+ for (let i = 0; i < command.length; i++) {
+ const c = command[i]!;
+ if (quote) {
+ current += c;
+ if (c === quote) quote = null;
+ else if (c === "\\" && quote === "\"" && i + 1 < command.length) current += command[++i];
+ continue;
+ }
+ if (c === "'" || c === "\"" || c === "`") { quote = c; current += c; continue; }
+ if (c === "\\" && i + 1 < command.length) { current += c + command[++i]; continue; }
+ if (c === "(") depth++;
+ else if (c === ")") depth = Math.max(0, depth - 1);
+ const redirect = c === "&" && (command[i - 1] === ">" || command[i - 1] === "<" || command[i + 1] === ">");
+ if (depth === 0 && !redirect && (c === ";" || c === "|" || c === "&" || c === "\n")) {
+ out.push(current);
+ current = "";
+ continue;
+ }
+ current += c;
+ }
+ out.push(current);
+ return out.map((segment) => segment.trim()).filter(Boolean);
+}
+
+// A backslash escapes only what a POSIX shell would otherwise read as syntax, so a Windows path keeps its separators.
+const ESCAPED_IN_QUOTES = new Set(["\"", "\\", "$", "`"]);
+const ESCAPED_BARE = new Set([...ESCAPED_IN_QUOTES, "'", " ", "&", "|", ";", "(", ")", "<", ">"]);
+
+function splitWords(segment: string): string[] {
+ const out: string[] = [];
+ let word = "";
+ let started = false;
+ let quote: string | null = null;
+ for (let i = 0; i < segment.length; i++) {
+ const c = segment[i]!;
+ if (quote) {
+ if (c === quote) quote = null;
+ else if (c === "\\" && quote === "\"" && ESCAPED_IN_QUOTES.has(segment[i + 1] ?? "")) word += segment[++i];
+ else word += c;
+ continue;
+ }
+ if (c === "'" || c === "\"") { quote = c; started = true; continue; }
+ if (c === "\\" && ESCAPED_BARE.has(segment[i + 1] ?? "")) { word += segment[++i]; started = true; continue; }
+ if (/\s/.test(c)) {
+ if (started) out.push(word);
+ word = "";
+ started = false;
+ continue;
+ }
+ word += c;
+ started = true;
+ }
+ if (started) out.push(word);
+ return out;
+}
+
+const isAssignment = (word: string) => /^[A-Za-z_][A-Za-z0-9_]*=/.test(word);
+const isFlag = (word: string) => word.startsWith("-") && word.length > 1;
+const baseName = (word: string) => word.replace(/[\\/]+$/, "").split(/[\\/]/).pop() ?? word;
+const programName = (word: string) => baseName(word).replace(/\.exe$/i, "");
+
+const SHELLS = new Set(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
+const WRAPPER_VALUE_FLAGS: Record<string, string> = { sudo: "ugCDhprtUT", doas: "uC", env: "uSC", nice: "n", ionice: "cnp", timeout: "sk", stdbuf: "ioe" };
+const WRAPPERS = new Set([...Object.keys(WRAPPER_VALUE_FLAGS), "nohup", "time", "exec", "command", "builtin", "caffeinate", "xvfb-run", "chronic", "unbuffer"]);
+const PREPARING = new Set(["cd", "pushd", "popd", "export", "set", "unset", "source", ".", "alias", "true", ":", "shopt", "ulimit",
+ "umask", "trap", "mkdir", "touch", "clear", "nvm", "pyenv", "conda", "deactivate", "chmod", "eval"]);
+const PLUMBING = new Set(["echo", "printf", "cat", "tee", "head", "tail", "grep", "egrep", "rg", "sort", "uniq", "wc", "sed", "awk",
+ "cut", "tr", "jq", "xargs", "less", "more", "column", "sleep", "date", "wait", "test", "[", "ls", "pwd", "which"]);
+const INTERPRETER = /^(?:python[0-9.]*|pypy[0-9.]*|node|nodejs|deno|bun|ruby|perl|php|Rscript|tsx|ts-node|osascript|pwsh|powershell|cmd|lua|julia|java|sh|bash|zsh|dash|ksh|fish)$/i;
+const RUNNERS = new Set(["npm", "pnpm", "yarn", "bun", "uv", "poetry", "pdm", "hatch", "deno", "pipenv", "rye"]);
+const RUNNER_VERBS = new Set(["run", "exec", "x", "dlx", "run-script", "task"]);
+const SCRIPT = /\.(?:py|js|mjs|cjs|ts|mts|tsx|sh|bash|zsh|rb|pl|php|lua|r|jl|ps1|jar)$/i;
+
+function programOf(words: string[]): { name: string; args: string[] } | undefined {
+ let i = 0;
+ for (;;) {
+ while (i < words.length && isAssignment(words[i]!)) i++;
+ const word = words[i];
+ if (word === undefined) return undefined;
+ const name = programName(word);
+ if (!WRAPPERS.has(name)) return { name, args: words.slice(i + 1) };
+ i++;
+ while (i < words.length && (isFlag(words[i]!) || isAssignment(words[i]!))) {
+ const flag = words[i++]!;
+ if (/^-[A-Za-z]$/.test(flag) && (WRAPPER_VALUE_FLAGS[name]?.includes(flag[1]!) || /^\d[\w.]*$/.test(words[i] ?? ""))) i++;
+ }
+ if (name === "timeout" && /^\d+(?:\.\d+)?[smhd]?$/.test(words[i] ?? "")) i++;
+ }
+}
+
+function plainArgs(args: string[]): string[] {
+ const out: string[] = [];
+ for (let i = 0; i < args.length; i++) {
+ const word = args[i]!;
+ if (word === "--") continue;
+ if (isFlag(word)) {
+ if (/^-[A-Za-z]$/.test(word) && /^\d[\w.]*$/.test(args[i + 1] ?? "")) i++;
+ continue;
+ }
+ if (isAssignment(word) || !word.trim()) continue;
+ out.push(word);
+ }
+ return out;
+}
+
+function siteOf(raw: string): string | undefined {
+ if (!/^https?:\/\//i.test(raw)) return undefined;
+ try {
+ const host = new URL(raw).hostname.replace(/^www\./i, "");
+ return host || undefined;
+ } catch {
+ return undefined;
+ }
+}
+
+function shortArg(word: string): string {
+ const site = siteOf(word);
+ if (site) return site;
+ const name = /[\\/]/.test(word) ? baseName(word) : word;
+ return name.length > ARG_MAX ? `${name.slice(0, ARG_MAX - 1)}…` : name;
+}
+
+const INLINE_SCRIPT: Record<string, RegExp> = { pwsh: /^-(?:c|command)$/i, powershell: /^-(?:c|command)$/i, cmd: /^\/c$/i };
+
+function interpreterTarget(name: string, args: string[]): string {
+ const inlineFlag = SHELLS.has(name) ? /^-[a-z]*c[a-z]*$/ : INLINE_SCRIPT[name.toLowerCase()];
+ const inline = inlineFlag ? args.findIndex((word) => inlineFlag.test(word)) : -1;
+ if (inline >= 0 && args[inline + 1]) return commandTarget(args.slice(inline + 1).join(" ")) ?? name;
+ for (let i = 0; i < args.length; i++) {
+ const word = args[i]!;
+ if (word === "-m" && args[i + 1]) return args[i + 1]!;
+ if (word === "-c" || word === "-e" || word === "--eval" || word === "-p" || word === "--print") return name;
+ if (word === "-jar" && args[i + 1]) return baseName(args[i + 1]!);
+ if (/^-[WXI]$/.test(word)) { i++; continue; }
+ if (isFlag(word)) continue;
+ if ((name === "deno" || name === "bun") && /^(?:run|test|task)$/.test(word)) {
+ const rest = plainArgs(args.slice(i + 1));
+ return rest[0] ? (SCRIPT.test(rest[0]) ? baseName(rest[0]) : `${name} ${word} ${shortArg(rest[0])}`) : `${name} ${word}`;
+ }
+ return SCRIPT.test(word) || /[\\/]/.test(word) ? baseName(word) : name === "bun" ? `bun ${shortArg(word)}` : baseName(word);
+ }
+ return name;
+}
+
+function segmentTarget(segment: string): string | undefined {
+ const inner = /^\((.*)\)$/s.exec(segment.trim());
+ if (inner) return commandTarget(inner[1]!);
+ const program = programOf(splitWords(segment));
+ if (!program) return undefined;
+ const { name, args } = program;
+ if (!name) return undefined;
+ if (SCRIPT.test(name)) return name;
+ if (INTERPRETER.test(name)) return interpreterTarget(name, args);
+ const plain = plainArgs(name === "git" ? args.filter((_, i) => !/^-[Cc]$/.test(args[i - 1] ?? "")) : args);
+ const site = plain.map(siteOf).find(Boolean);
+ if (site) return `${name} ${site}`;
+ const first = plain[0];
+ if (!first) return name;
+ if (RUNNERS.has(name) && RUNNER_VERBS.has(first) && plain[1]) return `${name} ${first} ${shortArg(plain[1])}`;
+ return `${name} ${shortArg(first)}`;
+}
+
+const segmentProgram = (segment: string) => programOf(splitWords(segment.replace(/^\(/, "")))?.name ?? "";
+
+export function commandTarget(command: string): string | undefined {
+ const segments = splitSegments(command.replace(/«redacted \d+ chars»/g, "«redacted»"));
+ if (!segments.length) return undefined;
+ const names = segments.map(segmentProgram);
+ const main = names.findIndex((name) => name && !PREPARING.has(name) && !PLUMBING.has(name));
+ const fallback = names.findIndex((name) => name && !PREPARING.has(name));
+ const target = segmentTarget(segments[main >= 0 ? main : fallback >= 0 ? fallback : 0]!);
+ return target ? cut(target, STEP_TARGET_MAX) : undefined;
+}
+
+function parsedInput(input: string | undefined): Record<string, unknown> | string | undefined {
+ if (!input?.trim()) return undefined;
+ try {
+ const value: unknown = JSON.parse(input);
+ if (typeof value === "string") return value;
+ if (value && typeof value === "object") return value as Record<string, unknown>;
+ } catch {}
+ return input;
+}
+
+function inputField(parsed: Record<string, unknown> | string | undefined, names: readonly string[]): string | undefined {
+ for (const name of names) {
+ if (parsed && typeof parsed === "object") {
+ const value = parsed[name];
+ if (typeof value === "string" && value.trim()) return value;
+ continue;
+ }
+ const match = typeof parsed === "string" ? new RegExp(`"${name}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`).exec(parsed) : null;
+ if (!match) continue;
+ try {
+ const value = JSON.parse(`"${match[1]}"`) as string;
+ if (value.trim()) return value;
+ } catch {}
+ }
+ return undefined;
+}
+
+function firstChangedPath(parsed: Record<string, unknown> | string | undefined): { path: string; added: boolean } | undefined {
+ if (!Array.isArray(parsed)) return undefined;
+ const changes = parsed as Array<{ path?: unknown; kind?: { type?: unknown } } | null>;
+ const first = changes.find((change) => typeof change?.path === "string");
+ if (!first) return undefined;
+ return { path: first.path as string, added: changes.every((change) => change?.kind?.type === "add") };
+}
+
+const WEB_SEARCH = /web.?search|search.?(?:the.?)?web|google.?search|brave.?search|bing.?search|tavily|exa.?search|duckduckgo|perplexity|internet.?search/i;
+const FETCH = /fetch|read.?page|read.?url|get.?page|scrape|crawl/i;
+const WRITE = /^(?:write|write.?file|create.?file)$/i;
+const EDIT = /^(?:edit|multi.?edit|notebook.?edit|str.?replace|replace|apply.?patch)$/i;
+const READ = /^(?:read|read.?file|view|open.?file)$/i;
+
+function withDetail(step: LiveStep, detail: string | undefined): LiveStep {
+ const shown = detail ? cut(detail, COMMAND_SUMMARY_MAX) : "";
+ return shown && shown !== step.target ? { ...step, detail: shown } : step;
+}
+
+export function toolStep(call: { title?: string; summary?: string; input?: string }): LiveStep | undefined {
+ const title = (call.title ?? "").replace(/^mcp__.+?__/, "").trim();
+ const parsed = parsedInput(call.input);
+ if (call.summary?.trim()) {
+ const target = commandTarget(call.summary);
+ return target ? withDetail({ activity: "command", target }, maskAssignments(call.summary)) : undefined;
+ }
+ if (WEB_SEARCH.test(title)) {
+ const query = typeof parsed === "string" && !parsed.trimStart().startsWith("{") ? parsed : inputField(parsed, ["query", "q", "search_query", "searchQuery"]);
+ if (!query) return undefined;
+ const target = cut(query, STEP_TARGET_MAX);
+ return target ? withDetail({ activity: "web", target }, query) : undefined;
+ }
+ const url = inputField(parsed, ["url", "uri", "href", "link"]);
+ if (url && FETCH.test(title)) {
+ const site = siteOf(url.trim());
+ if (!site) return undefined;
+ const { hostname, pathname } = new URL(url.trim());
+ return withDetail({ activity: "fetch", target: cut(site, STEP_TARGET_MAX) }, `${hostname.replace(/^www\./i, "")}${pathname === "/" ? "" : pathname}`);
+ }
+ const changed = title === "edit" ? firstChangedPath(parsed) : undefined;
+ if (changed) {
+ const file = progressFile(changed.path);
+ return file ? { activity: changed.added ? "write" : "edit", target: cut(file, STEP_TARGET_MAX) } : undefined;
+ }
+ const activity = WRITE.test(title) ? "write" : EDIT.test(title) ? "edit" : READ.test(title) ? "read" : null;
+ if (!activity) return undefined;
+ const file = progressFile(inputField(parsed, ["file_path", "notebook_path", "path", "filePath", "file"]));
+ return file ? { activity, target: cut(file, STEP_TARGET_MAX) } : undefined;
+}
diff --git a/server/testing/fake-acp-cli.ts b/server/testing/fake-acp-cli.ts
index 20ed66f40a..532d6678b8 100755
--- a/server/testing/fake-acp-cli.ts
+++ b/server/testing/fake-acp-cli.ts
@@ -16,7 +16,7 @@
// MCP; FAKE_ACP_REDELEGATE_FILE, FAKE_ACP_TASKID_FILE; a hand-off result wake gets a fixed line)
// | echo-gated (echo the whole prompt; hold until FAKE_ACP_GATE_FILE exists) | safe-agent-reads
// | stall-after-text | stall-after-tool (then silent forever) | slow-tool (silent for FAKE_ACP_TOOL_MS, or until
-// FAKE_ACP_TOOL_GATE exists when set)
+// FAKE_ACP_TOOL_GATE exists when set; FAKE_ACP_TOOL_OUTPUT is the text its running call shows meanwhile)
// | quiet-then-answer (silent for FAKE_ACP_QUIET_MS; with QWEN_HOME, append FAKE_ACP_QWEN_LOG lines to
// Qwen's debug log every FAKE_ACP_LOG_EVERY_MS; with XDG_DATA_HOME, append FAKE_ACP_OPENCODE_LOG lines once to
// OpenCode's shared log, {session} replaced by the session id) | mcp-tools (list each mcpServers entry's tools with
@@ -924,7 +924,8 @@ function handle(msg: any) {
out({ jsonrpc: "2.0", method: "session/update", params: { update: { toolCallId: "tc-slow", ...update } } });
// ACP's default status is pending: this tool_call carries none.
tool({ sessionUpdate: "tool_call", title: "sleep", kind: "execute", rawInput: { command: "sleep 45 && echo done" } });
- tool({ sessionUpdate: "tool_call_update", status: "in_progress" });
+ const printed = process.env.FAKE_ACP_TOOL_OUTPUT;
+ tool({ sessionUpdate: "tool_call_update", status: "in_progress", ...(printed ? { content: [{ type: "content", content: { type: "text", text: printed } }] } : {}) });
const finish = () => tool({ sessionUpdate: "tool_call_update", status: "completed", rawOutput: { output: "done" } });
if (mode === "stall-after-tool") {
finish();
diff --git a/server/testing/fake-claude-cli.ts b/server/testing/fake-claude-cli.ts
index 1296771fea..82fabbe8c7 100755
--- a/server/testing/fake-claude-cli.ts
+++ b/server/testing/fake-claude-cli.ts
@@ -10,7 +10,7 @@
// FAKE_CLAUDE_RATE_LIMIT JSON rate_limit_info reported in a `rate_limit_event` after init
// FAKE_CLAUDE_LIMITED_FILE path: while it exists, every turn plays usage-limit with the file's JSON rate_limit_info
// FAKE_CLAUDE_MCP_FAILED comma list of MCP servers init reports as failed (`mcp_servers`)
-// FAKE_CLAUDE_RELEASE with hang: the turn ends normally once this file exists
+// FAKE_CLAUDE_RELEASE with hang: the turn ends normally once this file exists; a scripted call's `hold` ends then too
// FAKE_CLAUDE_DUMP path for the latest turn's {argv, env, cwd, prompt, systemPrompt, mcpConfig}
// FAKE_CLAUDE_EXIT_AFTER_TURN 1: exit once the turn is answered, so later turns relaunch with --resume
// FAKE_CLAUDE_AUTH_AFTER_TURN 1: from the second turn, answer as not-logged-in; FAKE_CLAUDE_AUTH_AFTER_WORK 1: not-logged-in
@@ -30,7 +30,10 @@
// FAKE_CLAUDE_CHECK fail | hang: how the connection check answers (default OK)
// FAKE_CLAUDE_REPLIES JSON array of replies (string, or string[] for several items) used in order
// FAKE_CLAUDE_REPLY_STATE counter file keeping FAKE_CLAUDE_REPLIES in order across processes
-// FAKE_CLAUDE_TOOL_CALLS JSON [{name, input?, ok?}] each turn calls before its reply (unset: one Bash call)
+// FAKE_CLAUDE_TOOL_CALLS JSON [{name, input?, ok?, hold?}] each turn calls before its reply (unset: one Bash call). A call
+// with `hold` keeps running until FAKE_CLAUDE_RELEASE exists, sending a tool_progress every FAKE_CLAUDE_TOOL_PROGRESS_MS
+// (default 30000) as 2.1.306 does; hold "busy" | "idle" | "network" also keeps a stand-in child process that burns CPU,
+// sleeps, or holds a loopback TCP connection, as the call's command would
// FAKE_CLAUDE_TOOL_CALLS_FILE path of the same JSON, read again each turn (a warm process's turns differ); missing: none
// FAKE_CLAUDE_STREAM_CADENCE "chars:ms" (happy mode): stream each scripted reply as
// text_delta chunks of `chars` chars every `ms` ms before its assistant message
@@ -71,7 +74,7 @@
// environment); FAKE_CLAUDE_SHELL_LOG path: each such call appends {command, output}
// total_cost_usd and modelUsage are running totals (0.01 per result), as the real CLI reports them.
import { splitLaunchNote } from "./launch-note.ts";
-import { spawnSync } from "node:child_process";
+import { spawn, spawnSync, type ChildProcess } from "node:child_process";
import { appendFileSync, closeSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
import { homedir } from "node:os";
import { dirname, join } from "node:path";
@@ -136,14 +139,16 @@ const scriptedReplies = (() => {
return [];
}
})();
-type ScriptedToolCall = { name: string; id?: string; input: Record<string, unknown>; ok: boolean; output?: unknown; server?: string };
+type ScriptedHold = true | "busy" | "idle" | "network";
+type ScriptedToolCall = { name: string; id?: string; input: Record<string, unknown>; ok: boolean; output?: unknown; server?: string; hold?: ScriptedHold };
+const HOLDS = new Set<unknown>([true, "busy", "idle", "network"]);
const parseToolCalls = (raw: string | undefined): ScriptedToolCall[] | null => {
if (raw === undefined) return null;
try {
const parsed = JSON.parse(raw);
if (!Array.isArray(parsed)) return null;
return parsed
- .filter((call): call is { name: string; id?: unknown; input?: unknown; ok?: unknown; output?: unknown; server?: unknown } => typeof call?.name === "string")
+ .filter((call): call is { name: string; id?: unknown; input?: unknown; ok?: unknown; output?: unknown; server?: unknown; hold?: unknown } => typeof call?.name === "string")
.map((call) => ({
name: call.name,
...(typeof call.id === "string" ? { id: call.id } : {}),
@@ -151,6 +156,7 @@ const parseToolCalls = (raw: string | undefined): ScriptedToolCall[] | null => {
ok: call.ok !== false,
output: call.output,
...(typeof call.server === "string" ? { server: call.server } : {}),
+ ...(HOLDS.has(call.hold) ? { hold: call.hold as ScriptedHold } : {}),
}));
} catch {
return null;
@@ -706,6 +712,55 @@ const runBash = (command: string): { ok: boolean; content: string } => {
return { ok: ran.status === 0, content: output };
};
+// Each stand-in exits once this CLI is gone, so a killed fixture never leaves one behind.
+const ORPHAN_EXIT = "const parent = process.ppid; const orphaned = () => { try { process.kill(parent, 0); return false; } catch { return true; } };";
+const STAND_INS: Record<Exclude<ScriptedHold, true>, string> = {
+ busy: `${ORPHAN_EXIT} let checked = Date.now(); for (;;) { if (Date.now() - checked > 500) { checked = Date.now(); if (orphaned()) process.exit(0); } }`,
+ idle: `${ORPHAN_EXIT} setInterval(() => { if (orphaned()) process.exit(0); }, 500);`,
+ network: `${ORPHAN_EXIT} const net = require("node:net"); const server = net.createServer(() => {}).listen(0, "127.0.0.1", () => { net.connect(server.address().port, "127.0.0.1"); }); setInterval(() => { if (orphaned()) process.exit(0); }, 500);`,
+};
+
+/** The scripted calls in order, each streamed as 2.1.306 does with --include-partial-messages and each held one running
+ * until FAKE_CLAUDE_RELEASE exists. */
+const playHeldCalls = (calls: ScriptedToolCall[], usage: object, done: () => void) => {
+ const progressMs = Number(process.env.FAKE_CLAUDE_TOOL_PROGRESS_MS) || 30_000;
+ const event = (e: unknown) => out({ type: "stream_event", event: e, parent_tool_use_id: null, session_id: "fake-session" });
+ const next = (index: number) => {
+ const call = calls[index];
+ if (!call) return done();
+ const id = call.id ?? `tu-${process.pid}-${++toolUseCount}`;
+ event({ type: "message_start", message: { id: `msg-${id}`, usage } });
+ event({ type: "content_block_start", index: 0, content_block: { type: "tool_use", id, name: call.name, input: {} } });
+ event({ type: "content_block_delta", index: 0, delta: { type: "input_json_delta", partial_json: JSON.stringify(call.input) } });
+ event({ type: "content_block_stop", index: 0 });
+ out({ type: "assistant", message: { id: `msg-${id}`, content: [{ type: "tool_use", id, name: call.name, input: call.input }], usage } });
+ event({ type: "message_stop" });
+ const answer = () => {
+ out({ type: "user", message: { content: [{ type: "tool_result", tool_use_id: id, is_error: !call.ok, content: call.output ?? "" }] } });
+ // A model takes a moment to write its next call; back-to-back frames would only test the coalescing.
+ setTimeout(() => next(index + 1), 600);
+ };
+ if (!call.hold) return answer();
+ const standIn: ChildProcess | null = call.hold === true ? null : spawn(process.execPath, ["-e", STAND_INS[call.hold]], { stdio: "ignore" });
+ const startedAt = Date.now();
+ let beats = 0;
+ const poll = setInterval(() => {
+ const elapsed = Date.now() - startedAt;
+ if (elapsed >= (beats + 1) * progressMs) {
+ out({ type: "tool_progress", tool_use_id: `${id}-heartbeat-${beats}`, tool_name: call.name, parent_tool_use_id: id,
+ elapsed_time_seconds: Math.round(elapsed / 1000), heartbeat: true });
+ beats += 1;
+ }
+ const release = process.env.FAKE_CLAUDE_RELEASE;
+ if (!release || !existsSync(release)) return;
+ clearInterval(poll);
+ standIn?.kill();
+ answer();
+ }, 100);
+ };
+ next(0);
+};
+
const playTurn = (prompt: JsonValue, late = false) => {
turnRunning = true;
lateContinuation = late;
@@ -1017,6 +1072,13 @@ const playTurn = (prompt: JsonValue, late = false) => {
return;
}
const scriptedToolCalls = turnToolCalls();
+ if (scriptedToolCalls?.some((call) => call.hold)) {
+ playHeldCalls(scriptedToolCalls, usage, () => {
+ for (const text of replyParts) out({ type: "assistant", message: { content: [{ type: "text", text }], usage } });
+ finish();
+ });
+ return;
+ }
if (scriptedToolCalls) {
const failureContext: string[] = [];
for (const call of scriptedToolCalls) {
diff --git a/server/testing/fake-codex-app-server.ts b/server/testing/fake-codex-app-server.ts
index a435e09613..41929842c9 100755
--- a/server/testing/fake-codex-app-server.ts
+++ b/server/testing/fake-codex-app-server.ts
@@ -20,6 +20,9 @@
// FAKE_CODEX_DUMP path for {pid, argv, env, calls, decision}
// FAKE_CODEX_ACTION_LOG early-tool-timeout/error: append an action before turn/start times out or fails
// FAKE_CODEX_ECHO_INPUT "1": echo turn/start's input back as a userMessage item, as codex-cli 0.164.0 does
+// FAKE_CODEX_COMMAND the happy turn's one call, this command (default: "ls -la" and a web search);
+// FAKE_CODEX_COMMAND_OUTPUT JSON chunks it prints as item/commandExecution/outputDelta notifications, one every
+// FAKE_CODEX_COMMAND_OUTPUT_MS (default all at once); FAKE_CODEX_COMMAND_GATE the turn finishes once this file exists
// FAKE_CODEX_PATCH_BYTES each turn first writes web/index.html by apply_patch, streamed as two
// item/fileChange/patchUpdated notifications (codex-cli 0.160.1's schema) of half and all this many bytes
// FAKE_CODEX_IGNORE_FEATURES "1": config/read reports no `-c features.*` override
@@ -831,9 +834,16 @@ process.stdin.on("data", (chunk) => {
"-Command",
`"Get-Content -Raw -LiteralPath 'C:\\Users\\Ada\\workspaces\\${"very-long-folder\\".repeat(8)}NOTES.md'"`,
].join(" ")
- : "ls -la";
+ : process.env.FAKE_CODEX_COMMAND || "ls -la";
notify("item/started", { item: { id: "i1", type: "commandExecution", command } });
- notify("item/started", { item: { id: "w1", type: "webSearch", query: "OpenMausBot" } });
+ const printed = JSON.parse(process.env.FAKE_CODEX_COMMAND_OUTPUT ?? "[]") as string[];
+ const every = Number(process.env.FAKE_CODEX_COMMAND_OUTPUT_MS) || 0;
+ printed.forEach((delta, index) => {
+ const print = () => notify("item/commandExecution/outputDelta", { itemId: "i1", delta });
+ if (every > 0) setTimeout(print, every * (index + 1));
+ else print();
+ });
+ if (!process.env.FAKE_CODEX_COMMAND) notify("item/started", { item: { id: "w1", type: "webSearch", query: "OpenMausBot" } });
const reviewOnce = process.env.FAKE_CODEX_REVIEW_ONCE_FILE;
if (process.env.FAKE_CODEX_REVIEW_EVENTS && (!reviewOnce || !existsSync(reviewOnce))) {
if (reviewOnce) writeFileSync(reviewOnce, "1");
@@ -972,6 +982,8 @@ process.stdin.on("data", (chunk) => {
? JSON.parse(process.env.FAKE_CODEX_APPROVAL_REQUEST)
: { method: "execCommandApproval", params: { command: approvalCommand } };
out({ jsonrpc: "2.0", id: 100, ...approval });
+ } else if (process.env.FAKE_CODEX_COMMAND_GATE) {
+ void waitForGate(process.env.FAKE_CODEX_COMMAND_GATE, 10 * 60_000).then(() => finishTurn());
} else {
finishTurn();
if (process.env.FAKE_CODEX_REVIEW_AFTER_COMPLETION) {
diff --git a/shared/runtime-events.ts b/shared/runtime-events.ts
index 1c50488ac2..4024eeb19f 100644
--- a/shared/runtime-events.ts
+++ b/shared/runtime-events.ts
@@ -1,7 +1,7 @@
/** Canonical runtime-event shapes, as they ride the live wire and the
* inspector log. */
import type { AskQuestion } from "./ask-question.ts";
-import type { TurnProgressFields } from "./turn-progress.ts";
+import type { LiveStep, TurnProgressFields } from "./turn-progress.ts";
export type DriverKind = string;
export type InstanceId = string;
@@ -106,8 +106,13 @@ export type RuntimeEvent = RuntimeEventBase &
summary?: string;
/** Bounded, redacted display preview; never raw tool arguments. */
input?: string;
+ /** What the call works on, read from `summary` and `input` as the event passes the bus. */
+ step?: LiveStep;
}
| { type: "item.updated"; itemType: "tool" | "reasoning"; tokens?: number | null }
+ /** Output a running call printed, as its engine streams it: a chunk to append, or with `whole` all of it so far.
+ * Live only: the bus folds it into the status line's `tail` and never logs or forwards it. */
+ | { type: "item.output"; itemType: "tool"; text: string; whole?: boolean }
/** What the engine is doing right now (a tool call being written or run), for the chat's status line. Live only:
* the bus coalesces it and never writes it to the event log; nothing stores it. */
| Omit<TurnProgressFields, "itemId">
diff --git a/shared/turn-progress.ts b/shared/turn-progress.ts
index 97b6041acc..0cc6e1e1aa 100644
--- a/shared/turn-progress.ts
+++ b/shared/turn-progress.ts
@@ -5,6 +5,22 @@
* web, reading a file or a page, searching files, or any other tool. */
export type TurnProgressActivity = "write" | "edit" | "command" | "web" | "read" | "fetch" | "search" | "tool";
+/** What one tool call works on, in the words the status line, its chip and the sidebar use: a command's program and
+ * main target ("scrape.py", "pnpm test"), a web search's query, a page's site, a file's name. Server-made from redacted
+ * text and redacted again: never an environment variable's value or a credential. */
+export interface LiveStep {
+ activity: TurnProgressActivity;
+ /** At most 60 characters. */
+ target: string;
+ /** The whole command, query or page address the target was read from, environment values left out; at most 200
+ * characters, and absent when it says no more than the target. */
+ detail?: string;
+}
+
+/** How a call that has run a while is doing: when its output last arrived (epoch ms), or, while it has sent none, what
+ * its processes show: holding a network connection, using the CPU, or neither. */
+export type StepQuiet = { kind: "output"; at: number } | { kind: "network" | "busy" | "idle" };
+
export interface TurnProgressFields {
type: "turn.progress";
activity: TurnProgressActivity;
@@ -15,6 +31,14 @@ export interface TurnProgressFields {
/** Bytes of the call's input generated so far: for a write, about the size of the file. */
bytes?: number;
itemId?: string;
+ /** The call's LiveStep target, once the server has read one from the call. */
+ target?: string;
+ /** The call's LiveStep detail, for the phrase's tooltip. */
+ detail?: string;
+ /** Set once the call has run past the quiet notice. */
+ quiet?: StepQuiet;
+ /** A running command's last lines of output, redacted, oldest first. */
+ tail?: string[];
}
const KB = 1024;
@@ -36,7 +60,9 @@ export function progressFile(path: unknown): string | undefined {
}
/** Two reports that read the same on screen share a key, so only a visible change is worth a frame. */
-export function progressKey(event: { turnId?: string; itemId?: string; activity: string; tool?: string; file?: string; bytes?: number }): string {
+export function progressKey(event: Omit<TurnProgressFields, "type" | "activity"> & { activity: string; turnId?: string }): string {
const size = progressSize(event.bytes);
- return [event.turnId ?? "", event.itemId ?? "", event.activity, event.tool ?? "", event.file ?? "", size ? `${size.count}${size.unit}` : ""].join("|");
+ const quiet = event.quiet ? `${event.quiet.kind}${event.quiet.kind === "output" ? `@${event.quiet.at}` : ""}` : "";
+ return [event.turnId ?? "", event.itemId ?? "", event.activity, event.tool ?? "", event.file ?? "", size ? `${size.count}${size.unit}` : "",
+ event.target ?? "", event.detail ?? "", quiet, (event.tail ?? []).join("\n")].join("|");
}
diff --git a/shared/wire.ts b/shared/wire.ts
index cf74349c9c..ac700111db 100644
--- a/shared/wire.ts
+++ b/shared/wire.ts
@@ -500,6 +500,8 @@ export interface WireMessage extends HelperIntroField, SetupCardFields {
/** activity messages: tool name + outcome. */
tool?: {
name: string; ok?: boolean; spoken?: string; setup?: boolean; terminal?: boolean; summary?: string; input?: string; output?: string;
+ /** What the call works on, as its live status said it: the chip's and the "Now" card's specific words. */
+ step?: import("./turn-progress.ts").LiveStep;
/** error rows: the installed Claude Code is too old for the model, and
* the UI can offer to update it in place. notice rows: `rescue`, a turn that heard nothing from its AI for a while. */
claudeUpdate?: boolean; rescue?: import("./first-reply-rescue.ts").FirstReplyRescue;
diff --git a/src/components/ActivityPanel.tsx b/src/components/ActivityPanel.tsx
index e4e0dac108..84fb76212f 100644
--- a/src/components/ActivityPanel.tsx
+++ b/src/components/ActivityPanel.tsx
@@ -11,6 +11,7 @@ import {
type ChipTone,
} from "@/lib/activity";
import { listenLiveFrames } from "@/lib/live-events";
+import { useActivityFocus } from "@/lib/activity-focus";
import { t } from "@/lib/i18n";
const LIMIT = 300;
@@ -84,6 +85,12 @@ export function ActivityPanel({ bot }: { bot: Bot }) {
}, [threadIds, load]);
const days = useMemo(() => (rows ? groupActivityByDay(rows, new Date()) : []), [rows]);
+ const focus = useActivityFocus(bot.id);
+ const list = useRef<HTMLDivElement>(null);
+ const focused = (row: ActivityRow) => Boolean(focus?.turnId && row.turnId === focus.turnId && row.threadId === focus.threadId);
+ useEffect(() => {
+ list.current?.querySelector("[data-activity-focused]")?.scrollIntoView({ block: "nearest" });
+ }, [rows, focus]);
const jump = (row: ActivityRow) => {
if (row.threadId !== bot.threadId && threadIds.has(row.threadId)) {
@@ -121,7 +128,7 @@ export function ActivityPanel({ bot }: { bot: Bot }) {
{t("activity.panel.subtitle", { name: bot.name })}
</p>
- <div className="min-h-0 flex-1 overflow-y-auto">
+ <div ref={list} className="min-h-0 flex-1 overflow-y-auto">
{error && <div className="px-4 py-3 text-[13px] text-danger">{t("activity.panel.error", { message: error })}</div>}
{rows && rows.length === 0 && !error && (
<div className="px-4 py-6 text-[13px] text-ink-secondary">
@@ -135,7 +142,7 @@ export function ActivityPanel({ bot }: { bot: Bot }) {
{day.label}
</h3>
{day.rows.map((row) => (
- <ActivityLine key={`${row.threadId}:${row.at}:${row.tool}:${row.requestId ?? ""}`} row={row} current={row.threadId === bot.threadId} onJump={() => jump(row)} />
+ <ActivityLine key={`${row.threadId}:${row.at}:${row.tool}:${row.requestId ?? ""}`} row={row} current={row.threadId === bot.threadId} focused={focused(row)} onJump={() => jump(row)} />
))}
</section>
))}
@@ -144,13 +151,15 @@ export function ActivityPanel({ bot }: { bot: Bot }) {
);
}
-function ActivityLine({ row, current, onJump }: { row: ActivityRow; current: boolean; onJump: () => void }) {
+function ActivityLine({ row, current, focused, onJump }: { row: ActivityRow; current: boolean; focused: boolean; onJump: () => void }) {
const chip = outcomeChip(row.outcome);
return (
<button
type="button"
onClick={onJump}
- className="flex w-full items-start gap-3 border-b border-hairline/20 px-4 py-2 text-left hover:bg-raised/60"
+ aria-current={focused || undefined}
+ data-activity-focused={focused ? "" : undefined}
+ className={cn("flex w-full items-start gap-3 border-b border-hairline/20 px-4 py-2 text-left hover:bg-raised/60", focused && "bg-raised/60")}
title={current ? row.tool : t("activity.panel.openOtherTask", { tool: row.tool })}
>
<span className="mt-[2px] shrink-0 tabular-nums text-[11px] text-ink-secondary">{formatActivityTime(row.at)}</span>
diff --git a/src/components/ChatView.live-status.test.ts b/src/components/ChatView.live-status.test.ts
index fe4d9db123..bde3666ba5 100644
--- a/src/components/ChatView.live-status.test.ts
+++ b/src/components/ChatView.live-status.test.ts
@@ -9,11 +9,12 @@ import type { ModelPicker } from "./ModelPicker";
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+const dispatch = vi.hoisted(() => vi.fn());
vi.mock("@/state/store", async (importOriginal) => {
const original = await importOriginal<typeof import("@/state/store")>();
return { ...original, useStore: () => ({
state: { ...original.initialState, config: null, instances: [{ instanceId: "test", driverKind: "claudeAgent", displayName: "Test" } as InstanceInfo] },
- dispatch: vi.fn(),
+ dispatch,
}) };
});
vi.mock("./DesktopCapabilities", async (importOriginal) => ({
@@ -41,6 +42,7 @@ vi.mock("./ApprovalModeSelector", () => ({ ApprovalModeSelector: (_props: Compon
const { ChatView } = await import("./ChatView");
const { noteTurnEvent, resetTurnLive } = await import("@/state/turn-status");
+const { useActivityFocus } = await import("@/lib/activity-focus");
const THREAD = "selected";
const started = Date.UTC(2026, 9, 23, 12, 0, 0);
@@ -188,3 +190,55 @@ describe("the mascot and its status line through a long turn", () => {
expect(statusLine()).toBe("Working · 1m 12s · Thinking");
});
});
+
+describe("what the bot is doing right now", () => {
+ const search: Message = { id: "search", role: "bot", kind: "activity", at: started + 4_000, turnId: "t1",
+ tool: { name: "WebSearch", itemId: "s1", ok: true, step: { activity: "web", target: "Biber Dammbau" } } };
+ const bash: Message = { id: "bash", role: "bot", kind: "activity", at: started + 6_000, turnId: "t1",
+ tool: { name: "Bash", itemId: "b1", step: { activity: "command", target: "scrape.py", detail: "python3 scrape.py --pages 40" } } };
+ const toggle = () => host.querySelector<HTMLButtonElement>(".turn-presence button[aria-expanded]");
+ const steps = () => [...host.querySelectorAll("[data-now-step]")].map((step) => `${step.getAttribute("data-now-step")}: ${step.querySelector("[dir=auto]")?.textContent}`);
+
+ it("names the step, says how it is doing, and unfolds the ask's steps with a way into the Activity panel at this run", () => {
+ engine({ type: "turn.started" });
+ engine({ type: "item.started", itemType: "tool", itemId: "b1", title: "Bash" } as Partial<RuntimeEvent>);
+ engine({ type: "turn.progress", activity: "command", itemId: "b1", target: "scrape.py", detail: "python3 scrape.py --pages 40", quiet: { kind: "busy" } } as Partial<RuntimeEvent>);
+ render(busyBot([ask, search, bash]));
+ expect(statusLine()).toBe("Working · 1m 12s · Running scrape.py · busy, no output yet");
+ expect(host.querySelector("[data-turn-now]")?.getAttribute("title")).toBe("python3 scrape.py --pages 40");
+ expect(toggle()?.getAttribute("aria-label")).toBe("What Pepper is doing");
+ expect(host.querySelector("[data-now-card]")).toBeNull();
+
+ act(() => toggle()!.click());
+ expect(steps()).toEqual(["done: Searched the web for “Biber Dammbau”", "now: Running scrape.py"]);
+ const seen: Array<ReturnType<typeof useActivityFocus>> = [];
+ const probe = createRoot(document.createElement("div"));
+ act(() => probe.render(createElement(() => { seen.push(useActivityFocus("bot")); return null; })));
+ act(() => [...host.querySelectorAll<HTMLButtonElement>("[data-now-card] button")].find((button) => button.textContent === "Open activity")!.click());
+ expect(dispatch).toHaveBeenCalledWith({ type: "toggleActivity", open: true });
+ expect(seen.at(-1)).toEqual({ botId: "bot", threadId: THREAD, turnId: "t1" });
+ act(() => probe.unmount());
+ });
+
+ it("shows a running command's last lines of output in the card, and the time since they came on the line", () => {
+ engine({ type: "turn.started" });
+ engine({ type: "item.started", itemType: "tool", itemId: "b1", title: "Bash" } as Partial<RuntimeEvent>);
+ engine({ type: "turn.progress", activity: "command", itemId: "b1", target: "scrape.py", quiet: { kind: "output", at: started + 72_000 - 125_000 },
+ tail: ["page 39 of 40", "page 40 of 40"] } as Partial<RuntimeEvent>);
+ render(busyBot([ask, bash]));
+ expect(statusLine()).toBe("Working · 1m 12s · Running scrape.py · last output 2 min ago");
+ act(() => toggle()!.click());
+ expect(host.querySelector("[data-now-output]")?.textContent).toBe("page 39 of 40\npage 40 of 40");
+ });
+
+ it("is the same calm line in Simple mode, where the card unfolds too", () => {
+ mode.advanced = false;
+ engine({ type: "turn.started" });
+ engine({ type: "item.started", itemType: "tool", itemId: "b1", title: "Bash" } as Partial<RuntimeEvent>);
+ engine({ type: "turn.progress", activity: "command", itemId: "b1", target: "scrape.py", quiet: { kind: "idle" } } as Partial<RuntimeEvent>);
+ render(busyBot([ask, search, bash]));
+ expect(statusLine()).toBe("Running scrape.py · idle, no output yet");
+ act(() => toggle()!.click());
+ expect(steps()).toEqual(["done: Searched the web for “Biber Dammbau”", "now: Running scrape.py"]);
+ });
+});
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index a1e930c47f..ed132677e2 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -56,8 +56,7 @@ import { normalizeState, stateForBot } from "@/lib/mascot";
import { peerLine, peerRequest, type PeerLine } from "@/lib/peer-message";
import { showWorkingDots } from "@/lib/turn-tail";
import { lastNonReceipt } from "@/lib/receipts";
-import { turnNowPhrases } from "@/lib/live-activity"; import { useTurnLive } from "@/state/turn-status";
-import { friendlyNowPhrases } from "@/lib/friendly-activity";
+import { useTurnLive } from "@/state/turn-status"; import { useTurnNow } from "./NowCard";
import { ChatMarkdown } from "./ChatMarkdown";
import { liveToolIds } from "@/lib/tool-liveness";
import { VoiceNoteBubble, type VoiceNoteAttachment } from "./VoiceNoteBubble";
@@ -949,7 +948,7 @@ export function ChatView({ bot: profile }: { bot: Bot }) {
}, [lastTypedMessage]);
const lastMessage = lastNonReceipt(messages);
- const live = useTurnLive(bot.threadId), activity = advanced ? turnNowPhrases(live.status, lastMessage) : friendlyNowPhrases(live.status, lastMessage);
+ const live = useTurnLive(bot.threadId), now = useTurnNow(bot, messages, lastMessage, live, advanced);
const toolInFlight = (lastMessage?.kind === "activity" && lastMessage.tool?.ok === undefined) || Boolean(live.status && live.status.activity !== "thinking" && live.status.activity !== "reply");
// The mascot and its status line stay for the whole turn; only its end hides them, never a timer.
const waiting = Boolean(bot.busy && bot.activity !== "waiting-on-you" && showWorkingDots(bot.busy, lastMessage, undefined, live.ended));
@@ -1250,10 +1249,8 @@ export function ChatView({ bot: profile }: { bot: Bot }) {
className={cn(!advanced && presenceUnderBubble && SIMPLE_STACKED)}
label={teammatesWorking ? t("chat.teammatesWorking") : undefined}
visible={presenceVisible}
- phrases={teammatesWorking ? undefined : activity?.phrases}
- phase={activity?.phase}
- detail={advanced ? undefined : turnNowPhrases(live.status, lastMessage)?.phrases?.[0]}
- size={activity?.size}
+ {...now}
+ phrases={teammatesWorking ? undefined : now.phrases}
seed={`${bot.id}:${bot.threadId ?? ""}:${busySince ?? ""}`}
answering={popping !== null}
since={busySince}
diff --git a/src/components/GroupView.tsx b/src/components/GroupView.tsx
index aaa573f1e9..e2c569b03d 100644
--- a/src/components/GroupView.tsx
+++ b/src/components/GroupView.tsx
@@ -1171,7 +1171,7 @@ export function GroupView({ group }: { group: Group }) {
visible={presenceVisible}
phrases={activity?.phrases}
phase={activity?.phase}
- size={activity?.size}
+ size={activity?.size} hover={activity?.hover} quiet={live.status && "quiet" in live.status ? live.status.quiet : undefined}
seed={`${group.id}:${group.turnStartedAt ?? ""}:${speaker?.id ?? ""}`}
answering={popping !== null}
since={speaker ? group.turnStartedAt ?? null : null}
diff --git a/src/components/NowCard.tsx b/src/components/NowCard.tsx
new file mode 100644
index 0000000000..602620a399
--- /dev/null
+++ b/src/components/NowCard.tsx
@@ -0,0 +1,70 @@
+import { useMemo } from "react";
+import type { LocaleKey } from "@/locales";
+import { useStore, type Bot, type Message } from "@/state/store";
+import type { TurnLive } from "@/state/turn-status";
+import { cn } from "@/lib/cn";
+import { focusActivityRun } from "@/lib/activity-focus";
+import { friendlyNowPhrases } from "@/lib/friendly-activity";
+import { t } from "@/lib/i18n";
+import { turnNowPhrases } from "@/lib/live-activity";
+import { nowSteps, type NowStep, type NowStepState } from "@/lib/now-steps";
+
+const MARK: Record<NowStepState, string> = { done: "✓", failed: "✕", now: "●" };
+const STATE: Record<NowStepState, LocaleKey> = { done: "chat.now.stateDone", failed: "chat.now.stateFailed", now: "chat.now.stateNow" };
+
+export function NowCard({ steps, tail, onOpenActivity }: { steps: readonly NowStep[]; tail?: readonly string[]; onOpenActivity?: () => void }) {
+ return (
+ <div className="flex flex-col gap-2" data-now-card="">
+ {steps.length > 0 && (
+ <ol className="flex flex-col gap-1">
+ {steps.map((step) => (
+ <li key={step.id} className="flex min-w-0 items-baseline gap-2 text-[13px] leading-5" data-now-step={step.state}>
+ <span aria-hidden="true" className="w-3 shrink-0 text-center text-[11px] text-ink-tertiary">{MARK[step.state]}</span>
+ <span dir="auto" title={step.hover} className={cn("min-w-0 truncate", step.state === "now" ? "text-ink" : "text-ink-secondary")}>{step.label}</span>
+ <span className="sr-only">{t(STATE[step.state])}</span>
+ </li>
+ ))}
+ </ol>
+ )}
+ {tail && tail.length > 0 && (
+ <div>
+ <span className="sr-only">{t("chat.now.output")}</span>
+ <pre dir="ltr" data-now-output="" className="whitespace-pre-wrap break-words rounded-lg bg-ink/[0.04] px-2 py-1.5 font-mono text-[12px] leading-[18px] text-ink-secondary">{tail.join("\n")}</pre>
+ </div>
+ )}
+ {onOpenActivity && (
+ <button type="button" onClick={onOpenActivity} className="self-start rounded text-[13px] text-ink-secondary underline-offset-2 hover:text-ink hover:underline">
+ {t("chat.now.openActivity")}
+ </button>
+ )}
+ </div>
+ );
+}
+
+/** Everything the working line of a bot's chat shows: what is happening now, in each mode's words, how a long step is
+ * doing, and the card it unfolds. */
+export function useTurnNow(bot: Pick<Bot, "id" | "name" | "threadId">, messages: readonly Message[], lastMessage: Message | undefined, live: TurnLive, advanced: boolean) {
+ const { dispatch } = useStore();
+ const status = live.status;
+ const exact = turnNowPhrases(status, lastMessage);
+ const shown = advanced ? exact : friendlyNowPhrases(status, lastMessage);
+ const steps = useMemo(() => nowSteps(messages, status), [messages, status]);
+ const quiet = status && "quiet" in status ? status.quiet : undefined;
+ const tail = status?.activity === "command" && "tail" in status ? status.tail : undefined;
+ const turnId = live.turnId ?? lastMessage?.turnId;
+ const remote = typeof window !== "undefined" && window.ogb?.remoteClient?.active === true;
+ const openActivity = remote ? undefined : () => {
+ focusActivityRun({ botId: bot.id, threadId: bot.threadId, ...(turnId ? { turnId } : {}) });
+ dispatch({ type: "toggleActivity", open: true });
+ };
+ return {
+ phrases: shown?.phrases,
+ phase: shown?.phase,
+ size: shown?.size,
+ detail: advanced ? undefined : exact?.phrases[0],
+ hover: exact?.hover,
+ quiet,
+ cardLabel: t("chat.now.title", { name: bot.name }),
+ card: steps.length > 0 || tail?.length ? <NowCard steps={steps} tail={tail} onOpenActivity={openActivity} /> : undefined,
+ };
+}
diff --git a/src/components/Sidebar.simple-mode.test.ts b/src/components/Sidebar.simple-mode.test.ts
index 9fb914ff35..3a9b24f9d0 100644
--- a/src/components/Sidebar.simple-mode.test.ts
+++ b/src/components/Sidebar.simple-mode.test.ts
@@ -20,6 +20,8 @@ vi.mock("@/state/store", async (importOriginal) => {
import { BotContextMenu, BotListItem, BotThreadList, botRowProps, GroupListItem, PinnedBotCircle, type BotRowProps } from "./Sidebar";
import { SidebarBotActivity, sidebarBotActivityTasks } from "./SidebarBotActivity";
import { forgetSearchDisclosuresForTests } from "@/lib/search-disclosure";
+import { noteTurnEvent, resetTurnLive } from "@/state/turn-status";
+import type { RuntimeEvent } from "../../shared/runtime-events";
const bot: Bot = {
id: "atlas", threadId: "last-selected", name: "Atlas", title: "", description: "",
@@ -190,6 +192,38 @@ describe("bot-first sidebar", () => {
expect(working).toContain("[--row:var(--color-panel)]");
});
+ it.each([false, true])("says the step a working bot is on in place of its last message, and its last message again once done (advanced: %s)", (advanced) => {
+ fixture.advanced = advanced;
+ fixture.showThreads = false;
+ resetTurnLive();
+ const said: Bot["messages"] = [{ id: "hi", role: "bot", kind: "text", at: 1, text: "Here are the leads from Monday." }];
+ const leads = { threadId: "leads", title: "Leads", createdAt: 1 };
+ const candidate: Bot = { ...bot, threadId: "leads", messages: said, unread: false, projects: [], tasks: [{ ...leads, busy: true, activity: "working" }], busy: true };
+ noteTurnEvent({ eventId: "e1", provider: "claudeAgent", threadId: "leads", createdAt: "2026-10-28T12:00:00.000Z", turnId: "t1",
+ type: "turn.progress", activity: "command", itemId: "c1", target: "scrape.py", quiet: { kind: "busy" } } as RuntimeEvent);
+ const working = renderToStaticMarkup(createElement(BotListItem, rowProps("comfortable", candidate)));
+ expect(working).toContain('<span dir="auto" data-sidebar-working-phrase="" class="truncate">Running scrape.py</span>');
+ expect(working, "the row's second line keeps its height: no taller dots").not.toContain("h-[1.5em]");
+ expect(working).not.toContain("Monday");
+ expect(working, "the row says the step alone, not how it is doing").not.toContain("busy, no output yet");
+ const done = renderToStaticMarkup(createElement(BotListItem, rowProps("comfortable", { ...candidate, busy: false, tasks: [{ ...leads, busy: false, activity: "idle" }] })));
+ expect(done).toContain("Here are the leads from Monday.");
+ expect(done).not.toContain("scrape.py");
+ resetTurnLive();
+ });
+
+ it("speaks for the conversation that is working when another one is open", () => {
+ fixture.advanced = true;
+ fixture.showThreads = false;
+ resetTurnLive();
+ const candidate: Bot = { ...bot, threadId: "open", messages: [], unread: false, projects: [], busy: true,
+ tasks: [{ threadId: "open", title: "Open", createdAt: 1 }, { threadId: "leads", title: "Leads", createdAt: 2, busy: true, activity: "working" }] };
+ noteTurnEvent({ eventId: "e2", provider: "codex", threadId: "leads", createdAt: "2026-10-28T12:00:00.000Z", turnId: "t1",
+ type: "turn.progress", activity: "web", itemId: "w1", target: "Biber Dammbau" } as RuntimeEvent);
+ expect(renderToStaticMarkup(createElement(BotListItem, rowProps("comfortable", candidate)))).toContain(">Searching the web for “Biber Dammbau”</span>");
+ resetTurnLive();
+ });
+
it("rings a focused row or group chat inside its edge in both modes", () => {
fixture.showThreads = false;
const group: Group = { id: "room", threadId: "room-thread", name: "Launch", memberIds: [bot.id], messages: [], defaultResponder: { kind: "mentions" }, bulletin: "", unread: false, createdAt: 1 };
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 7a0e830e3c..f54f192da2 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -4,8 +4,8 @@ import { createPortal } from "react-dom";
import { Activity, Archive, Bot as BotIcon, Check, ChevronRight, ClipboardCopy, Crown, FolderPlus, Library, Loader2, MessageSquarePlus, MoreHorizontal, Pencil, PanelLeftClose, PanelLeftOpen, Phone, Pin, PinOff, Plus, Search, TextQuote, Trash2, Users, X } from "lucide-react";
import { api, useStore, formatTime, visibleMessages, currentTaskBot, botOpensTo, openBot, openThread, type Action, type AppState, type Bot, type BotProject, type Group, type InstanceInfo, type Message } from "@/state/store";
import { approvalModeFor } from "../../shared/approval-mode";
-import { liveActivityLabel, turnNowPhrases } from "@/lib/live-activity";
-import { useTurnLive } from "@/state/turn-status";
+import { liveActivityLabel } from "@/lib/live-activity";
+import { SidebarWorkingStep } from "./SidebarWorkingStep";
import { llmThreadTitlesEnabled } from "@/lib/feature-flags";
import { BotAvatar } from "./Avatar";
@@ -24,7 +24,6 @@ import { BulkSelectFilters, ThreadListFooter, deleteThreadsInBulk, useBulkSelect
import { StackedMauses } from "./StackedMauses";
import { LocalComputerAutoWarning } from "./LocalComputerAutoWarning";
-import { WorkingDots } from "./WorkingIndicator";
import { nextRename } from "@/lib/rename";
import { useDesktopCapabilities } from "./DesktopCapabilities";
import { MIN_QUERY, SearchResults } from "./SearchResults";
@@ -723,11 +722,6 @@ export function useVisibleMessages(bot: Bot): Message[] {
return useMemo(() => visibleMessages({ messages, activeLeafId }), [messages, activeLeafId]);
}
-function WorkingPhrase({ threadId, last }: { threadId: string; last?: Message }) {
- const live = useTurnLive(threadId);
- return <span dir="auto" data-sidebar-working-phrase="" className="truncate">{turnNowPhrases(live.status, last)?.phrases[0] ?? t("chat.activity.thinking")}</span>;
-}
-
export const BotListItem = memo(function BotListItem(props: BotRowProps) {
const advanced = useAdvancedMode();
const { bot, selected, deleting, mascotMotion, reveal, pendingQueued, instances, liveCall, density, quiet, query, dispatch, onMenu, renameRequest } = props;
@@ -867,13 +861,8 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
</span>
) : (
<span className={cn("flex min-w-0 items-center gap-1.5 truncate text-[13px] leading-[18px]", waiting ? simpleRow ? "text-warning" : "font-semibold text-warning" : "text-ink-secondary")}>
- {working && simpleList ? (
- <WorkingPhrase threadId={bot.threadId} last={last} />
- ) : working ? (
- <span className="flex h-[1.5em] items-center" role="status">
- <WorkingDots size={3.5} />
- <span className="sr-only">{t("sidebar.preview.working")}</span>
- </span>
+ {working ? (
+ <SidebarWorkingStep bot={bot} last={last} />
) : (
<span dir="auto" className="truncate">{waiting ? t("sidebar.preview.waiting") : teammateWait ? t("sidebar.preview.waitingOnTeammate") : queued ? t("task.queued") : botPreview(bot, visible, instances, advanced)}</span>
)}
diff --git a/src/components/SidebarBotListItem.expansion.test.ts b/src/components/SidebarBotListItem.expansion.test.ts
index a7a0b7778b..8d3fa5988c 100644
--- a/src/components/SidebarBotListItem.expansion.test.ts
+++ b/src/components/SidebarBotListItem.expansion.test.ts
@@ -98,7 +98,7 @@ describe("bot row expansion follows the visible thread tree", () => {
});
it.each([
- [{ busy: true }, 'class="sr-only">Working…'],
+ [{ busy: true }, '<span dir="auto" data-sidebar-working-phrase="" class="truncate">Thinking</span>'],
[{ activity: "waiting-on-you" }, '<span dir="auto" class="truncate">Waiting for you…'],
[{ waitingForTeammates: true }, '<span dir="auto" class="truncate">Waiting on a teammate…'],
] as const)("keeps sole-thread activity visible after a reveal (%j)", (status, label) => {
diff --git a/src/components/SidebarBotListItem.test.ts b/src/components/SidebarBotListItem.test.ts
index cc089c7a20..ad2535d672 100644
--- a/src/components/SidebarBotListItem.test.ts
+++ b/src/components/SidebarBotListItem.test.ts
@@ -311,11 +311,12 @@ describe("BotListItem", () => {
expect(markup).not.toContain("](https://");
});
- it("shows typing dots instead of preview text while the bot works", () => {
- const markup = renderRow(bot({ busy: true }));
+ it("says what the bot is doing in place of its preview text while it works, in a line as tall as the preview", () => {
+ const markup = renderRow(bot({ busy: true, messages: [{ id: "b1", role: "bot", kind: "text", text: "hello", at: 1 }] as Bot["messages"] }));
- expect(markup).toContain("animate-status-pulse");
- expect(markup).toContain('class="sr-only">Working…');
+ expect(markup).toContain('<span dir="auto" data-sidebar-working-phrase="" class="truncate">Thinking</span>');
+ expect(markup).not.toContain(">hello<");
+ expect(markup).not.toContain("animate-status-pulse");
});
it("marks the avatar with a green presence dot only while the bot works", () => {
@@ -455,7 +456,7 @@ describe("bot deletion feedback", () => {
});
it("keeps the status line while something is happening", () => {
- expect(renderRow(bot({ busy: true }), true)).toContain('class="sr-only">Working…');
+ expect(renderRow(bot({ busy: true }), true)).toContain('data-sidebar-working-phrase=""');
expect(renderRow(bot({ activity: "waiting-on-you" }), true)).toContain("Waiting for you…");
expect(renderRow(bot({ waitingForTeammates: true, busy: false }), true)).toContain("Waiting on a teammate…");
});
diff --git a/src/components/SidebarWorkingStep.tsx b/src/components/SidebarWorkingStep.tsx
new file mode 100644
index 0000000000..11e88ebad6
--- /dev/null
+++ b/src/components/SidebarWorkingStep.tsx
@@ -0,0 +1,18 @@
+import type { Bot, Message } from "@/state/store";
+import { useTurnLive } from "@/state/turn-status";
+import { t } from "@/lib/i18n";
+import { turnNowPhrases } from "@/lib/live-activity";
+
+/** The conversation a working bot's row speaks for: the open one when it is working, else the first one that is. */
+export function workingThreadId(bot: Pick<Bot, "threadId" | "tasks">): string {
+ const tasks = bot.tasks ?? [];
+ if (tasks.some((task) => task.threadId === bot.threadId && task.busy)) return bot.threadId;
+ return tasks.find((task) => task.busy)?.threadId ?? bot.threadId;
+}
+
+export function SidebarWorkingStep({ bot, last }: { bot: Pick<Bot, "threadId" | "tasks">; last?: Message }) {
+ const threadId = workingThreadId(bot);
+ const live = useTurnLive(threadId);
+ const phrase = turnNowPhrases(live.status, threadId === bot.threadId ? last : undefined)?.phrases[0];
+ return <span dir="auto" data-sidebar-working-phrase="" className="truncate">{phrase ?? t("chat.activity.thinking")}</span>;
+}
diff --git a/src/components/TurnPresence.test.ts b/src/components/TurnPresence.test.ts
index 48fe1b87f3..8880ff865e 100644
--- a/src/components/TurnPresence.test.ts
+++ b/src/components/TurnPresence.test.ts
@@ -118,6 +118,79 @@ describe("the status line", () => {
});
});
+describe("a long step's quiet part", () => {
+ const line = () => host.querySelector("[data-turn-status]")?.textContent?.replace(/\s+/g, " ").trim();
+
+ it("follows the step with how it is doing, and counts the time since its last output on its own", () => {
+ vi.setSystemTime(1_000_000);
+ render({ label: "Working", since: 1_000_000 - 72_000, phrases: ["Running scrape.py"], phase: "step", hover: "python3 scrape.py --pages 40", quiet: { kind: "busy" } });
+ expect(line()).toBe("Working · 1m 12s · Running scrape.py · busy, no output yet");
+ expect(host.querySelector("[data-turn-now]")?.getAttribute("title")).toBe("python3 scrape.py --pages 40");
+ render({ label: "Working", since: 1_000_000 - 72_000, phrases: ["Running scrape.py"], phase: "step", quiet: { kind: "output", at: 1_000_000 - 30_000 } });
+ expect(host.querySelector("[data-turn-quiet]")?.textContent).toBe("last output just now");
+ act(() => void vi.advanceTimersByTime(45_000));
+ expect(host.querySelector("[data-turn-quiet]")?.textContent).toBe("last output 1 min ago");
+ });
+
+ it("says it in Simple mode too, after the one phrase", () => {
+ render({ simple: true, phrases: ["Running scrape.py"], phase: "step", quiet: { kind: "network" } });
+ expect(line()).toBe("Running scrape.py · waiting on the network");
+ });
+});
+
+describe("the Now card", () => {
+ const toggle = () => host.querySelector<HTMLButtonElement>("button[aria-expanded]");
+ const card = () => host.querySelector("[role=region]");
+ const open = (extra: Record<string, unknown> = {}) =>
+ render({ label: "Working", since: Date.now(), phrases: ["Running scrape.py"], phase: "step", card: createElement("p", null, "steps"), cardLabel: "What Biber is doing", ...extra });
+
+ it("is one calm line by default; a click unfolds the card under it and another folds it", () => {
+ open();
+ expect(toggle()?.getAttribute("aria-expanded")).toBe("false");
+ expect(toggle()?.getAttribute("aria-label")).toBe("What Biber is doing");
+ expect(card()).toBeNull();
+ act(() => toggle()!.click());
+ expect(toggle()?.getAttribute("aria-expanded")).toBe("true");
+ expect(card()?.textContent).toBe("steps");
+ expect(toggle()?.getAttribute("aria-controls")).toBe(card()?.id);
+ act(() => toggle()!.click());
+ expect(toggle()?.getAttribute("aria-expanded")).toBe("false");
+ expect(card()).toBeNull();
+ });
+
+ it("folds on Escape and gives focus back to the line", () => {
+ open();
+ act(() => toggle()!.click());
+ toggle()!.focus();
+ act(() => void document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true })));
+ expect(card()).toBeNull();
+ expect(document.activeElement).toBe(toggle());
+ });
+
+ it("leaves Escape to whatever else has the focus", () => {
+ const field = document.createElement("textarea");
+ document.body.append(field);
+ open();
+ act(() => toggle()!.click());
+ field.focus();
+ act(() => void document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true })));
+ expect(card()).not.toBeNull();
+ field.remove();
+ });
+
+ it("is a plain line with nothing to show, in Simple mode a button as well, and folds when the turn ends", () => {
+ render({ label: "Working", since: Date.now(), phrases: ["Thinking"], phase: "think" });
+ expect(toggle()).toBeNull();
+ open({ simple: true });
+ act(() => toggle()!.click());
+ expect(card()).not.toBeNull();
+ render({ visible: false, card: createElement("p", null, "steps"), cardLabel: "What Biber is doing" });
+ act(() => void vi.advanceTimersByTime(300));
+ open({ simple: true });
+ expect(toggle()?.getAttribute("aria-expanded"), "a new turn starts folded").toBe("false");
+ });
+});
+
describe("thinking shimmer box", () => {
it("pads the sheen past ascenders, descenders and arabic marks without moving the layout", () => {
const css = readFileSync("src/styles.css", "utf8");
diff --git a/src/components/TurnPresence.tsx b/src/components/TurnPresence.tsx
index 585bc49f61..e0ce6e9d62 100644
--- a/src/components/TurnPresence.tsx
+++ b/src/components/TurnPresence.tsx
@@ -1,9 +1,12 @@
-import { useEffect, useRef, useState, type ReactNode } from "react";
+import { useEffect, useId, useRef, useState, type ReactNode } from "react";
+import { ChevronDown } from "lucide-react";
import { cn } from "@/lib/cn";
import { WorkingTimer } from "@/components/WorkingIndicator";
import { phraseAt, phraseHoldMs } from "@/lib/live-activity";
+import { quietText } from "@/lib/now-steps";
import { t } from "@/lib/i18n";
import { formatElapsed } from "@/lib/working-time";
+import type { StepQuiet } from "../../shared/turn-progress";
const FADE_MS = 320;
@@ -55,10 +58,23 @@ const NOTHING: readonly string[] = [];
// The spaces keep copied text readable; the flex gap does the spacing on screen.
const Dot = () => <span aria-hidden="true" className="text-[12px] text-ink-tertiary"> · </span>;
-/** The turn's live status line: "Working · 1m 12s · Writing index.html · 14 KB". The lead word and the timer stay for
- * the whole turn; `phrases` say what is happening now and rotate through their alternates; `size` is how much of the
- * file is written. With nothing to say the line is the lead and the timer alone. The part that is live shimmers.
- * `simple` draws Simple mode's quiet line instead: the avatar and one friendly phrase for what is happening now. */
+/** "last output 2 min ago" counts on by itself; the other states change only with a new frame. */
+function QuietPart({ quiet }: { quiet: StepQuiet }) {
+ const [now, setNow] = useState(() => Date.now());
+ useEffect(() => {
+ if (quiet.kind !== "output") return;
+ setNow(Date.now());
+ const timer = setInterval(() => setNow(Date.now()), 15_000);
+ return () => clearInterval(timer);
+ }, [quiet]);
+ return <><Dot /><span data-turn-quiet="" className="text-[12px] text-ink-tertiary">{quietText(quiet, now)}</span></>;
+}
+
+/** The turn's live status line: "Working · 1m 12s · Running scrape.py · busy, no output yet". The lead word and the
+ * timer stay for the whole turn; `phrases` say what is happening now and rotate through their alternates; `size` is how
+ * much of the file is written; `quiet` is how a long step is doing. With nothing to say the line is the lead and the timer
+ * alone. The part that is live shimmers. `simple` draws Simple mode's quiet line instead: the avatar and one phrase for
+ * what is happening now. With a `card`, the line is a button that unfolds it underneath. */
export function TurnPresence({
avatar,
visible,
@@ -71,6 +87,10 @@ export function TurnPresence({
size,
simple = false,
detail,
+ hover,
+ quiet,
+ card,
+ cardLabel,
className,
}: {
avatar: ReactNode;
@@ -85,11 +105,21 @@ export function TurnPresence({
simple?: boolean;
/** Simple mode: Advanced's wording for what is happening now, kept in the row's tooltip with the timer and size. */
detail?: string;
+ /** The whole command, query or address behind the phrase. */
+ hover?: string;
+ quiet?: StepQuiet;
+ card?: ReactNode;
+ cardLabel?: string;
className?: string;
}) {
const [mounted, setMounted] = useState(visible);
const [presencePhase, setPhase] = useState<"think" | "answer" | "out">(answering ? "answer" : "think");
+ const [open, setOpen] = useState(false);
const wasAnswering = useRef(answering);
+ const root = useRef<HTMLDivElement>(null);
+ const toggle = useRef<HTMLButtonElement>(null);
+ const cardId = useId();
+ const statusId = useId();
useEffect(() => {
if (visible) {
@@ -111,60 +141,101 @@ export function TurnPresence({
}, [visible, answering, mounted]);
const showWorking = presencePhase === "think";
+ const expandable = Boolean(card) && showWorking;
+ useEffect(() => {
+ if (!expandable) setOpen(false);
+ }, [expandable]);
+ useEffect(() => {
+ if (!open) return;
+ const fold = (event: KeyboardEvent) => {
+ if (event.key !== "Escape" || event.defaultPrevented) return;
+ const inside = Boolean(root.current?.contains(document.activeElement));
+ if (!inside && document.activeElement && document.activeElement !== document.body) return;
+ event.preventDefault();
+ setOpen(false);
+ if (inside) toggle.current?.focus();
+ };
+ document.addEventListener("keydown", fold);
+ return () => document.removeEventListener("keydown", fold);
+ }, [open]);
const lead = label ?? t("chat.activity.working");
const now = phrases && phrases.length > 0 ? phrases : null;
const { current, previous } = useRotatingPhrase(now ?? NOTHING, phase ?? now?.[0] ?? "", seed, mounted && showWorking && now !== null);
if (!mounted) return null;
+ const status = showWorking && simple ? (
+ <span id={statusId} className="flex min-w-0 items-baseline gap-x-1.5 text-[14px] leading-[22px] text-ink-tertiary" data-turn-status>
+ <span className="turn-phrase turn-phrase-quiet relative grid min-w-0" title={hover} data-turn-now={now ? "" : undefined}>
+ {now ? (
+ <ShimmerPhrase key={`in:${current}`} text={current} className={cn("truncate", previous !== null && "turn-phrase-in")} />
+ ) : (
+ <span>{label ?? t("chat.typing")}</span>
+ )}
+ </span>
+ {now && quiet && <QuietPart quiet={quiet} />}
+ </span>
+ ) : showWorking ? (
+ <span id={statusId} className="flex min-w-0 flex-wrap items-baseline gap-x-1.5 gap-y-1 leading-none" data-turn-status>
+ {now ? <span className="text-[13px] text-ink-secondary">{lead}</span> : <ShimmerPhrase text={lead} className="text-[13px]" />}
+ {since !== null && (
+ <>
+ <Dot />
+ <WorkingTimer since={since} className="text-[12px] text-ink-tertiary" />
+ </>
+ )}
+ {now && (
+ <>
+ <Dot />
+ {/* One phrase at a time: a fading old phrase sat out of flow and a longer one drew over the size beside it. */}
+ <span className="turn-phrase relative grid min-w-0 max-w-full text-[13px]" title={hover} data-turn-now>
+ <ShimmerPhrase
+ key={`in:${current}`}
+ text={current}
+ className={cn("truncate", previous !== null && "turn-phrase-in")}
+ />
+ </span>
+ {size && (
+ <>
+ <Dot />
+ <span className="text-[12px] tabular-nums text-ink-tertiary" data-turn-size>{size}</span>
+ </>
+ )}
+ {quiet && <QuietPart quiet={quiet} />}
+ </>
+ )}
+ </span>
+ ) : null;
return (
- <div className={cn("turn-presence flex flex-col items-start", className)}>
+ <div ref={root} className={cn("turn-presence flex min-w-0 max-w-full flex-col items-start", className)}>
<div
title={simple && showWorking ? [lead, since !== null ? formatElapsed(Date.now() - since) : null, detail ?? (now ? current : null), size].filter(Boolean).join(" · ") : undefined}
className={cn(
- simple ? "flex h-9 items-center gap-2 ps-2" : "flex items-center gap-2",
+ simple ? "flex h-9 min-w-0 max-w-full items-center gap-2 ps-2" : "flex min-w-0 max-w-full items-center gap-2",
presencePhase === "think" && "turn-mascot-in",
presencePhase === "out" && "turn-mascot-out",
)}
>
{avatar}
- {showWorking && simple ? (
- <span className="turn-phrase turn-phrase-quiet relative grid text-[14px] leading-[22px] text-ink-tertiary" data-turn-status data-turn-now={now ? "" : undefined}>
- {now ? (
- <ShimmerPhrase key={`in:${current}`} text={current} className={previous !== null ? "turn-phrase-in" : undefined} />
- ) : (
- <span>{label ?? t("chat.typing")}</span>
- )}
- </span>
- ) : showWorking ? (
- <span className="flex min-w-0 flex-wrap items-baseline gap-x-1.5 gap-y-1 leading-none" data-turn-status>
- {now ? <span className="text-[13px] text-ink-secondary">{lead}</span> : <ShimmerPhrase text={lead} className="text-[13px]" />}
- {since !== null && (
- <>
- <Dot />
- <WorkingTimer since={since} className="text-[12px] text-ink-tertiary" />
- </>
- )}
- {now && (
- <>
- <Dot />
- {/* One phrase at a time: a fading old phrase sat out of flow and a longer one drew over the size beside it. */}
- <span className="turn-phrase relative grid text-[13px]" data-turn-now>
- <ShimmerPhrase
- key={`in:${current}`}
- text={current}
- className={previous !== null ? "turn-phrase-in" : undefined}
- />
- </span>
- {size && (
- <>
- <Dot />
- <span className="text-[12px] tabular-nums text-ink-tertiary" data-turn-size>{size}</span>
- </>
- )}
- </>
- )}
- </span>
- ) : null}
+ {expandable ? (
+ <button
+ ref={toggle}
+ type="button"
+ aria-expanded={open}
+ aria-controls={cardId}
+ aria-label={cardLabel}
+ aria-describedby={statusId}
+ onClick={() => setOpen((shown) => !shown)}
+ className="turn-now-toggle"
+ >
+ {status}
+ <ChevronDown aria-hidden="true" size={12} strokeWidth={2} className={cn("turn-now-chevron", open && "rotate-180")} />
+ </button>
+ ) : status}
</div>
+ {expandable && open && (
+ <div id={cardId} role="region" aria-label={cardLabel} className="turn-now-card">
+ {card}
+ </div>
+ )}
</div>
);
}
diff --git a/src/lib/activity-focus.ts b/src/lib/activity-focus.ts
new file mode 100644
index 0000000000..d5a6b1bc44
--- /dev/null
+++ b/src/lib/activity-focus.ts
@@ -0,0 +1,35 @@
+import { useEffect, useState } from "react";
+
+export interface ActivityFocus {
+ botId: string;
+ threadId: string;
+ turnId?: string;
+}
+
+let current: ActivityFocus | null = null;
+const listeners = new Set<() => void>();
+
+/** Asks the Activity panel to show this run: the panel opened next, or the one open now. */
+export function focusActivityRun(focus: ActivityFocus): void {
+ current = focus;
+ for (const listener of Array.from(listeners)) listener();
+}
+
+/** The run the person last asked this bot's panel to show. Taking it clears the request, so opening the panel some other
+ * way later shows no old run. */
+export function useActivityFocus(botId: string): ActivityFocus | null {
+ const [focus, setFocus] = useState<ActivityFocus | null>(null);
+ useEffect(() => {
+ const take = () => {
+ if (current?.botId !== botId) return;
+ setFocus(current);
+ current = null;
+ };
+ listeners.add(take);
+ take();
+ return () => {
+ listeners.delete(take);
+ };
+ }, [botId]);
+ return focus;
+}
diff --git a/src/lib/friendly-activity.test.ts b/src/lib/friendly-activity.test.ts
index 4a0fa9224a..f517166680 100644
--- a/src/lib/friendly-activity.test.ts
+++ b/src/lib/friendly-activity.test.ts
@@ -26,6 +26,13 @@ describe("Simple mode's working line", () => {
expect(friendlyNowPhrases(null, running("Bash", { spoken: "running a command" })).phrases).toEqual(["Running a few commands"]);
});
+ it("says the command, search or page the server could name, as Advanced does, and still no file names", () => {
+ expect(friendlyNowPhrases({ activity: "command", itemId: "x", target: "scrape.py" }).phrases).toEqual(["Running scrape.py"]);
+ expect(friendlyNowPhrases({ activity: "web", itemId: "s", target: "Biber Dammbau" }).phrases).toEqual(["Searching the web for “Biber Dammbau”"]);
+ expect(friendlyNowPhrases(null, running("WebFetch", { step: { activity: "fetch", target: "linkedin.com" } })).phrases).toEqual(["Reading linkedin.com"]);
+ expect(friendlyNowPhrases(null, running("Write", { step: { activity: "write", target: "report.md" } })).phrases).toEqual(["Writing some code"]);
+ });
+
it("says which outside service the bot is working in", () => {
expect(toolService("mcp__notion__search")).toBe("Notion");
expect(toolService("mcp__composio__GMAIL_SEND_EMAIL")).toBe("Gmail");
diff --git a/src/lib/friendly-activity.ts b/src/lib/friendly-activity.ts
index 47c3875595..cf1363d449 100644
--- a/src/lib/friendly-activity.ts
+++ b/src/lib/friendly-activity.ts
@@ -36,10 +36,12 @@ function phrases(phase: string, keys: LocaleKey[]): LiveActivityPhrases {
}
/** Simple mode's one rotating line for what the bot is doing now: plain words in place of file names, sizes and
- * timers, chosen by the kind of step (a tool's spoken narration is read by its name, as every other step is). */
+ * timers, chosen by the kind of step (a tool's spoken narration is read by its name, as every other step is); a
+ * command, search or page the server could name is said by name. */
export function friendlyNowPhrases(status: LiveStatus | null, message?: Message): LiveActivityPhrases {
const plain = message?.kind === "activity" && message.tool?.spoken ? { ...message, tool: { ...message.tool, spoken: undefined } } : message;
const now = turnNowPhrases(status, plain);
+ if (now?.phase.startsWith("step:")) return now;
const tool = (status && "tool" in status ? status.tool : undefined) ?? (message?.kind === "activity" && message.tool?.ok === undefined ? message.tool?.name : undefined);
const service = toolService(tool);
if (service) return { phase: `friendly:service:${service}`, phrases: [t("chat.friendly.service", { service })] };
diff --git a/src/lib/live-activity.test.ts b/src/lib/live-activity.test.ts
index bb9a3e196a..5bbc9c8421 100644
--- a/src/lib/live-activity.test.ts
+++ b/src/lib/live-activity.test.ts
@@ -150,6 +150,20 @@ describe("turnNowPhrases: what the status line says is happening now", () => {
expect(turnNowPhrases(null)).toBeNull();
});
+ it("names the command, the search and the page the server read from the call, with the whole command for the hover", () => {
+ const command = turnNowPhrases({ activity: "command", itemId: "c", target: "scrape.py", detail: "cd ~/biber && python3 scrape.py --pages 40" });
+ expect(command).toEqual({ phase: "step:command:scrape.py", phrases: ["Running scrape.py"], hover: "cd ~/biber && python3 scrape.py --pages 40" });
+ expect(turnNowPhrases({ activity: "web", target: "Biber Dammbau" })?.phrases).toEqual(["Searching the web for “Biber Dammbau”"]);
+ expect(turnNowPhrases({ activity: "fetch", target: "linkedin.com" })?.phrases).toEqual(["Reading linkedin.com"]);
+ });
+
+ it("names a running chip by the step stored with it, before the server's English narration", () => {
+ const chip = activity("Bash", { spoken: "running a command", step: { activity: "command", target: "pnpm test", detail: "cd web && pnpm test" } });
+ expect(turnNowPhrases(null, chip)).toMatchObject({ phrases: ["Running pnpm test"], hover: "cd web && pnpm test" });
+ expect(activityStepLabel({ name: "Write", step: { activity: "write", target: "report.md" } })).toBe("Writing report.md");
+ expect(turnNowPhrases(null, activity("Bash", { ok: true, step: { activity: "command", target: "pnpm test" } }))).toBeNull();
+ });
+
it("shows no size under a kilobyte", () => {
expect(formatProgressSize(1023)).toBeUndefined();
expect(formatProgressSize(1024)).toBe("1 KB");
diff --git a/src/lib/live-activity.ts b/src/lib/live-activity.ts
index 333fe5be94..fb45e3a61f 100644
--- a/src/lib/live-activity.ts
+++ b/src/lib/live-activity.ts
@@ -2,7 +2,7 @@ import type { Message } from "@/state/store";
import type { LiveStatus } from "@/state/turn-status";
import { activeLocale, t } from "./i18n";
import type { LocaleKey } from "@/locales";
-import { progressSize } from "../../shared/turn-progress";
+import { progressSize, type LiveStep } from "../../shared/turn-progress";
// Keys, not labels: this array is built at import time, and t() reads the active pack when called.
const FALLBACK_LABELS: Array<[RegExp, LocaleKey]> = [
@@ -68,6 +68,8 @@ export type LiveActivityPhrases = {
phrases: string[];
/** How much of the file the call has written so far ("14 KB"), shown apart so a growing size never re-fades the phrase. */
size?: string;
+ /** The whole command, query or page address behind a step's short words, for the phrase's tooltip. */
+ hover?: string;
};
function phaseOf(key: LocaleKey): LiveActivityPhrases {
@@ -86,10 +88,18 @@ export function liveActivityPhrases(message?: Message): LiveActivityPhrases {
return toolActivityPhrases(message.tool);
}
-export function activityStepLabel(tool: { name: string; spoken?: string }): string {
+export function activityStepLabel(tool: ActivityTool): string {
return toolActivityPhrases(tool).phrases[0];
}
+const STEP_KEYS = { command: "chat.activity.runningNamed", web: "chat.activity.searchingWebFor", fetch: "chat.activity.readingSite" } as const;
+
+/** A step as the status line reads it: a command, search or page by its words, a file by its name. */
+export function stepStatus(step: LiveStep): LiveStatus {
+ return step.activity in STEP_KEYS ? { activity: step.activity, target: step.target, ...(step.detail ? { detail: step.detail } : {}) }
+ : { activity: step.activity, file: step.target };
+}
+
/** The status line's "now": the engine's own report when it made one, else the tool call still running in the chat,
* else nothing, and the line shows its timer alone. */
export function turnNowPhrases(status: LiveStatus | null, message?: Message): LiveActivityPhrases | null {
@@ -114,22 +124,23 @@ function liveStatusPhrases(status: LiveStatus): LiveActivityPhrases | null {
return phaseOf("chat.activity.reply");
case "write":
case "edit": {
- const named = status.file
- ? t(status.activity === "write" ? "chat.activity.writingNamed" : "chat.activity.editingNamed", { file: status.file })
+ const file = status.file ?? status.target;
+ const named = file
+ ? t(status.activity === "write" ? "chat.activity.writingNamed" : "chat.activity.editingNamed", { file })
: t(status.activity === "write" ? "chat.activity.writeFile" : "chat.activity.editFile");
const size = formatProgressSize(status.bytes);
return { phase: `live:${status.itemId ?? ""}:${named}`, phrases: [named], ...(size ? { size } : {}) };
}
- case "read":
- return status.file
- ? { phase: `live:read:${status.file}`, phrases: [t("chat.activity.readingNamed", { file: status.file })] }
- : phaseOf("chat.activity.readFile");
+ case "read": {
+ const file = status.file ?? status.target;
+ return file ? { phase: `live:read:${file}`, phrases: [t("chat.activity.readingNamed", { file })] } : phaseOf("chat.activity.readFile");
+ }
case "command":
- return phaseOf("chat.activity.runCommand");
case "web":
- return phaseOf("chat.activity.searchWeb");
case "fetch":
- return phaseOf("chat.activity.readPage");
+ return status.target
+ ? { phase: `step:${status.activity}:${status.target}`, phrases: [t(STEP_KEYS[status.activity], { target: status.target })], ...(status.detail ? { hover: status.detail } : {}) }
+ : phaseOf(status.activity === "command" ? "chat.activity.runCommand" : status.activity === "web" ? "chat.activity.searchWeb" : "chat.activity.readPage");
case "search":
return phaseOf("chat.activity.searching");
default: {
@@ -139,7 +150,11 @@ function liveStatusPhrases(status: LiveStatus): LiveActivityPhrases | null {
}
}
-function toolActivityPhrases(tool: { name: string; spoken?: string }): LiveActivityPhrases {
+type ActivityTool = { name: string; spoken?: string; step?: LiveStep };
+
+export function toolActivityPhrases(tool: ActivityTool): LiveActivityPhrases {
+ const step = tool.step ? liveStatusPhrases(stepStatus(tool.step)) : null;
+ if (step) return step;
const spoken = tool.spoken?.trim();
if (spoken) return { phase: `spoken:${spoken}`, phrases: [sentenceCase(spoken)] };
diff --git a/src/lib/now-steps.test.ts b/src/lib/now-steps.test.ts
new file mode 100644
index 0000000000..8229eb9377
--- /dev/null
+++ b/src/lib/now-steps.test.ts
@@ -0,0 +1,61 @@
+import { describe, expect, it } from "vitest";
+
+import type { Message } from "@/state/store";
+import { nowSteps, quietText, stepLabel } from "./now-steps";
+
+let id = 0;
+const ask = (text: string, extra: Partial<Message> = {}): Message => ({ id: `u${++id}`, role: "user", kind: "text", at: id, text, ...extra });
+const call = (name: string, tool: Partial<NonNullable<Message["tool"]>> = {}): Message =>
+ ({ id: `a${++id}`, role: "bot", kind: "activity", at: id, tool: { name, itemId: `item-${id}`, ...tool } });
+
+describe("the Now card's steps", () => {
+ it("lists the current ask's calls in order: done in the past tense, the running one as the line says it", () => {
+ const messages = [
+ ask("Old question"),
+ call("Bash", { ok: true, step: { activity: "command", target: "ls" } }),
+ ask("Find construction leads for Biber"),
+ call("WebSearch", { ok: true, step: { activity: "web", target: "Biber Dammbau" } }),
+ call("WebFetch", { ok: true, step: { activity: "fetch", target: "linkedin.com", detail: "linkedin.com/company/biber" } }),
+ call("Bash", { ok: false }),
+ ask("and hurry", { steered: true }),
+ call("Bash", { step: { activity: "command", target: "scrape.py", detail: "python3 scrape.py --pages 40" } }),
+ ];
+ expect(nowSteps(messages, null).map(({ label, state, hover }) => ({ label, state, hover }))).toEqual([
+ { label: "Searched the web for “Biber Dammbau”", state: "done", hover: undefined },
+ { label: "Read linkedin.com", state: "done", hover: "linkedin.com/company/biber" },
+ { label: "Ran a command", state: "failed", hover: undefined },
+ { label: "Running scrape.py", state: "now", hover: "python3 scrape.py --pages 40" },
+ ]);
+ });
+
+ it("keeps the last few, leaves out notices and team chips, and adds the live call the chat has no row for yet", () => {
+ const messages = [
+ ask("Build the report"),
+ ...Array.from({ length: 5 }, (_, n) => call("Read", { ok: true, step: { activity: "read", target: `notes-${n}.md` } })),
+ { id: "notice", role: "bot", kind: "activity", at: 99, tool: { name: "Approve for me: …", ok: true } } as Message,
+ { ...call("ask_bot", { ok: true }), comm: { groupId: "g", withBotId: "b", withName: "Kai", withColor: "blue" } } as Message,
+ ];
+ const steps = nowSteps(messages, { activity: "write", itemId: "w1", file: "report.md", bytes: 9_000 });
+ expect(steps.map((step) => step.label)).toEqual(["Read notes-2.md", "Read notes-3.md", "Read notes-4.md", "Writing report.md"]);
+ expect(steps.at(-1)?.state).toBe("now");
+ });
+
+ it("says a finished step it cannot name in plain past words, and keeps an unknown tool's own label", () => {
+ expect(stepLabel({ name: "Bash", ok: true }, "done")).toBe("Ran a command");
+ expect(stepLabel({ name: "Grep", ok: true }, "done")).toBe("Searched files");
+ expect(stepLabel({ name: "mcp__agents__ask_bot", ok: true }, "done")).toBe("Asking a teammate");
+ });
+});
+
+describe("a long step's sign of life", () => {
+ it("counts the time since its last output, and says what its processes show while it has printed nothing", () => {
+ const at = 1_000_000;
+ expect(quietText({ kind: "output", at }, at + 20_000)).toBe("last output just now");
+ expect(quietText({ kind: "output", at }, at + 2 * 60_000 + 5_000)).toBe("last output 2 min ago");
+ expect(quietText({ kind: "output", at }, at + 3 * 60 * 60_000)).toBe("last output 3 h ago");
+ expect(quietText({ kind: "network" }, at)).toBe("waiting on the network");
+ expect(quietText({ kind: "busy" }, at)).toBe("busy, no output yet");
+ expect(quietText({ kind: "idle" }, at)).toBe("idle, no output yet");
+ expect(quietText(undefined, at)).toBeUndefined();
+ });
+});
diff --git a/src/lib/now-steps.ts b/src/lib/now-steps.ts
new file mode 100644
index 0000000000..090b9633ba
--- /dev/null
+++ b/src/lib/now-steps.ts
@@ -0,0 +1,76 @@
+import type { LocaleKey } from "@/locales";
+import type { Message } from "@/state/store";
+import type { LiveStatus } from "@/state/turn-status";
+import type { StepQuiet } from "../../shared/turn-progress";
+import { t } from "./i18n";
+import { toolActivityPhrases, turnNowPhrases } from "./live-activity";
+
+export type NowStepState = "done" | "failed" | "now";
+
+export interface NowStep {
+ id: string;
+ label: string;
+ state: NowStepState;
+ hover?: string;
+}
+
+const DONE_NAMED: Partial<Record<string, LocaleKey>> = {
+ command: "chat.now.ranNamed",
+ web: "chat.now.searchedWebFor",
+ fetch: "chat.now.readSite",
+ read: "chat.now.readNamed",
+ write: "chat.now.wroteNamed",
+ edit: "chat.now.editedNamed",
+};
+
+const DONE_PLAIN: Partial<Record<string, LocaleKey>> = {
+ "chat.activity.runCommand": "chat.now.ranCommand",
+ "chat.activity.searchWeb": "chat.now.searchedWeb",
+ "chat.activity.readPage": "chat.now.readPage",
+ "chat.activity.readFile": "chat.now.readFile",
+ "chat.activity.writeFile": "chat.now.wroteFile",
+ "chat.activity.editFile": "chat.now.editedFile",
+ "chat.activity.searching": "chat.now.searchedFiles",
+};
+
+type StepTool = NonNullable<Message["tool"]>;
+
+export function stepLabel(tool: StepTool, state: NowStepState): string {
+ const now = toolActivityPhrases(tool);
+ if (state === "now") return now.phrases[0]!;
+ const named = tool.step && DONE_NAMED[tool.step.activity];
+ if (named) return t(named, { target: tool.step!.target });
+ const plain = DONE_PLAIN[now.phase];
+ return plain ? t(plain) : now.phrases[0]!;
+}
+
+const isCall = (message: Message) =>
+ message.kind === "activity" && Boolean(message.tool?.itemId) && !message.comm && !message.tool?.rescue;
+
+/** The current ask's tool calls, newest last: what it did and what it is doing, with the live call the chat has no row
+ * for yet (a file whose content the engine is still writing). */
+export function nowSteps(messages: readonly Message[], status: LiveStatus | null, limit = 4): NowStep[] {
+ const asked = messages.findLastIndex((message) => message.role === "user" && message.kind === "text" && !message.steered);
+ const calls = messages.slice(asked + 1).filter(isCall);
+ const steps: NowStep[] = calls.map((message) => {
+ const tool = message.tool!;
+ const state: NowStepState = tool.ok === undefined ? "now" : tool.ok ? "done" : "failed";
+ return { id: message.id, label: stepLabel(tool, state), state, ...(tool.step?.detail ? { hover: tool.step.detail } : {}) };
+ });
+ const itemId = status?.itemId;
+ const live = itemId && !calls.some((message) => message.tool?.itemId === itemId) ? turnNowPhrases(status) : null;
+ if (live) steps.push({ id: `live:${itemId}`, label: live.phrases[0]!, state: "now", ...(live.hover ? { hover: live.hover } : {}) });
+ return steps.slice(-limit);
+}
+
+const PROCESS_STATE = { network: "chat.liveness.network", busy: "chat.liveness.busy", idle: "chat.liveness.idle" } as const;
+
+/** "last output 2 min ago", or what the call's processes show while it has printed nothing. */
+export function quietText(quiet: StepQuiet | undefined, now: number): string | undefined {
+ if (!quiet) return undefined;
+ if (quiet.kind !== "output") return t(PROCESS_STATE[quiet.kind]);
+ const minutes = Math.floor(Math.max(0, now - quiet.at) / 60_000);
+ if (minutes < 1) return t("chat.liveness.outputJustNow");
+ if (minutes < 60) return t("chat.liveness.outputMinutes", { count: minutes });
+ return t("chat.liveness.outputHours", { count: Math.floor(minutes / 60) });
+}
diff --git a/src/locales/de.json b/src/locales/de.json
index e8982841a6..6499f73e4e 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -775,6 +775,34 @@
"chat.activity.writingNamed": "Schreibt {file}",
"chat.activity.editingNamed": "Bearbeitet {file}",
"chat.activity.readingNamed": "Liest {file}",
+ "chat.activity.runningNamed": "Führt {target} aus",
+ "chat.activity.searchingWebFor": "Durchsucht das Web nach „{target}“",
+ "chat.activity.readingSite": "Liest {target}",
+ "chat.liveness.outputJustNow": "letzte Ausgabe gerade eben",
+ "chat.liveness.outputMinutes": "letzte Ausgabe vor {count} Min.",
+ "chat.liveness.outputHours": "letzte Ausgabe vor {count} Std.",
+ "chat.liveness.network": "wartet auf das Netzwerk",
+ "chat.liveness.busy": "beschäftigt, noch keine Ausgabe",
+ "chat.liveness.idle": "im Leerlauf, noch keine Ausgabe",
+ "chat.now.title": "Was {name} gerade tut",
+ "chat.now.openActivity": "Aktivität öffnen",
+ "chat.now.output": "Neueste Ausgabe",
+ "chat.now.stateDone": "erledigt",
+ "chat.now.stateNow": "läuft",
+ "chat.now.stateFailed": "fehlgeschlagen",
+ "chat.now.ranNamed": "Hat {target} ausgeführt",
+ "chat.now.searchedWebFor": "Hat das Web nach „{target}“ durchsucht",
+ "chat.now.readSite": "Hat {target} gelesen",
+ "chat.now.readNamed": "Hat {target} gelesen",
+ "chat.now.wroteNamed": "Hat {target} geschrieben",
+ "chat.now.editedNamed": "Hat {target} bearbeitet",
+ "chat.now.ranCommand": "Hat einen Befehl ausgeführt",
+ "chat.now.searchedWeb": "Hat das Web durchsucht",
+ "chat.now.readPage": "Hat eine Seite gelesen",
+ "chat.now.readFile": "Hat eine Datei gelesen",
+ "chat.now.wroteFile": "Hat eine Datei geschrieben",
+ "chat.now.editedFile": "Hat eine Datei bearbeitet",
+ "chat.now.searchedFiles": "Hat Dateien durchsucht",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.run.worked": "Gearbeitet",
diff --git a/src/locales/en.json b/src/locales/en.json
index 6982f26a5b..d4d4c86bee 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -2078,6 +2078,34 @@
"chat.activity.writingNamed": "Writing {file}",
"chat.activity.editingNamed": "Editing {file}",
"chat.activity.readingNamed": "Reading {file}",
+ "chat.activity.runningNamed": "Running {target}",
+ "chat.activity.searchingWebFor": "Searching the web for “{target}”",
+ "chat.activity.readingSite": "Reading {target}",
+ "chat.liveness.outputJustNow": "last output just now",
+ "chat.liveness.outputMinutes": "last output {count} min ago",
+ "chat.liveness.outputHours": "last output {count} h ago",
+ "chat.liveness.network": "waiting on the network",
+ "chat.liveness.busy": "busy, no output yet",
+ "chat.liveness.idle": "idle, no output yet",
+ "chat.now.title": "What {name} is doing",
+ "chat.now.openActivity": "Open activity",
+ "chat.now.output": "Latest output",
+ "chat.now.stateDone": "done",
+ "chat.now.stateNow": "in progress",
+ "chat.now.stateFailed": "failed",
+ "chat.now.ranNamed": "Ran {target}",
+ "chat.now.searchedWebFor": "Searched the web for “{target}”",
+ "chat.now.readSite": "Read {target}",
+ "chat.now.readNamed": "Read {target}",
+ "chat.now.wroteNamed": "Wrote {target}",
+ "chat.now.editedNamed": "Edited {target}",
+ "chat.now.ranCommand": "Ran a command",
+ "chat.now.searchedWeb": "Searched the web",
+ "chat.now.readPage": "Read a page",
+ "chat.now.readFile": "Read a file",
+ "chat.now.wroteFile": "Wrote a file",
+ "chat.now.editedFile": "Edited a file",
+ "chat.now.searchedFiles": "Searched files",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.activity.alt.mullingItOver": "Mulling it over",
diff --git a/src/locales/es.json b/src/locales/es.json
index 1b31727942..b26c94babb 100644
--- a/src/locales/es.json
+++ b/src/locales/es.json
@@ -1799,6 +1799,34 @@
"chat.activity.writingNamed": "Escribiendo {file}",
"chat.activity.editingNamed": "Editando {file}",
"chat.activity.readingNamed": "Leyendo {file}",
+ "chat.activity.runningNamed": "Ejecutando {target}",
+ "chat.activity.searchingWebFor": "Buscando «{target}» en la web",
+ "chat.activity.readingSite": "Leyendo {target}",
+ "chat.liveness.outputJustNow": "última salida hace un momento",
+ "chat.liveness.outputMinutes": "última salida hace {count} min",
+ "chat.liveness.outputHours": "última salida hace {count} h",
+ "chat.liveness.network": "esperando a la red",
+ "chat.liveness.busy": "ocupado, aún sin salida",
+ "chat.liveness.idle": "inactivo, aún sin salida",
+ "chat.now.title": "Qué está haciendo {name}",
+ "chat.now.openActivity": "Abrir actividad",
+ "chat.now.output": "Última salida",
+ "chat.now.stateDone": "hecho",
+ "chat.now.stateNow": "en curso",
+ "chat.now.stateFailed": "falló",
+ "chat.now.ranNamed": "Ejecutó {target}",
+ "chat.now.searchedWebFor": "Buscó «{target}» en la web",
+ "chat.now.readSite": "Leyó {target}",
+ "chat.now.readNamed": "Leyó {target}",
+ "chat.now.wroteNamed": "Escribió {target}",
+ "chat.now.editedNamed": "Editó {target}",
+ "chat.now.ranCommand": "Ejecutó un comando",
+ "chat.now.searchedWeb": "Buscó en la web",
+ "chat.now.readPage": "Leyó una página",
+ "chat.now.readFile": "Leyó un archivo",
+ "chat.now.wroteFile": "Escribió un archivo",
+ "chat.now.editedFile": "Editó un archivo",
+ "chat.now.searchedFiles": "Buscó en archivos",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.activity.alt.mullingItOver": "Dándole vueltas",
diff --git a/src/locales/fr.json b/src/locales/fr.json
index 39148459d6..46adfacfb3 100644
--- a/src/locales/fr.json
+++ b/src/locales/fr.json
@@ -687,6 +687,34 @@
"chat.activity.writingNamed": "Écrit {file}",
"chat.activity.editingNamed": "Modifie {file}",
"chat.activity.readingNamed": "Lit {file}",
+ "chat.activity.runningNamed": "Exécute {target}",
+ "chat.activity.searchingWebFor": "Cherche « {target} » sur le web",
+ "chat.activity.readingSite": "Lit {target}",
+ "chat.liveness.outputJustNow": "dernière sortie à l’instant",
+ "chat.liveness.outputMinutes": "dernière sortie il y a {count} min",
+ "chat.liveness.outputHours": "dernière sortie il y a {count} h",
+ "chat.liveness.network": "attend le réseau",
+ "chat.liveness.busy": "occupé, pas encore de sortie",
+ "chat.liveness.idle": "inactif, pas encore de sortie",
+ "chat.now.title": "Ce que fait {name}",
+ "chat.now.openActivity": "Ouvrir l’activité",
+ "chat.now.output": "Dernière sortie",
+ "chat.now.stateDone": "terminé",
+ "chat.now.stateNow": "en cours",
+ "chat.now.stateFailed": "échec",
+ "chat.now.ranNamed": "A exécuté {target}",
+ "chat.now.searchedWebFor": "A cherché « {target} » sur le web",
+ "chat.now.readSite": "A lu {target}",
+ "chat.now.readNamed": "A lu {target}",
+ "chat.now.wroteNamed": "A écrit {target}",
+ "chat.now.editedNamed": "A modifié {target}",
+ "chat.now.ranCommand": "A exécuté une commande",
+ "chat.now.searchedWeb": "A cherché sur le web",
+ "chat.now.readPage": "A lu une page",
+ "chat.now.readFile": "A lu un fichier",
+ "chat.now.wroteFile": "A écrit un fichier",
+ "chat.now.editedFile": "A modifié un fichier",
+ "chat.now.searchedFiles": "A cherché dans les fichiers",
"chat.activity.sizeKb": "{count} Ko",
"chat.activity.sizeMb": "{count} Mo",
"chat.run.worked": "A travaillé",
diff --git a/src/locales/hi.json b/src/locales/hi.json
index fa780f85d9..a3abd85d74 100644
--- a/src/locales/hi.json
+++ b/src/locales/hi.json
@@ -687,6 +687,34 @@
"chat.activity.writingNamed": "{file} लिख रहा है",
"chat.activity.editingNamed": "{file} संपादित कर रहा है",
"chat.activity.readingNamed": "{file} पढ़ रहा है",
+ "chat.activity.runningNamed": "{target} चला रहा है",
+ "chat.activity.searchingWebFor": "वेब पर “{target}” खोज रहा है",
+ "chat.activity.readingSite": "{target} पढ़ रहा है",
+ "chat.liveness.outputJustNow": "आखिरी आउटपुट अभी-अभी",
+ "chat.liveness.outputMinutes": "आखिरी आउटपुट {count} मिनट पहले",
+ "chat.liveness.outputHours": "आखिरी आउटपुट {count} घंटे पहले",
+ "chat.liveness.network": "नेटवर्क का इंतज़ार कर रहा है",
+ "chat.liveness.busy": "व्यस्त, अभी तक कोई आउटपुट नहीं",
+ "chat.liveness.idle": "निष्क्रिय, अभी तक कोई आउटपुट नहीं",
+ "chat.now.title": "{name} अभी क्या कर रहा है",
+ "chat.now.openActivity": "गतिविधि खोलें",
+ "chat.now.output": "नवीनतम आउटपुट",
+ "chat.now.stateDone": "पूरा",
+ "chat.now.stateNow": "चल रहा है",
+ "chat.now.stateFailed": "विफल",
+ "chat.now.ranNamed": "{target} चलाया",
+ "chat.now.searchedWebFor": "वेब पर “{target}” खोजा",
+ "chat.now.readSite": "{target} पढ़ा",
+ "chat.now.readNamed": "{target} पढ़ा",
+ "chat.now.wroteNamed": "{target} लिखा",
+ "chat.now.editedNamed": "{target} संपादित किया",
+ "chat.now.ranCommand": "एक कमांड चलाया",
+ "chat.now.searchedWeb": "वेब पर खोजा",
+ "chat.now.readPage": "एक पेज पढ़ा",
+ "chat.now.readFile": "एक फ़ाइल पढ़ी",
+ "chat.now.wroteFile": "एक फ़ाइल लिखी",
+ "chat.now.editedFile": "एक फ़ाइल संपादित की",
+ "chat.now.searchedFiles": "फ़ाइलें खोजीं",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.run.worked": "काम किया",
diff --git a/src/locales/it.json b/src/locales/it.json
index 53ecf2221c..e912d91f2b 100644
--- a/src/locales/it.json
+++ b/src/locales/it.json
@@ -1895,6 +1895,34 @@
"chat.activity.writingNamed": "Scrive {file}",
"chat.activity.editingNamed": "Modifica {file}",
"chat.activity.readingNamed": "Legge {file}",
+ "chat.activity.runningNamed": "Esegue {target}",
+ "chat.activity.searchingWebFor": "Cerca «{target}» sul web",
+ "chat.activity.readingSite": "Legge {target}",
+ "chat.liveness.outputJustNow": "ultimo output poco fa",
+ "chat.liveness.outputMinutes": "ultimo output {count} min fa",
+ "chat.liveness.outputHours": "ultimo output {count} h fa",
+ "chat.liveness.network": "in attesa della rete",
+ "chat.liveness.busy": "occupato, ancora nessun output",
+ "chat.liveness.idle": "inattivo, ancora nessun output",
+ "chat.now.title": "Cosa sta facendo {name}",
+ "chat.now.openActivity": "Apri attività",
+ "chat.now.output": "Ultimo output",
+ "chat.now.stateDone": "fatto",
+ "chat.now.stateNow": "in corso",
+ "chat.now.stateFailed": "non riuscito",
+ "chat.now.ranNamed": "Ha eseguito {target}",
+ "chat.now.searchedWebFor": "Ha cercato «{target}» sul web",
+ "chat.now.readSite": "Ha letto {target}",
+ "chat.now.readNamed": "Ha letto {target}",
+ "chat.now.wroteNamed": "Ha scritto {target}",
+ "chat.now.editedNamed": "Ha modificato {target}",
+ "chat.now.ranCommand": "Ha eseguito un comando",
+ "chat.now.searchedWeb": "Ha cercato sul web",
+ "chat.now.readPage": "Ha letto una pagina",
+ "chat.now.readFile": "Ha letto un file",
+ "chat.now.wroteFile": "Ha scritto un file",
+ "chat.now.editedFile": "Ha modificato un file",
+ "chat.now.searchedFiles": "Ha cercato nei file",
"chat.activity.alt.mullingItOver": "Ci rimugina",
"chat.activity.alt.piecingItTogether": "Mette insieme i pezzi",
"chat.activity.alt.workingItOut": "Ci sta arrivando",
diff --git a/src/locales/ja.json b/src/locales/ja.json
index 146fcbaf97..0467eef53d 100644
--- a/src/locales/ja.json
+++ b/src/locales/ja.json
@@ -1994,6 +1994,34 @@
"chat.activity.writingNamed": "{file} を書き込み中",
"chat.activity.editingNamed": "{file} を編集中",
"chat.activity.readingNamed": "{file} を読み込み中",
+ "chat.activity.runningNamed": "{target} を実行中",
+ "chat.activity.searchingWebFor": "ウェブで「{target}」を検索中",
+ "chat.activity.readingSite": "{target} を読み込み中",
+ "chat.liveness.outputJustNow": "最後の出力: たった今",
+ "chat.liveness.outputMinutes": "最後の出力: {count} 分前",
+ "chat.liveness.outputHours": "最後の出力: {count} 時間前",
+ "chat.liveness.network": "ネットワーク待ち",
+ "chat.liveness.busy": "処理中、まだ出力なし",
+ "chat.liveness.idle": "待機中、まだ出力なし",
+ "chat.now.title": "{name} が今していること",
+ "chat.now.openActivity": "アクティビティを開く",
+ "chat.now.output": "最新の出力",
+ "chat.now.stateDone": "完了",
+ "chat.now.stateNow": "実行中",
+ "chat.now.stateFailed": "失敗",
+ "chat.now.ranNamed": "{target} を実行しました",
+ "chat.now.searchedWebFor": "ウェブで「{target}」を検索しました",
+ "chat.now.readSite": "{target} を読みました",
+ "chat.now.readNamed": "{target} を読みました",
+ "chat.now.wroteNamed": "{target} を書きました",
+ "chat.now.editedNamed": "{target} を編集しました",
+ "chat.now.ranCommand": "コマンドを実行しました",
+ "chat.now.searchedWeb": "ウェブを検索しました",
+ "chat.now.readPage": "ページを読みました",
+ "chat.now.readFile": "ファイルを読みました",
+ "chat.now.wroteFile": "ファイルを書きました",
+ "chat.now.editedFile": "ファイルを編集しました",
+ "chat.now.searchedFiles": "ファイルを検索しました",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.activity.alt.mullingItOver": "じっくり考え中",
diff --git a/src/locales/pl.json b/src/locales/pl.json
index a56f8216a9..217baefb5a 100644
--- a/src/locales/pl.json
+++ b/src/locales/pl.json
@@ -1937,6 +1937,34 @@
"chat.activity.writingNamed": "Zapisywanie: {file}",
"chat.activity.editingNamed": "Edytowanie: {file}",
"chat.activity.readingNamed": "Czytanie: {file}",
+ "chat.activity.runningNamed": "Uruchamianie: {target}",
+ "chat.activity.searchingWebFor": "Szukanie w sieci: „{target}”",
+ "chat.activity.readingSite": "Czytanie: {target}",
+ "chat.liveness.outputJustNow": "ostatnie wyjście przed chwilą",
+ "chat.liveness.outputMinutes": "ostatnie wyjście {count} min temu",
+ "chat.liveness.outputHours": "ostatnie wyjście {count} godz. temu",
+ "chat.liveness.network": "czeka na sieć",
+ "chat.liveness.busy": "zajęty, jeszcze bez wyjścia",
+ "chat.liveness.idle": "bezczynny, jeszcze bez wyjścia",
+ "chat.now.title": "Co teraz robi {name}",
+ "chat.now.openActivity": "Otwórz aktywność",
+ "chat.now.output": "Najnowsze wyjście",
+ "chat.now.stateDone": "gotowe",
+ "chat.now.stateNow": "w toku",
+ "chat.now.stateFailed": "nie powiodło się",
+ "chat.now.ranNamed": "Uruchomiono: {target}",
+ "chat.now.searchedWebFor": "Wyszukano w sieci: „{target}”",
+ "chat.now.readSite": "Przeczytano: {target}",
+ "chat.now.readNamed": "Przeczytano: {target}",
+ "chat.now.wroteNamed": "Zapisano: {target}",
+ "chat.now.editedNamed": "Edytowano: {target}",
+ "chat.now.ranCommand": "Uruchomiono polecenie",
+ "chat.now.searchedWeb": "Przeszukano sieć",
+ "chat.now.readPage": "Przeczytano stronę",
+ "chat.now.readFile": "Przeczytano plik",
+ "chat.now.wroteFile": "Zapisano plik",
+ "chat.now.editedFile": "Edytowano plik",
+ "chat.now.searchedFiles": "Przeszukano pliki",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.activity.alt.mullingItOver": "Zastanawianie się",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index f415fa4e01..53db7c0615 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -1861,6 +1861,34 @@
"chat.activity.writingNamed": "Escrevendo {file}",
"chat.activity.editingNamed": "Editando {file}",
"chat.activity.readingNamed": "Lendo {file}",
+ "chat.activity.runningNamed": "Executando {target}",
+ "chat.activity.searchingWebFor": "Pesquisando “{target}” na web",
+ "chat.activity.readingSite": "Lendo {target}",
+ "chat.liveness.outputJustNow": "última saída agora mesmo",
+ "chat.liveness.outputMinutes": "última saída há {count} min",
+ "chat.liveness.outputHours": "última saída há {count} h",
+ "chat.liveness.network": "aguardando a rede",
+ "chat.liveness.busy": "ocupado, ainda sem saída",
+ "chat.liveness.idle": "ocioso, ainda sem saída",
+ "chat.now.title": "O que {name} está fazendo",
+ "chat.now.openActivity": "Abrir atividade",
+ "chat.now.output": "Última saída",
+ "chat.now.stateDone": "concluído",
+ "chat.now.stateNow": "em andamento",
+ "chat.now.stateFailed": "falhou",
+ "chat.now.ranNamed": "Executou {target}",
+ "chat.now.searchedWebFor": "Pesquisou “{target}” na web",
+ "chat.now.readSite": "Leu {target}",
+ "chat.now.readNamed": "Leu {target}",
+ "chat.now.wroteNamed": "Escreveu {target}",
+ "chat.now.editedNamed": "Editou {target}",
+ "chat.now.ranCommand": "Executou um comando",
+ "chat.now.searchedWeb": "Pesquisou na web",
+ "chat.now.readPage": "Leu uma página",
+ "chat.now.readFile": "Leu um arquivo",
+ "chat.now.wroteFile": "Escreveu um arquivo",
+ "chat.now.editedFile": "Editou um arquivo",
+ "chat.now.searchedFiles": "Pesquisou arquivos",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.activity.alt.mullingItOver": "Refletindo",
diff --git a/src/locales/ru.json b/src/locales/ru.json
index 7d77f9af95..8e0faf0a6a 100644
--- a/src/locales/ru.json
+++ b/src/locales/ru.json
@@ -1976,6 +1976,34 @@
"chat.activity.writingNamed": "Пишет {file}",
"chat.activity.editingNamed": "Редактирует {file}",
"chat.activity.readingNamed": "Читает {file}",
+ "chat.activity.runningNamed": "Выполняет {target}",
+ "chat.activity.searchingWebFor": "Ищет в интернете «{target}»",
+ "chat.activity.readingSite": "Читает {target}",
+ "chat.liveness.outputJustNow": "последний вывод только что",
+ "chat.liveness.outputMinutes": "последний вывод {count} мин назад",
+ "chat.liveness.outputHours": "последний вывод {count} ч назад",
+ "chat.liveness.network": "ждёт сеть",
+ "chat.liveness.busy": "занят, вывода пока нет",
+ "chat.liveness.idle": "простаивает, вывода пока нет",
+ "chat.now.title": "Что сейчас делает {name}",
+ "chat.now.openActivity": "Открыть активность",
+ "chat.now.output": "Последний вывод",
+ "chat.now.stateDone": "готово",
+ "chat.now.stateNow": "выполняется",
+ "chat.now.stateFailed": "не удалось",
+ "chat.now.ranNamed": "Выполнил {target}",
+ "chat.now.searchedWebFor": "Искал в интернете «{target}»",
+ "chat.now.readSite": "Прочитал {target}",
+ "chat.now.readNamed": "Прочитал {target}",
+ "chat.now.wroteNamed": "Записал {target}",
+ "chat.now.editedNamed": "Изменил {target}",
+ "chat.now.ranCommand": "Выполнил команду",
+ "chat.now.searchedWeb": "Искал в интернете",
+ "chat.now.readPage": "Прочитал страницу",
+ "chat.now.readFile": "Прочитал файл",
+ "chat.now.wroteFile": "Записал файл",
+ "chat.now.editedFile": "Изменил файл",
+ "chat.now.searchedFiles": "Искал в файлах",
"chat.activity.sizeKb": "{count} КБ",
"chat.activity.sizeMb": "{count} МБ",
"chat.activity.alt.mullingItOver": "Обдумывает",
diff --git a/src/locales/tr.json b/src/locales/tr.json
index e516079b97..b6394dbe5f 100644
--- a/src/locales/tr.json
+++ b/src/locales/tr.json
@@ -1607,6 +1607,34 @@
"chat.activity.writingNamed": "{file} dosyasını yazıyor",
"chat.activity.editingNamed": "{file} dosyasını düzenliyor",
"chat.activity.readingNamed": "{file} dosyasını okuyor",
+ "chat.activity.runningNamed": "{target} çalıştırıyor",
+ "chat.activity.searchingWebFor": "Web'de “{target}” arıyor",
+ "chat.activity.readingSite": "{target} sayfasını okuyor",
+ "chat.liveness.outputJustNow": "son çıktı az önce",
+ "chat.liveness.outputMinutes": "son çıktı {count} dk önce",
+ "chat.liveness.outputHours": "son çıktı {count} sa önce",
+ "chat.liveness.network": "ağı bekliyor",
+ "chat.liveness.busy": "meşgul, henüz çıktı yok",
+ "chat.liveness.idle": "boşta, henüz çıktı yok",
+ "chat.now.title": "{name} şu an ne yapıyor",
+ "chat.now.openActivity": "Etkinliği aç",
+ "chat.now.output": "En son çıktı",
+ "chat.now.stateDone": "tamamlandı",
+ "chat.now.stateNow": "sürüyor",
+ "chat.now.stateFailed": "başarısız",
+ "chat.now.ranNamed": "{target} çalıştırdı",
+ "chat.now.searchedWebFor": "Web'de “{target}” aradı",
+ "chat.now.readSite": "{target} sayfasını okudu",
+ "chat.now.readNamed": "{target} dosyasını okudu",
+ "chat.now.wroteNamed": "{target} dosyasını yazdı",
+ "chat.now.editedNamed": "{target} dosyasını düzenledi",
+ "chat.now.ranCommand": "Bir komut çalıştırdı",
+ "chat.now.searchedWeb": "Web'de arama yaptı",
+ "chat.now.readPage": "Bir sayfa okudu",
+ "chat.now.readFile": "Bir dosya okudu",
+ "chat.now.wroteFile": "Bir dosya yazdı",
+ "chat.now.editedFile": "Bir dosyayı düzenledi",
+ "chat.now.searchedFiles": "Dosyalarda arama yaptı",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.activity.alt.mullingItOver": "Üzerinde düşünüyor",
diff --git a/src/locales/uk.json b/src/locales/uk.json
index 9e4d975ddf..ddd9b349ca 100644
--- a/src/locales/uk.json
+++ b/src/locales/uk.json
@@ -847,6 +847,34 @@
"chat.activity.writingNamed": "Записує {file}",
"chat.activity.editingNamed": "Редагує {file}",
"chat.activity.readingNamed": "Читає {file}",
+ "chat.activity.runningNamed": "Виконує {target}",
+ "chat.activity.searchingWebFor": "Шукає в інтернеті «{target}»",
+ "chat.activity.readingSite": "Читає {target}",
+ "chat.liveness.outputJustNow": "останній вивід щойно",
+ "chat.liveness.outputMinutes": "останній вивід {count} хв тому",
+ "chat.liveness.outputHours": "останній вивід {count} год тому",
+ "chat.liveness.network": "чекає на мережу",
+ "chat.liveness.busy": "зайнятий, виводу ще немає",
+ "chat.liveness.idle": "простоює, виводу ще немає",
+ "chat.now.title": "Що зараз робить {name}",
+ "chat.now.openActivity": "Відкрити активність",
+ "chat.now.output": "Останній вивід",
+ "chat.now.stateDone": "готово",
+ "chat.now.stateNow": "виконується",
+ "chat.now.stateFailed": "не вдалося",
+ "chat.now.ranNamed": "Виконав {target}",
+ "chat.now.searchedWebFor": "Шукав в інтернеті «{target}»",
+ "chat.now.readSite": "Прочитав {target}",
+ "chat.now.readNamed": "Прочитав {target}",
+ "chat.now.wroteNamed": "Записав {target}",
+ "chat.now.editedNamed": "Змінив {target}",
+ "chat.now.ranCommand": "Виконав команду",
+ "chat.now.searchedWeb": "Шукав в інтернеті",
+ "chat.now.readPage": "Прочитав сторінку",
+ "chat.now.readFile": "Прочитав файл",
+ "chat.now.wroteFile": "Записав файл",
+ "chat.now.editedFile": "Змінив файл",
+ "chat.now.searchedFiles": "Шукав у файлах",
"chat.activity.sizeKb": "{count} КБ",
"chat.activity.sizeMb": "{count} МБ",
"chat.run.worked": "Працював",
diff --git a/src/locales/vi.json b/src/locales/vi.json
index 21f0c5b083..5eecedca0c 100644
--- a/src/locales/vi.json
+++ b/src/locales/vi.json
@@ -1607,6 +1607,34 @@
"chat.activity.writingNamed": "Đang ghi {file}",
"chat.activity.editingNamed": "Đang chỉnh sửa {file}",
"chat.activity.readingNamed": "Đang đọc {file}",
+ "chat.activity.runningNamed": "Đang chạy {target}",
+ "chat.activity.searchingWebFor": "Đang tìm “{target}” trên web",
+ "chat.activity.readingSite": "Đang đọc {target}",
+ "chat.liveness.outputJustNow": "đầu ra gần nhất: vừa xong",
+ "chat.liveness.outputMinutes": "đầu ra gần nhất: {count} phút trước",
+ "chat.liveness.outputHours": "đầu ra gần nhất: {count} giờ trước",
+ "chat.liveness.network": "đang chờ mạng",
+ "chat.liveness.busy": "đang bận, chưa có đầu ra",
+ "chat.liveness.idle": "đang rảnh, chưa có đầu ra",
+ "chat.now.title": "{name} đang làm gì",
+ "chat.now.openActivity": "Mở hoạt động",
+ "chat.now.output": "Đầu ra mới nhất",
+ "chat.now.stateDone": "xong",
+ "chat.now.stateNow": "đang chạy",
+ "chat.now.stateFailed": "thất bại",
+ "chat.now.ranNamed": "Đã chạy {target}",
+ "chat.now.searchedWebFor": "Đã tìm “{target}” trên web",
+ "chat.now.readSite": "Đã đọc {target}",
+ "chat.now.readNamed": "Đã đọc {target}",
+ "chat.now.wroteNamed": "Đã ghi {target}",
+ "chat.now.editedNamed": "Đã sửa {target}",
+ "chat.now.ranCommand": "Đã chạy một lệnh",
+ "chat.now.searchedWeb": "Đã tìm kiếm trên web",
+ "chat.now.readPage": "Đã đọc một trang",
+ "chat.now.readFile": "Đã đọc một tệp",
+ "chat.now.wroteFile": "Đã ghi một tệp",
+ "chat.now.editedFile": "Đã sửa một tệp",
+ "chat.now.searchedFiles": "Đã tìm trong các tệp",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.activity.alt.mullingItOver": "Đang cân nhắc kỹ",
diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.json
index 65866395bd..80056ec2f1 100644
--- a/src/locales/zh-tw.json
+++ b/src/locales/zh-tw.json
@@ -1355,6 +1355,34 @@
"chat.activity.writingNamed": "正在寫入 {file}",
"chat.activity.editingNamed": "正在編輯 {file}",
"chat.activity.readingNamed": "正在讀取 {file}",
+ "chat.activity.runningNamed": "正在執行 {target}",
+ "chat.activity.searchingWebFor": "正在網路上搜尋「{target}」",
+ "chat.activity.readingSite": "正在閱讀 {target}",
+ "chat.liveness.outputJustNow": "最近輸出:剛剛",
+ "chat.liveness.outputMinutes": "最近輸出:{count} 分鐘前",
+ "chat.liveness.outputHours": "最近輸出:{count} 小時前",
+ "chat.liveness.network": "正在等待網路",
+ "chat.liveness.busy": "忙碌中,尚無輸出",
+ "chat.liveness.idle": "閒置中,尚無輸出",
+ "chat.now.title": "{name} 正在做什麼",
+ "chat.now.openActivity": "開啟活動",
+ "chat.now.output": "最新輸出",
+ "chat.now.stateDone": "已完成",
+ "chat.now.stateNow": "進行中",
+ "chat.now.stateFailed": "失敗",
+ "chat.now.ranNamed": "已執行 {target}",
+ "chat.now.searchedWebFor": "已在網路上搜尋「{target}」",
+ "chat.now.readSite": "已閱讀 {target}",
+ "chat.now.readNamed": "已讀取 {target}",
+ "chat.now.wroteNamed": "已寫入 {target}",
+ "chat.now.editedNamed": "已編輯 {target}",
+ "chat.now.ranCommand": "已執行指令",
+ "chat.now.searchedWeb": "已搜尋網路",
+ "chat.now.readPage": "已閱讀網頁",
+ "chat.now.readFile": "已讀取檔案",
+ "chat.now.wroteFile": "已寫入檔案",
+ "chat.now.editedFile": "已編輯檔案",
+ "chat.now.searchedFiles": "已搜尋檔案",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.run.worked": "已執行",
diff --git a/src/locales/zh.json b/src/locales/zh.json
index 88d4f89c1e..837ab82ccc 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -1009,6 +1009,34 @@
"chat.activity.writingNamed": "正在写入 {file}",
"chat.activity.editingNamed": "正在编辑 {file}",
"chat.activity.readingNamed": "正在读取 {file}",
+ "chat.activity.runningNamed": "正在运行 {target}",
+ "chat.activity.searchingWebFor": "正在网上搜索“{target}”",
+ "chat.activity.readingSite": "正在阅读 {target}",
+ "chat.liveness.outputJustNow": "最近输出:刚刚",
+ "chat.liveness.outputMinutes": "最近输出:{count} 分钟前",
+ "chat.liveness.outputHours": "最近输出:{count} 小时前",
+ "chat.liveness.network": "正在等待网络",
+ "chat.liveness.busy": "忙碌中,尚无输出",
+ "chat.liveness.idle": "空闲,尚无输出",
+ "chat.now.title": "{name} 正在做什么",
+ "chat.now.openActivity": "打开活动",
+ "chat.now.output": "最新输出",
+ "chat.now.stateDone": "已完成",
+ "chat.now.stateNow": "进行中",
+ "chat.now.stateFailed": "失败",
+ "chat.now.ranNamed": "已运行 {target}",
+ "chat.now.searchedWebFor": "已在网上搜索“{target}”",
+ "chat.now.readSite": "已阅读 {target}",
+ "chat.now.readNamed": "已读取 {target}",
+ "chat.now.wroteNamed": "已写入 {target}",
+ "chat.now.editedNamed": "已编辑 {target}",
+ "chat.now.ranCommand": "已执行命令",
+ "chat.now.searchedWeb": "已搜索网页",
+ "chat.now.readPage": "已阅读网页",
+ "chat.now.readFile": "已读取文件",
+ "chat.now.wroteFile": "已写入文件",
+ "chat.now.editedFile": "已编辑文件",
+ "chat.now.searchedFiles": "已搜索文件",
"chat.activity.sizeKb": "{count} KB",
"chat.activity.sizeMb": "{count} MB",
"chat.run.worked": "已工作",
diff --git a/src/state/store.tsx b/src/state/store.tsx
index 28aa9483b6..e1df48c938 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -152,7 +152,7 @@ export interface Message extends Pick<import("../../shared/wire").WireMessage, "
goalRun?: GroupGoalRunCardData;
call?: import("../../shared/wire").LiveCallRecord;
channelMode?: "chat" | "goal";
- tool?: { name: string; ok?: boolean; spoken?: string; setup?: boolean; claudeUpdate?: boolean; place?: PlaceRow; limitResetsAt?: number; summary?: string; input?: string; output?: string ; itemId?: string; outputPath?: string; fullResult?: boolean; rescue?: import("../../shared/first-reply-rescue").FirstReplyRescue };
+ tool?: { name: string; ok?: boolean; spoken?: string; setup?: boolean; claudeUpdate?: boolean; place?: PlaceRow; limitResetsAt?: number; summary?: string; input?: string; output?: string ; itemId?: string; outputPath?: string; fullResult?: boolean; rescue?: import("../../shared/first-reply-rescue").FirstReplyRescue; step?: import("../../shared/turn-progress").LiveStep };
steered?: boolean;
via?: "api" | "call";
callId?: string;
diff --git a/src/state/turn-status.test.ts b/src/state/turn-status.test.ts
index 1dc99d3bb0..676935eed8 100644
--- a/src/state/turn-status.test.ts
+++ b/src/state/turn-status.test.ts
@@ -49,6 +49,21 @@ describe("a thread's live turn", () => {
expect(turnLive("t")).toEqual({ turnId: "turn-2", ended: false, status: null });
});
+ it("carries what a call works on, how it is doing and its last output, and changes only when one of them does", () => {
+ note({ type: "item.started", itemType: "tool", itemId: "c", title: "Bash" } as Partial<RuntimeEvent>);
+ note({ type: "turn.progress", activity: "command", itemId: "c", target: "scrape.py", detail: "python3 scrape.py" } as Partial<RuntimeEvent>);
+ const named = turnLive("t");
+ expect(named.status).toEqual({ activity: "command", itemId: "c", target: "scrape.py", detail: "python3 scrape.py" });
+ note({ type: "turn.progress", activity: "command", itemId: "c", target: "scrape.py", detail: "python3 scrape.py" } as Partial<RuntimeEvent>);
+ expect(turnLive("t")).toBe(named);
+ note({ type: "turn.progress", activity: "command", itemId: "c", target: "scrape.py", detail: "python3 scrape.py", quiet: { kind: "busy" } } as Partial<RuntimeEvent>);
+ expect(turnLive("t").status).toMatchObject({ quiet: { kind: "busy" } });
+ note({ type: "turn.progress", activity: "command", itemId: "c", target: "scrape.py", quiet: { kind: "output", at: 5 }, tail: ["page 12 of 40"] } as Partial<RuntimeEvent>);
+ expect(turnLive("t").status).toMatchObject({ quiet: { kind: "output", at: 5 }, tail: ["page 12 of 40"] });
+ note({ type: "thread.token-usage.updated", input: 1, output: 1 } as Partial<RuntimeEvent>);
+ expect(turnLive("t").status, "a token count says nothing about the call").toMatchObject({ target: "scrape.py" });
+ });
+
it("keeps threads apart and returns the same snapshot until something shown changes", () => {
note({ type: "content.delta", streamKind: "assistant_text", delta: "a" } as Partial<RuntimeEvent>, "x");
const first = turnLive("x");
diff --git a/src/state/turn-status.ts b/src/state/turn-status.ts
index a68e5f80b9..151986285b 100644
--- a/src/state/turn-status.ts
+++ b/src/state/turn-status.ts
@@ -4,10 +4,10 @@
import { useSyncExternalStore } from "react";
import type { RuntimeEvent } from "../../shared/runtime-events";
-import type { TurnProgressActivity } from "../../shared/turn-progress";
+import { progressKey, type TurnProgressActivity, type TurnProgressFields } from "../../shared/turn-progress";
export type LiveStatus =
- | { activity: TurnProgressActivity; tool?: string; file?: string; bytes?: number; itemId?: string }
+ | ({ activity: TurnProgressActivity } & Omit<TurnProgressFields, "type" | "activity">)
| { activity: "thinking" | "reply"; itemId?: undefined };
export interface TurnLive {
@@ -25,8 +25,7 @@ const listeners = new Map<string, Set<() => void>>();
function sameStatus(a: LiveStatus | null, b: LiveStatus | null): boolean {
if (a === b) return true;
if (!a || !b) return false;
- const left = a as Record<string, unknown>, right = b as Record<string, unknown>;
- return ["activity", "tool", "file", "bytes", "itemId"].every((key) => left[key] === right[key]);
+ return ("bytes" in a ? a.bytes : undefined) === ("bytes" in b ? b.bytes : undefined) && progressKey(a) === progressKey(b);
}
function put(threadId: string, next: TurnLive): void {
@@ -54,8 +53,11 @@ export function noteTurnEvent(event: RuntimeEvent): void {
case "session.exited":
return put(threadId, { turnId, ended: true, status: null });
case "turn.progress": {
- const { activity, tool, file, bytes, itemId } = event;
- return put(threadId, { turnId, ended: false, status: { activity, ...(tool ? { tool } : {}), ...(file ? { file } : {}), ...(bytes !== undefined ? { bytes } : {}), ...(itemId ? { itemId } : {}) } });
+ const { activity, tool, file, bytes, itemId, target, detail, quiet, tail } = event;
+ return put(threadId, { turnId, ended: false, status: {
+ activity, ...(tool ? { tool } : {}), ...(file ? { file } : {}), ...(bytes !== undefined ? { bytes } : {}), ...(itemId ? { itemId } : {}),
+ ...(target ? { target } : {}), ...(detail ? { detail } : {}), ...(quiet ? { quiet } : {}), ...(tail?.length ? { tail } : {}),
+ } });
}
case "content.delta":
return put(threadId, { turnId, ended: false, status: { activity: event.streamKind === "reasoning_text" ? "thinking" : "reply" } });
diff --git a/src/styles.css b/src/styles.css
index 70c3101e5b..b7e5bf4108 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -1876,7 +1876,46 @@ html[data-cloud-intent-morph] [data-tour="composer"] { view-transition-name: clo
from { opacity: 0; }
}
.turn-phrase-in { animation: shimmer 2s linear infinite, turn-phrase-in 0.32s ease-out both; }
+.turn-now-toggle {
+ display: flex;
+ min-width: 0;
+ max-width: 100%;
+ align-items: center;
+ gap: 6px;
+ margin: -4px -6px;
+ padding: 4px 6px;
+ border-radius: 8px;
+ text-align: start;
+ cursor: pointer;
+}
+.turn-now-toggle:hover, .turn-now-toggle[aria-expanded="true"] {
+ background: color-mix(in srgb, var(--color-ink) 5%, transparent);
+}
+.turn-now-toggle:focus-visible {
+ outline: 1.5px solid var(--color-focus);
+ outline-offset: 1px;
+}
+.turn-now-chevron {
+ flex-shrink: 0;
+ color: var(--color-ink-tertiary);
+ transition: transform 160ms ease-out;
+}
+@keyframes turn-now-in {
+ from { opacity: 0; transform: translateY(-2px); }
+}
+.turn-now-card {
+ margin-top: 8px;
+ margin-inline-start: 44px;
+ width: min(560px, calc(100% - 44px));
+ border-radius: 14px;
+ background: var(--color-composer);
+ box-shadow: 0 0 0 0.5px color-mix(in srgb, var(--color-ink) 10%, transparent);
+ padding: 10px 12px;
+ animation: turn-now-in 160ms ease-out both;
+}
@media (prefers-reduced-motion: reduce) {
+ .turn-now-card { animation: none; }
+ .turn-now-chevron { transition: none; }
.animate-caret, .animate-msg-in, .animate-shimmer, .animate-pop-in, .animate-pop-out { animation: none; }
.animate-status-pulse { animation: none; opacity: 0.6; }
.thinking-shimmer { background: none; color: var(--color-ink-secondary); }