@devries-cameron20 / t3code-1 / commits / bd7aab2c95
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

refactor(web): ChatView's subagent, goal, background-work and branch banners are built in ThreadActivityBanners (#22725)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 21, 2026 at 01:36 UTC bd7aab2c95ef13fe93956cea8d88ca1cfbaf9172
2 files changed +245 -176
apps/web/src/components/ChatView.tsx
+44 -176
@@ -82,7 +82,6 @@ import { isPasteAsTextShortcut } from "@t3tools/client-runtime/text-paste";
82 import { effectiveSnoozed, threadWokeAt } from "@t3tools/client-runtime/state/thread-settled";
83 import { declinePendingApprovals } from "@t3tools/client-runtime/state/thread-requests";
84 import { presentThreadShell } from "@t3tools/client-runtime/state/shell";
85 -import { childThreadInputsTitle } from "@t3tools/client-runtime/state/threads";
85 import { useAcknowledgeThreadWoke, useThreadActions } from "../hooks/useThreadActions";
86 import {
87 deriveProviderSubagentStatus,
@@ -92,8 +91,6 @@ import {
91 deriveThreadActivityRun,
92 deriveLatestThreadRun,
93 deriveThreadRuntime,
95 - presentPendingBackgroundWork,
96 - presentProviderGoal,
94 } from "@t3tools/client-runtime/state/thread-execution";
95 import {
96 resolveWorkflowOpening,
@@ -137,7 +134,7 @@ import { truncate } from "@t3tools/shared/String";
134 import { resolveThreadReferenceCopyTarget } from "@t3tools/shared/threadReference";
135 import { resolveTerminalSessionLabel } from "@t3tools/shared/terminalLabels";
136 import { useAtomValue } from "@effect/atom-react";
140 -import { Fragment, type SetStateAction, useEffect, useLayoutEffect, useRef, useState } from "react";
137 +import { type SetStateAction, useEffect, useLayoutEffect, useRef, useState } from "react";
138 import { flushSync } from "react-dom";
139 import { useLocation, useNavigate, useRouter } from "@tanstack/react-router";
140 import { assistantCitationFromLocation } from "../lib/assistantCitationNavigation";
@@ -234,13 +231,9 @@ import { shortcutLabelForCommand } from "../keybindings";
231 import {
232 AlarmClockIcon,
233 CheckCircle2Icon,
237 - MessageCircleIcon,
234 PaperclipIcon,
235 ChevronDownIcon,
236 DownloadIcon,
241 - GitBranchIcon,
242 - ShieldQuestionIcon,
243 - TargetIcon,
237 } from "lucide-react";
238 import { cn } from "~/lib/utils";
239 import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar";
@@ -483,8 +476,7 @@ import { readEnvironmentScope, readPreparedConnection } from "../state/session";
476 import { useAtomCommand } from "../state/use-atom-command";
477 import { useOrchestrationCommand } from "../state/use-orchestration-command";
478 import { useAtomQueryRunner } from "../state/use-atom-query-runner";
486 -import { Button, InlineButton } from "./ui/button";
487 -import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
479 +import { Button } from "./ui/button";
480 import { useAssetUrls } from "../assets/assetUrls";
481 import {
482 ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
@@ -494,6 +486,12 @@ import { observeResize } from "~/lib/observeResize";
486 import { ThreadVisitWatermark } from "./chat/ThreadVisitWatermark";
487 import { ChatTerminalDrawers } from "./chat/ChatTerminalDrawers";
488 import { ChatRightPanel } from "./chat/ChatRightPanel";
489 +import {
490 + backgroundWorkBannerItem,
491 + branchMismatchBannerItem,
492 + childInputBannerItem,
493 + goalBannerItem,
494 +} from "./chat/ThreadActivityBanners";
495 import { useTimelineFollow } from "./chat/useTimelineFollow";
496 import {
497 type EnvironmentUnavailableState,
@@ -4019,35 +4017,13 @@ export default function ChatView(props: ChatViewProps) {
4017 };
4018 const onOpenRelatedThreadStable = useStableCallback(onOpenRelatedThread);
4019 const childThreadInputs = useChildThreadInputs(activeThreadRef);
4022 - const childInputBannerItem = (() => {
4023 - const first = childThreadInputs[0];
4024 - const parentAwaitingUser =
4025 - activePendingApproval || activePendingUserInput || activeThreadShell?.hasPendingUserInput;
4026 - if (!first || parentAwaitingUser) return null;
4027 - return {
4028 - id: `child-input:${first.id}`,
4029 - variant: "info",
4030 - priority: "activity",
4031 - icon: first.hasPendingApprovals ? <ShieldQuestionIcon /> : <MessageCircleIcon />,
4032 - title: childThreadInputsTitle(childThreadInputs),
4033 - description: childThreadInputs.map((child, index) => (
4034 - <Fragment key={child.id}>
4035 - {index > 0 ? " " : null}
4036 - <span className="whitespace-nowrap">
4037 - <InlineButton tone="muted" onClick={() => onOpenRelatedThreadStable(child.id)}>
4038 - {child.title}
4039 - </InlineButton>
4040 - {index < childThreadInputs.length - 1 ? "," : null}
4041 - </span>
4042 - </Fragment>
4043 - )),
4044 - actions: (
4045 - <Button size="xs" variant="ghost" onClick={() => onOpenRelatedThreadStable(first.id)}>
4046 - {first.hasPendingApprovals ? "Open approval" : "Open question"}
4047 - </Button>
4048 - ),
4049 - };
4050 - })() as ComposerBannerStackItem | null;
4020 + const childInputBanner = childInputBannerItem({
4021 + childThreadInputs,
4022 + parentAwaitingUser: Boolean(
4023 + activePendingApproval || activePendingUserInput || activeThreadShell?.hasPendingUserInput,
4024 + ),
4025 + onOpenThread: onOpenRelatedThreadStable,
4026 + });
4027
4028 const sendStandaloneCommand = async (text: string, failureMessage: string) => {
4029 if (!activeThread || !clientSettingsHydrated || sendInFlightRef.current) return;
@@ -4111,104 +4087,26 @@ export default function ChatView(props: ChatViewProps) {
4087 };
4088 const sendStandaloneCommandStable = useStableCallback(sendStandaloneCommand);
4089 const activeGoal = activeThreadShell?.goal ?? null;
4114 - const goalBannerItem = (() => {
4115 - if (!activeThread || activeGoal === null) return null;
4116 - const presentation = presentProviderGoal(activeGoal, isWorking);
4117 - return {
4118 - id: `goal:${activeThread.id}`,
4119 - variant: "default",
4120 - priority: "activity",
4121 - icon: <TargetIcon />,
4122 - title:
4123 - presentation.usage === null
4124 - ? presentation.title
4125 - : `${presentation.title} · ${presentation.usage}`,
4126 - description: presentation.objective,
4127 - actions: isWorking ? undefined : (
4128 - <>
4129 - {presentation.canResume ? (
4130 - <Button
4131 - size="xs"
4132 - variant="ghost"
4133 - onClick={() =>
4134 - void sendStandaloneCommandStable("/goal resume", "Failed to resume goal.")
4135 - }
4136 - >
4137 - Resume
4138 - </Button>
4139 - ) : null}
4140 - <Button
4141 - size="xs"
4142 - variant="ghost"
4143 - onClick={() => void sendStandaloneCommandStable("/goal clear", "Failed to clear goal.")}
4144 - >
4145 - Clear
4146 - </Button>
4147 - </>
4148 - ),
4149 - };
4150 - })() as ComposerBannerStackItem | null;
4090 + const goalBanner =
4091 + activeThread && activeGoal !== null
4092 + ? goalBannerItem({
4093 + threadId: activeThread.id,
4094 + goal: activeGoal,
4095 + isWorking,
4096 + onSendCommand: sendStandaloneCommandStable,
4097 + })
4098 + : null;
4099
4152 - const backgroundWorkBannerItem = (() => {
4153 - const presentation = presentPendingBackgroundWork(activeBackgroundTasks);
4154 - if (presentation === null || !activeThread) {
4155 - return null;
4156 - }
4157 - return {
4158 - id: `background-work:${activeThread.id}`,
4159 - variant: "default",
4160 - priority: "activity",
4161 - icon: (
4162 - <span
4163 - className={cn(
4164 - "size-1.5 rounded-full bg-foreground",
4165 - presentation.waiting && "motion-safe:animate-status-pulse",
4166 - )}
4167 - aria-hidden="true"
4168 - />
4169 - ),
4170 - title: presentation.title,
4171 - description:
4172 - presentation.items.length === 1 && presentation.items[0]?.childThreadId === undefined
4173 - ? undefined
4174 - : presentation.items.map((item, index) => {
4175 - const childThreadId = item.childThreadId;
4176 - const separator = index < presentation.items.length - 1 ? "," : null;
4177 - return (
4178 - <Fragment key={item.taskId}>
4179 - {index > 0 ? " " : null}
4180 - {childThreadId === undefined ? (
4181 - <>
4182 - {item.label}
4183 - {separator}
4184 - </>
4185 - ) : (
4186 - <span className="whitespace-nowrap">
4187 - <InlineButton
4188 - tone="muted"
4189 - aria-label={`${presentation.items.length === 1 ? "Show" : "Open"} subagent ${item.label}`}
4190 - onClick={() => onOpenRelatedThreadStable(childThreadId)}
4191 - >
4192 - {presentation.items.length === 1 ? "Show" : item.label}
4193 - </InlineButton>
4194 - {separator}
4195 - </span>
4196 - )}
4197 - </Fragment>
4198 - );
4199 - }),
4200 - actions: (
4201 - <Button
4202 - size="xs"
4203 - variant="ghost"
4204 - disabled={!canOperateThread || isStoppingBackgroundWork}
4205 - onClick={() => void handleStopBackgroundWorkStable()}
4206 - >
4207 - {isStoppingBackgroundWork ? "Stopping..." : "Stop"}
4208 - </Button>
4209 - ),
4210 - };
4211 - })() as ComposerBannerStackItem | null;
4100 + const backgroundWorkBanner = activeThread
4101 + ? backgroundWorkBannerItem({
4102 + threadId: activeThread.id,
4103 + tasks: activeBackgroundTasks,
4104 + stopDisabled: !canOperateThread || isStoppingBackgroundWork,
4105 + stopping: isStoppingBackgroundWork,
4106 + onStop: handleStopBackgroundWorkStable,
4107 + onOpenThread: onOpenRelatedThreadStable,
4108 + })
4109 + : null;
4110 // The relative times read the clock; nowMinute re-renders them on the minute.
4111 const snoozedUntil = activeThreadShell?.snoozedUntil ?? null;
4112 const settledAt = activeThreadShell?.settledAt ?? null;
@@ -4353,11 +4251,9 @@ export default function ChatView(props: ChatViewProps) {
4251 : null;
4252 const composerBannerItems = (() => {
4253 const limitRecoveryItems = limitRecoveryBanner === null ? [] : [limitRecoveryBanner];
4356 - const backgroundWorkItems = [
4357 - childInputBannerItem,
4358 - goalBannerItem,
4359 - backgroundWorkBannerItem,
4360 - ].filter((item) => item !== null);
4254 + const backgroundWorkItems = [childInputBanner, goalBanner, backgroundWorkBanner].filter(
4255 + (item) => item !== null,
4256 + );
4257 const usageLimitsItems = usageLimitsBanner === null ? [] : [usageLimitsBanner];
4258 const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem];
4259 if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) {
@@ -4377,45 +4273,17 @@ export default function ChatView(props: ChatViewProps) {
4273 ...projectCloneItems,
4274 ...systemComposerBannerItems,
4275 ...backgroundWorkItems,
4380 - {
4381 - id: `branch-mismatch:${activeBranchMismatchKey}`,
4382 - variant: "info",
4383 - compact: true,
4384 - icon: <GitBranchIcon />,
4385 - title: (
4386 - <span className="flex min-w-0 items-baseline gap-1.5">
4387 - <span className="shrink-0 font-normal text-muted-foreground">Branch changed — was</span>
4388 - <Tooltip>
4389 - <TooltipTrigger
4390 - render={
4391 - <code className="min-w-0 truncate font-medium text-foreground">
4392 - {localCheckoutBranchMismatch.threadBranch}
4393 - </code>
4394 - }
4395 - />
4396 - <TooltipPopup side="top">
4397 - This thread last ran on {localCheckoutBranchMismatch.threadBranch}. Sending will
4398 - continue on {localCheckoutBranchMismatch.currentBranch}.
4399 - </TooltipPopup>
4400 - </Tooltip>
4401 - </span>
4402 - ),
4403 - actions: (
4404 - <Button
4405 - size="xs"
4406 - variant="ghost"
4407 - disabled={!canWriteSourceControl || isRestoringThreadBranch}
4408 - onClick={handleRestoreThreadBranchStable}
4409 - >
4410 - {isRestoringThreadBranch ? "Restoring..." : "Restore branch"}
4411 - </Button>
4412 - ),
4413 - dismissLabel: "Dismiss branch change notice",
4276 + branchMismatchBannerItem({
4277 + mismatchKey: activeBranchMismatchKey,
4278 + mismatch: localCheckoutBranchMismatch,
4279 + restoreDisabled: !canWriteSourceControl || isRestoringThreadBranch,
4280 + restoring: isRestoringThreadBranch,
4281 + onRestore: handleRestoreThreadBranchStable,
4282 onDismiss: () => {
4283 dismissBranchMismatchForSession(activeBranchMismatchKey);
4284 setBranchMismatchDismissTick((tick) => tick + 1);
4285 },
4418 - },
4286 + }),
4287 ];
4288 })() as ComposerBannerStackItem[];
4289
apps/web/src/components/chat/ThreadActivityBanners.tsx new
+201
@@ -0,0 +1,201 @@
1 +import type {
2 + OrchestrationV2PendingBackgroundTask,
3 + OrchestrationV2ProviderGoal,
4 + ThreadId,
5 +} from "@t3tools/contracts";
6 +import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
7 +import {
8 + presentPendingBackgroundWork,
9 + presentProviderGoal,
10 +} from "@t3tools/client-runtime/state/thread-execution";
11 +import { childThreadInputsTitle } from "@t3tools/client-runtime/state/threads";
12 +import { GitBranchIcon, MessageCircleIcon, ShieldQuestionIcon, TargetIcon } from "lucide-react";
13 +import { Fragment } from "react";
14 +import { cn } from "~/lib/utils";
15 +import { Button, InlineButton } from "../ui/button";
16 +import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
17 +import type { ComposerBannerStackItem } from "./ComposerBannerStack";
18 +
19 +/** Subagents waiting on the user, unless the parent is itself waiting on them. */
20 +export function childInputBannerItem(input: {
21 + readonly childThreadInputs: ReadonlyArray<EnvironmentThreadShell>;
22 + readonly parentAwaitingUser: boolean;
23 + readonly onOpenThread: (threadId: ThreadId) => void;
24 +}): ComposerBannerStackItem | null {
25 + const { childThreadInputs, onOpenThread } = input;
26 + const first = childThreadInputs[0];
27 + if (!first || input.parentAwaitingUser) return null;
28 + return {
29 + id: `child-input:${first.id}`,
30 + variant: "info",
31 + priority: "activity",
32 + icon: first.hasPendingApprovals ? <ShieldQuestionIcon /> : <MessageCircleIcon />,
33 + title: childThreadInputsTitle(childThreadInputs),
34 + description: childThreadInputs.map((child, index) => (
35 + <Fragment key={child.id}>
36 + {index > 0 ? " " : null}
37 + <span className="whitespace-nowrap">
38 + <InlineButton tone="muted" onClick={() => onOpenThread(child.id)}>
39 + {child.title}
40 + </InlineButton>
41 + {index < childThreadInputs.length - 1 ? "," : null}
42 + </span>
43 + </Fragment>
44 + )),
45 + actions: (
46 + <Button size="xs" variant="ghost" onClick={() => onOpenThread(first.id)}>
47 + {first.hasPendingApprovals ? "Open approval" : "Open question"}
48 + </Button>
49 + ),
50 + };
51 +}
52 +
53 +export function goalBannerItem(input: {
54 + readonly threadId: ThreadId;
55 + readonly goal: OrchestrationV2ProviderGoal;
56 + readonly isWorking: boolean;
57 + readonly onSendCommand: (text: string, failureMessage: string) => Promise<void>;
58 +}): ComposerBannerStackItem {
59 + const { isWorking, onSendCommand } = input;
60 + const presentation = presentProviderGoal(input.goal, isWorking);
61 + return {
62 + id: `goal:${input.threadId}`,
63 + variant: "default",
64 + priority: "activity",
65 + icon: <TargetIcon />,
66 + title:
67 + presentation.usage === null
68 + ? presentation.title
69 + : `${presentation.title} · ${presentation.usage}`,
70 + description: presentation.objective,
71 + actions: isWorking ? undefined : (
72 + <>
73 + {presentation.canResume ? (
74 + <Button
75 + size="xs"
76 + variant="ghost"
77 + onClick={() => void onSendCommand("/goal resume", "Failed to resume goal.")}
78 + >
79 + Resume
80 + </Button>
81 + ) : null}
82 + <Button
83 + size="xs"
84 + variant="ghost"
85 + onClick={() => void onSendCommand("/goal clear", "Failed to clear goal.")}
86 + >
87 + Clear
88 + </Button>
89 + </>
90 + ),
91 + };
92 +}
93 +
94 +export function backgroundWorkBannerItem(input: {
95 + readonly threadId: ThreadId;
96 + readonly tasks: ReadonlyArray<OrchestrationV2PendingBackgroundTask>;
97 + readonly stopDisabled: boolean;
98 + readonly stopping: boolean;
99 + readonly onStop: () => Promise<void>;
100 + readonly onOpenThread: (threadId: ThreadId) => void;
101 +}): ComposerBannerStackItem | null {
102 + const { onOpenThread } = input;
103 + const presentation = presentPendingBackgroundWork(input.tasks);
104 + if (presentation === null) return null;
105 + return {
106 + id: `background-work:${input.threadId}`,
107 + variant: "default",
108 + priority: "activity",
109 + icon: (
110 + <span
111 + className={cn(
112 + "size-1.5 rounded-full bg-foreground",
113 + presentation.waiting && "motion-safe:animate-status-pulse",
114 + )}
115 + aria-hidden="true"
116 + />
117 + ),
118 + title: presentation.title,
119 + description:
120 + presentation.items.length === 1 && presentation.items[0]?.childThreadId === undefined
121 + ? undefined
122 + : presentation.items.map((item, index) => {
123 + const childThreadId = item.childThreadId;
124 + const separator = index < presentation.items.length - 1 ? "," : null;
125 + return (
126 + <Fragment key={item.taskId}>
127 + {index > 0 ? " " : null}
128 + {childThreadId === undefined ? (
129 + <>
130 + {item.label}
131 + {separator}
132 + </>
133 + ) : (
134 + <span className="whitespace-nowrap">
135 + <InlineButton
136 + tone="muted"
137 + aria-label={`${presentation.items.length === 1 ? "Show" : "Open"} subagent ${item.label}`}
138 + onClick={() => onOpenThread(childThreadId)}
139 + >
140 + {presentation.items.length === 1 ? "Show" : item.label}
141 + </InlineButton>
142 + {separator}
143 + </span>
144 + )}
145 + </Fragment>
146 + );
147 + }),
148 + actions: (
149 + <Button
150 + size="xs"
151 + variant="ghost"
152 + disabled={input.stopDisabled}
153 + onClick={() => void input.onStop()}
154 + >
155 + {input.stopping ? "Stopping..." : "Stop"}
156 + </Button>
157 + ),
158 + };
159 +}
160 +
161 +/** The local checkout moved off the branch this thread last ran on. */
162 +export function branchMismatchBannerItem(input: {
163 + readonly mismatchKey: string;
164 + readonly mismatch: { readonly threadBranch: string; readonly currentBranch: string };
165 + readonly restoreDisabled: boolean;
166 + readonly restoring: boolean;
167 + readonly onRestore: () => void;
168 + readonly onDismiss: () => void;
169 +}): ComposerBannerStackItem {
170 + const { mismatch } = input;
171 + return {
172 + id: `branch-mismatch:${input.mismatchKey}`,
173 + variant: "info",
174 + icon: <GitBranchIcon />,
175 + title: (
176 + <span className="flex min-w-0 items-baseline gap-1.5">
177 + <span className="shrink-0 font-normal text-muted-foreground">Branch changed — was</span>
178 + <Tooltip>
179 + <TooltipTrigger
180 + render={
181 + <code className="min-w-0 truncate font-medium text-foreground">
182 + {mismatch.threadBranch}
183 + </code>
184 + }
185 + />
186 + <TooltipPopup side="top">
187 + This thread last ran on {mismatch.threadBranch}. Sending will continue on{" "}
188 + {mismatch.currentBranch}.
189 + </TooltipPopup>
190 + </Tooltip>
191 + </span>
192 + ),
193 + actions: (
194 + <Button size="xs" variant="ghost" disabled={input.restoreDisabled} onClick={input.onRestore}>
195 + {input.restoring ? "Restoring..." : "Restore branch"}
196 + </Button>
197 + ),
198 + dismissLabel: "Dismiss branch change notice",
199 + onDismiss: input.onDismiss,
200 + };
201 +}