The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 00:45 UTC
fix(web): show details for background commands (#33647)
Add a Details action for pending background commands and subagents. Preserve Claude command metadata across roster updates and bind output visibility to the explicit command item. Keep internal task IDs, duplicate command labels, and empty output headings out of the dialog. Validation: check:changed passed with 371 tests; CI and agentic reviews completed on a0326ab. Verified command details in real Codex and Claude runs. Implemented and verified with GPT 6.1 Sol in the Codex harness.
Yash Singh committed
Nov 9, 2026 at 20:27 UTC
16a6c1c41fc608015d8ea129d7d270c488b7893d
7 files changed
+291
-5
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+57
@@ -10049,6 +10049,32 @@ describe("ClaudeAdapterV2 background wake turns", () => {
10049
attachments: [],
10050
}),
10051
);
10052
+ yield* Queue.offer(
10053
+ harness.sdkMessages,
10054
+ claudeSdkFrame({
10055
+ type: "assistant",
10056
+ message: {
10057
+ model: "claude-sonnet-4-6",
10058
+ id: "msg_background_command",
10059
+ type: "message",
10060
+ role: "assistant",
10061
+ content: [
10062
+ {
10063
+ type: "tool_use",
10064
+ id: WAKE_TOOL_USE_ID,
10065
+ name: "Bash",
10066
+ input: {
10067
+ command: "python3 audit.py > audit.log 2>&1",
10068
+ run_in_background: true,
10069
+ },
10070
+ },
10071
+ ],
10072
+ },
10073
+ parent_tool_use_id: null,
10074
+ uuid: "background-command-launch",
10075
+ session_id: WAKE_NATIVE_SESSION,
10076
+ }),
10077
+ );
10078
yield* Queue.offer(harness.sdkMessages, wakeTaskStarted);
10079
yield* Queue.offer(harness.sdkMessages, turnOneResult);
10080
yield* harness.awaitTerminal(1);
@@ -10062,6 +10088,37 @@ describe("ClaudeAdapterV2 background wake turns", () => {
10088
WAKE_TASK_ID,
10089
);
10090
10091
+ const command = harness.events.find(
10092
+ (event) =>
10093
+ event.type === "turn_item.updated" &&
10094
+ event.turnItem.type === "command_execution" &&
10095
+ event.turnItem.nativeItemRef?.nativeId === WAKE_TOOL_USE_ID,
10096
+ );
10097
+ assert.equal(command?.type, "turn_item.updated");
10098
+ if (command?.type !== "turn_item.updated") return;
10099
+ const details = {
10100
+ command: "python3 audit.py > audit.log 2>&1",
10101
+ itemId: command.turnItem.id,
10102
+ };
10103
+ assert.deepInclude(
10104
+ afterStart.at(-1)?.providerThread.pendingBackgroundTasks?.[0],
10105
+ details,
10106
+ );
10107
+ yield* harness.offerAndWait(
10108
+ claudeSdkFrame({
10109
+ type: "system",
10110
+ subtype: "background_tasks_changed",
10111
+ tasks: [{ task_id: WAKE_TASK_ID, task_type: "local_bash", description: "Audit" }],
10112
+ uuid: "background-command-snapshot",
10113
+ session_id: WAKE_NATIVE_SESSION,
10114
+ }),
10115
+ );
10116
+ assert.deepInclude(
10117
+ providerThreadRosterEvents(harness.events).at(-1)?.providerThread
10118
+ .pendingBackgroundTasks?.[0],
10119
+ details,
10120
+ );
10121
+
10122
yield* Queue.offer(
10123
harness.sdkMessages,
10124
claudeSdkFrame({
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+27
-5
@@ -5777,7 +5777,12 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
5777
} else {
5778
updated.set(
5779
nativeThreadId,
5780
- new Map(tasks.map((task) => [task.taskId, task] as const)),
5780
+ new Map(
5781
+ tasks.map((task) => {
5782
+ const previous = current.get(nativeThreadId)?.get(task.taskId);
5783
+ return [task.taskId, { ...previous, ...task }] as const;
5784
+ }),
5785
+ ),
5786
);
5787
}
5788
return updated;
@@ -8719,9 +8724,26 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
8724
if (!isClaudeNonSubagentTask(message) || message.is_backgrounded === false) {
8725
return false;
8726
}
8722
- yield* upsertPendingBackgroundTask(
8723
- input.nativeThreadId,
8724
- claudePendingBackgroundTask({
8727
+ const launch =
8728
+ message.tool_use_id === undefined || input.activeContext === null
8729
+ ? undefined
8730
+ : findToolCall(input.activeContext, message.tool_use_id);
8731
+ const command =
8732
+ launch?.classification.itemType === "command_execution"
8733
+ ? firstStringInputField(launch.input, ["command"])
8734
+ : undefined;
8735
+ yield* upsertPendingBackgroundTask(input.nativeThreadId, {
8736
+ ...(launch === undefined || command === undefined
8737
+ ? {}
8738
+ : {
8739
+ itemId: idAllocator.derive.turnItemFromProviderItem({
8740
+ driver: CLAUDE_PROVIDER,
8741
+ nativeItemId: launch.nativeItemId,
8742
+ }),
8743
+ sourceThreadId: launch.threadId,
8744
+ }),
8745
+ ...(command === undefined ? {} : { command }),
8746
+ ...claudePendingBackgroundTask({
8747
taskId: message.task_id,
8748
taskType: claudeTaskTypeFromSdkMessage(message),
8749
startedByMonitor: yield* isClaudeMonitorTask({
@@ -8733,7 +8755,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
8755
typeof message.description === "string" ? message.description : undefined,
8756
parentTaskId: Reflect.get(message, "parent_task_id"),
8757
}),
8736
- );
8758
+ });
8759
rosterChanged = true;
8760
} else if (message.type === "system" && message.subtype === "task_notification") {
8761
yield* endClaudeMonitorTasks((taskId) => taskId === message.task_id);
apps/web/src/components/chat/BackgroundWorkDetails.browser.test.tsx
new
+97
@@ -0,0 +1,97 @@
1
+import "~/index.css";
2
+import { EnvironmentId, ProviderDriverKind, ThreadId, TurnItemId } from "@t3tools/contracts";
3
+import * as DateTime from "effect/DateTime";
4
+import { expect, it, vi } from "vite-plus/test";
5
+import { page } from "vite-plus/test/browser";
6
+vi.mock(import("./CommandOutputPanel"), () => ({
7
+ useCommandOutputStreaming: () => true,
8
+ CommandOutputPanel: () => <div>Command output stream</div>,
9
+}));
10
+
11
+import { render } from "../../../test/render";
12
+import { backgroundWorkNowItem } from "./ThreadActivityBanners";
13
+import { ThreadNow } from "./ThreadNow";
14
+
15
+it("opens full command details for short labels and keeps pending tasks current", async () => {
16
+ const command = "python3 audit.py -j 6\n> scratch/audit.log 2>&1";
17
+ const commandItem = (status: "running" | "completed") => ({
18
+ id: TurnItemId.make("bash-1"),
19
+ threadId: ThreadId.make("thread"),
20
+ runId: null,
21
+ nodeId: null,
22
+ providerThreadId: null,
23
+ providerTurnId: null,
24
+ nativeItemRef: null,
25
+ parentItemId: null,
26
+ ordinal: 1,
27
+ status,
28
+ title: null,
29
+ startedAt: null,
30
+ completedAt: null,
31
+ updatedAt: DateTime.makeUnsafe("2026-11-09T00:00:00Z"),
32
+ type: "command_execution" as const,
33
+ input: command,
34
+ output: "Command running in background with ID: native-task",
35
+ });
36
+ const view = (
37
+ description?: string,
38
+ status: "running" | "completed" = "completed",
39
+ explicitItem = true,
40
+ ) => (
41
+ <ThreadNow
42
+ attention={null}
43
+ syncPhase={null}
44
+ goal={null}
45
+ work={backgroundWorkNowItem({
46
+ environmentId: EnvironmentId.make("test"),
47
+ threadId: ThreadId.make("thread"),
48
+ tasks: [
49
+ {
50
+ taskId: "native-task",
51
+ itemId: explicitItem ? TurnItemId.make("bash-1") : undefined,
52
+ kind: "command",
53
+ description,
54
+ command,
55
+ awaited: true,
56
+ },
57
+ ],
58
+ turnItems: [
59
+ commandItem(status),
60
+ {
61
+ ...commandItem("running"),
62
+ id: TurnItemId.make("native-match"),
63
+ nativeItemRef: {
64
+ driver: ProviderDriverKind.make("codex"),
65
+ nativeId: "native-task",
66
+ strength: "strong",
67
+ },
68
+ ordinal: 2,
69
+ },
70
+ ],
71
+ stopDisabled: false,
72
+ stopping: false,
73
+ onStop: async () => undefined,
74
+ onOpenThread: () => undefined,
75
+ })}
76
+ />
77
+ );
78
+ await using screen = await render(view("Audit"));
79
+ await screen.getByRole("button", { name: "Details", exact: true }).click();
80
+ await vi.waitFor(() => expect(page.getByRole("dialog").element().textContent).toContain(command));
81
+ await expect.element(page.getByText("Command output stream")).not.toBeInTheDocument();
82
+
83
+ await screen.rerender(view(command));
84
+ await expect.element(page.getByRole("heading", { name: "Command", exact: true })).toBeVisible();
85
+ await screen.rerender(view());
86
+ await expect.element(page.getByRole("heading", { name: "Command", exact: true })).toBeVisible();
87
+
88
+ await screen.rerender(view("Check remaining modules", "running"));
89
+ await expect
90
+ .element(page.getByRole("heading", { name: "Check remaining modules" }))
91
+ .toBeVisible();
92
+ await expect.element(page.getByText("Command output stream")).toBeVisible();
93
+ await screen.rerender(view("Native fallback", "completed", false));
94
+ await expect.element(page.getByText("Command output stream")).toBeVisible();
95
+ await page.getByRole("button", { name: "Close", exact: true }).click();
96
+ await expect.element(page.getByRole("dialog")).not.toBeInTheDocument();
97
+});
apps/web/src/components/chat/BackgroundWorkDetails.tsx
new
+97
@@ -0,0 +1,97 @@
1
+import type {
2
+ EnvironmentId,
3
+ OrchestrationV2PendingBackgroundTask,
4
+ ThreadId,
5
+} from "@t3tools/contracts";
6
+import type { ThreadStructure } from "@t3tools/client-runtime/state/shell";
7
+import { useState } from "react";
8
+
9
+import { InlineButton } from "../ui/button";
10
+import {
11
+ Dialog,
12
+ DialogHeader,
13
+ DialogPanel,
14
+ DialogPopup,
15
+ DialogTitle,
16
+ DialogTrigger,
17
+} from "../ui/dialog";
18
+import { CommandOutputPanel, useCommandOutputStreaming } from "./CommandOutputPanel";
19
+import { ShellCommandBlock } from "./ShellCommandBlock";
20
+
21
+export function BackgroundWorkDetails(props: {
22
+ readonly environmentId: EnvironmentId;
23
+ readonly threadId: ThreadId;
24
+ readonly tasks: ReadonlyArray<OrchestrationV2PendingBackgroundTask>;
25
+ readonly turnItems: ThreadStructure["turnItems"];
26
+ readonly onOpenThread: (threadId: ThreadId) => void;
27
+}) {
28
+ const [open, setOpen] = useState(false);
29
+ const streamsOutput = useCommandOutputStreaming(props.environmentId);
30
+ return (
31
+ <Dialog open={open} onOpenChange={setOpen}>
32
+ <DialogTrigger render={<InlineButton />}>Details</DialogTrigger>
33
+ <DialogPopup>
34
+ <DialogHeader>
35
+ <DialogTitle>Background work</DialogTitle>
36
+ </DialogHeader>
37
+ <DialogPanel>
38
+ <div className="space-y-5">
39
+ {props.tasks.map((task) => {
40
+ const item = props.turnItems.findLast((candidate) =>
41
+ task.itemId === undefined
42
+ ? (candidate.nativeItemRef?.nativeId || candidate.id) === task.taskId
43
+ : candidate.id === task.itemId,
44
+ );
45
+ const command =
46
+ task.command ?? (item?.type === "command_execution" ? item.input : undefined);
47
+ const description = task.description?.trim();
48
+ const title =
49
+ description && description !== command?.trim()
50
+ ? description
51
+ : command
52
+ ? "Command"
53
+ : task.kind.replaceAll("_", " ");
54
+ const itemId =
55
+ task.itemId ?? (item?.type === "command_execution" ? item.id : undefined);
56
+ const childThreadId = task.kind === "subagent" ? task.childThreadId : undefined;
57
+ return (
58
+ <section key={task.taskId} className="space-y-2 text-sm">
59
+ <div className="flex items-baseline justify-between gap-3">
60
+ <h3 className="font-medium">{title}</h3>
61
+ <span className="shrink-0 text-xs text-muted-foreground">
62
+ {task.awaited ? "Waiting" : "Running"}
63
+ </span>
64
+ </div>
65
+ {command ? (
66
+ <div className="rounded-md border border-border bg-muted/20 p-3 font-mono text-xs whitespace-pre-wrap break-words">
67
+ <ShellCommandBlock command={command} />
68
+ </div>
69
+ ) : null}
70
+ {itemId && streamsOutput && item?.status === "running" ? (
71
+ <div className="font-mono text-xs whitespace-pre-wrap break-words">
72
+ <CommandOutputPanel
73
+ environmentId={props.environmentId}
74
+ threadId={task.sourceThreadId ?? item?.threadId ?? props.threadId}
75
+ itemId={itemId}
76
+ />
77
+ </div>
78
+ ) : null}
79
+ {childThreadId ? (
80
+ <InlineButton
81
+ onClick={() => {
82
+ setOpen(false);
83
+ props.onOpenThread(childThreadId);
84
+ }}
85
+ >
86
+ Open thread
87
+ </InlineButton>
88
+ ) : null}
89
+ </section>
90
+ );
91
+ })}
92
+ </div>
93
+ </DialogPanel>
94
+ </DialogPopup>
95
+ </Dialog>
96
+ );
97
+}
apps/web/src/components/chat/ThreadActivityBanners.tsx
+9
@@ -27,6 +27,7 @@ import {
27
} from "lucide-react";
28
import { Fragment } from "react";
29
import { tickTextContent } from "~/lib/tickTextContent";
30
+import { BackgroundWorkDetails } from "./BackgroundWorkDetails";
31
import { Button, InlineButton } from "../ui/button";
32
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
33
import type { ComposerBannerStackItem } from "./ComposerBannerStack";
@@ -168,6 +169,7 @@ export function runStopNowItem(input: {
169
170
/** Background commands and subagents, for the end of the timeline. */
171
export function backgroundWorkNowItem(input: {
172
+ readonly environmentId: EnvironmentId;
173
readonly threadId: ThreadId;
174
readonly tasks: ReadonlyArray<OrchestrationV2PendingBackgroundTask>;
175
readonly turnItems: ThreadStructure["turnItems"];
@@ -246,6 +248,13 @@ export function backgroundWorkNowItem(input: {
248
className="tabular-nums"
249
/>
250
)}
251
+ <BackgroundWorkDetails
252
+ environmentId={input.environmentId}
253
+ threadId={input.threadId}
254
+ tasks={input.tasks}
255
+ turnItems={input.turnItems}
256
+ onOpenThread={onOpenThread}
257
+ />
258
{onlyThreadId === undefined ? null : (
259
<InlineButton tone="muted" onClick={() => onOpenThread(onlyThreadId)}>
260
Open
apps/web/src/components/chat/useThreadLifecycle.tsx
+1
@@ -596,6 +596,7 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
596
: null;
597
const backgroundWorkNow = activeThread
598
? backgroundWorkNowItem({
599
+ environmentId,
600
threadId: activeThread.id,
601
tasks: activeBackgroundTasks,
602
turnItems,
packages/contracts/src/orchestrationV2.ts
+3
@@ -1023,6 +1023,9 @@ function kindUnionWithFallback<
1023
}
1024
1025
const PendingBackgroundTaskFields = {
1026
+ command: Schema.optional(Schema.String),
1027
+ itemId: Schema.optional(TurnItemId),
1028
+ sourceThreadId: Schema.optional(ThreadId),
1029
taskId: TrimmedNonEmptyString,
1030
description: Schema.optional(TrimmedNonEmptyString),
1031
/** The subagent task that started this work and waits on it. */