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

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

feat(web): thread state lives at the end of the timeline, not stacked on the composer (#25401)

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

Theo Browne committed Oct 26, 2026 at 17:09 UTC bd3287b640a717513a44b1d23e362aed446a263f
34 files changed +712 -1518
apps/web/src/components/ChatView.tsx
+77 -79
@@ -86,7 +86,10 @@ import {
86 resolveWorkflowOpening,
87 workflowOpeningParentThreadId,
88 } from "@t3tools/client-runtime/state/subagentRuntime";
89 -import { threadSupportsProviderHandoff } from "@t3tools/client-runtime/state/thread-workflows";
89 +import {
90 + getUserQueuedThreadRuns,
91 + threadSupportsProviderHandoff,
92 +} from "@t3tools/client-runtime/state/thread-workflows";
93 import { resolvePendingHandoff } from "@t3tools/client-runtime/handoff";
94 import { HandoffRow } from "./chat/V2LifecycleRow";
95 import {
@@ -126,8 +129,6 @@ import { useActiveThreadRef } from "../hooks/useActiveThreadRef";
129 import { composerRequiresModifier } from "../composer-logic";
130 import {
131 derivePhase,
129 - deriveActivePlanState,
130 - selectComposerTasksPlan,
132 deriveActiveWorkStartedAt,
133 deriveCanInterruptRunningThread,
134 findLatestProposedPlan,
@@ -352,6 +353,8 @@ import { ChatTerminalDrawers } from "./chat/ChatTerminalDrawers";
353 import { ChatRightPanel } from "./chat/ChatRightPanel";
354 import { useDraftEnvironmentRouting } from "./chat/useDraftEnvironmentRouting";
355 import { branchMismatchBannerItem } from "./chat/ThreadActivityBanners";
356 +import { ThreadNow } from "./chat/ThreadNow";
357 +import { useDelayedStatus } from "../hooks/useDelayedStatus";
358 import { useTimelineFollow } from "./chat/useTimelineFollow";
359 import {
360 type EnvironmentUnavailableState,
@@ -512,6 +515,8 @@ export default function ChatView(props: ChatViewProps) {
515 status: threadStatus,
516 });
517 const threadDetailLoading = threadSyncPhase === "loading";
518 + // Held back briefly, so a quick sync does not flash a status line at the end of the timeline.
519 + const delayedThreadSyncPhase = useDelayedStatus(routeThreadKey, threadSyncPhase);
520 const activeProviderThread = serverProjection?.providerThreads.find(
521 (thread) => thread.id === serverProjection.thread.activeProviderThreadId,
522 );
@@ -989,30 +994,6 @@ export default function ChatView(props: ChatViewProps) {
994 );
995
996 const latestRunSettled = isLatestRunSettled(activeLatestRun, activeRuntime);
992 - const activePlan = deriveActivePlanState(serverProjection, activeActivityRun?.runId);
993 - const activeActivityRunSettled = isLatestRunSettled(activeActivityRun, activeRuntime);
994 - const composerTasksPlan = selectComposerTasksPlan(
995 - serverProjection,
996 - activePlan,
997 - activeActivityRun?.runId ?? null,
998 - activeActivityRunSettled,
999 - );
1000 - const activeComposerTasksProgress = (() => {
1001 - if (!composerTasksPlan) return null;
1002 - const live = !activeActivityRunSettled && composerTasksPlan.runId === activeActivityRun?.runId;
1003 - const totalSteps = composerTasksPlan.steps.length;
1004 - if (totalSteps === 0) return null;
1005 - const completedSteps = composerTasksPlan.steps.filter(
1006 - (step) => step.status === "completed",
1007 - ).length;
1008 - const step =
1009 - composerTasksPlan.steps.find((candidate) => candidate.status === "inProgress")?.step ??
1010 - composerTasksPlan.steps.find((candidate) => candidate.status === "pending")?.step ??
1011 - composerTasksPlan.steps.at(-1)!.step;
1012 - return { step, completedSteps, totalSteps, live };
1013 - })();
1014 - const activeComposerTaskSteps =
1015 - activeComposerTasksProgress && composerTasksPlan ? composerTasksPlan.steps : null;
997 const activeThreadEnvironmentId = activeThread?.environmentId;
998 const activeThreadProjectId = activeThread?.projectId;
999 const activeProjectRef =
@@ -2007,6 +1988,7 @@ export default function ChatView(props: ChatViewProps) {
1988 onTimelineAnchorReadyStable,
1989 onTimelineAnchorSizeChangedStable,
1990 onToolOutputCollapsedAtEndStable,
1991 + onTimelineFooterGrowStable,
1992 onIsAtEndChangeStable,
1993 anchorNewTurn,
1994 attachTimelineViewport,
@@ -2185,22 +2167,11 @@ export default function ChatView(props: ChatViewProps) {
2167 modelStrip.offsetHeight + Number.parseFloat(getComputedStyle(modelStrip).marginTop),
2168 )
2169 : 0;
2188 - const noticeStack = composerOverlayElement?.querySelector<HTMLElement>(
2189 - '[data-composer-banner-stack="true"]',
2190 - );
2191 - const expandedNoticesHeight = noticeStack
2192 - ? Math.max(
2193 - 0,
2194 - noticeStack.getBoundingClientRect().height -
2195 - Number.parseFloat(getComputedStyle(noticeStack).minHeight),
2196 - )
2197 - : 0;
2170 const nextInset = resolveComposerTimelineInset({
2171 currentInset: composerTimelineInsetRef.current,
2172 overlayHeight: height,
2173 isResting,
2174 restingOnlyHeight,
2203 - expandedNoticesHeight,
2175 });
2176 if (composerTimelineInsetRef.current !== nextInset) {
2177 composerTimelineInsetRef.current = nextInset;
@@ -2226,9 +2197,8 @@ export default function ChatView(props: ChatViewProps) {
2197 const mainSurface = composerOverlayElement?.querySelector<HTMLElement>(
2198 '[data-chat-composer-main-surface="true"]',
2199 );
2229 - const button = composerOverlayElement?.parentElement?.querySelector<HTMLElement>(
2230 - 'button[aria-label="Scroll to end"]',
2231 - );
2200 + const button =
2201 + composerOverlayElement?.parentElement?.querySelector<HTMLElement>("[data-scroll-to-end]");
2202 const clearance =
2203 composerOverlayElement && mainSurface && button
2204 ? resolveScrollToEndClearance({
@@ -2383,9 +2353,9 @@ export default function ChatView(props: ChatViewProps) {
2353 const {
2354 acknowledgeActiveThreadWoke,
2355 activeBranchMismatchKey,
2386 - backgroundWorkBanner,
2387 - childInputBanner,
2388 - goalBanner,
2356 + backgroundWorkNow,
2357 + childInputNow,
2358 + goalNow,
2359 handleSwitchCheckoutToThread,
2360 handleSwitchCheckoutToThreadStable,
2361 isRestoringThreadBranch,
@@ -2550,9 +2520,6 @@ export default function ChatView(props: ChatViewProps) {
2520 : null;
2521 const composerBannerItems = (() => {
2522 const limitRecoveryItems = limitRecoveryBanner === null ? [] : [limitRecoveryBanner];
2553 - const backgroundWorkItems = [childInputBanner, goalBanner, backgroundWorkBanner].filter(
2554 - (item) => item !== null,
2555 - );
2523 const usageLimitsItems = usageLimitsBanner === null ? [] : [usageLimitsBanner];
2524 const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem];
2525 if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) {
@@ -2562,7 +2529,6 @@ export default function ChatView(props: ChatViewProps) {
2529 ...usageLimitsItems,
2530 ...projectCloneItems,
2531 ...systemComposerBannerItems,
2565 - ...backgroundWorkItems,
2532 ];
2533 }
2534 return [
@@ -2571,7 +2537,6 @@ export default function ChatView(props: ChatViewProps) {
2537 ...usageLimitsItems,
2538 ...projectCloneItems,
2539 ...systemComposerBannerItems,
2574 - ...backgroundWorkItems,
2540 branchMismatchBannerItem({
2541 mismatchKey: activeBranchMismatchKey,
2542 mismatch: localCheckoutBranchMismatch,
@@ -2979,6 +2944,66 @@ export default function ChatView(props: ChatViewProps) {
2944 openExpandedImagePreview(routeThreadKey, preview);
2945 };
2946 const onExpandTimelineImageStable = useStableCallback(onExpandTimelineImage);
2947 + const shownThreadSyncPhase = activeEnvironmentUnavailable ? null : delayedThreadSyncPhase;
2948 + const hasThreadNow =
2949 + childInputNow !== null ||
2950 + backgroundWorkNow !== null ||
2951 + goalNow !== null ||
2952 + shownThreadSyncPhase !== null;
2953 + const queuedRunCount = serverProjection ? getUserQueuedThreadRuns(serverProjection).length : 0;
2954 + // The queue control is mounted for every server thread but joins the footer only while it shows
2955 + // something, by its own rule: an optimistic message stops counting once the server has it.
2956 + const hasQueuedTurns =
2957 + queuedRunCount > 0 ||
2958 + optimisticUserMessages.some(
2959 + (message) =>
2960 + message.inputIntent === "queued_turn" &&
2961 + !serverProjection?.messages.some((committed) => committed.id === message.id),
2962 + );
2963 + const scrollToEndSummary =
2964 + [
2965 + childInputNow === null ? null : "Subagent waiting",
2966 + queuedRunCount === 0 ? null : `${queuedRunCount} queued`,
2967 + ]
2968 + .filter((part) => part !== null)
2969 + .join(" · ") || null;
2970 + // The end of the timeline holds the thread's present and next turns: what it is doing now,
2971 + // its lifecycle status, guest messages awaiting you, then your queued messages.
2972 + const timelineFooter =
2973 + pendingHandoff === null &&
2974 + !hasThreadNow &&
2975 + threadStatusLine === null &&
2976 + pendingGuestMessageCount === 0 &&
2977 + !hasQueuedTurns ? null : (
2978 + <>
2979 + {pendingHandoff === null ? null : (
2980 + <div className="chat-content-lane">
2981 + <HandoffRow
2982 + environmentId={environmentId}
2983 + endpoints={pendingHandoff}
2984 + providers={providerStatuses}
2985 + pending
2986 + />
2987 + </div>
2988 + )}
2989 + <ThreadNow
2990 + key={routeThreadKey}
2991 + attention={childInputNow}
2992 + work={backgroundWorkNow}
2993 + syncPhase={shownThreadSyncPhase}
2994 + goal={goalNow}
2995 + />
2996 + {threadStatusLine}
2997 + {pendingGuestMessageCount > 0 && isServerThread && activeThread ? (
2998 + <GuestPendingMessages
2999 + threadRef={scopeThreadRef(activeThread.environmentId, activeThread.id)}
3000 + onImageExpand={onExpandTimelineImageStable}
3001 + onFileOpen={openFileAttachmentStable}
3002 + />
3003 + ) : null}
3004 + {hasQueuedTurns ? queuedRunsControl : null}
3005 + </>
3006 + );
3007
3008 const pendingSidebarFileDrops = useSidebarPendingFileDropStore((state) => state.pending);
3009 const consumePendingFileDrop = useSidebarPendingFileDropStore(
@@ -3265,33 +3290,7 @@ export default function ChatView(props: ChatViewProps) {
3290 : {})}
3291 {...(onOpenWorktreeSetupTerminal ? { onOpenWorktreeSetupTerminal } : {})}
3292 isPreparingWorktree={!paintOnlyDisplayedTimeline && isPreparingWorktree}
3268 - footer={
3269 - paintOnlyDisplayedTimeline ||
3270 - (pendingHandoff === null &&
3271 - pendingGuestMessageCount === 0 &&
3272 - threadStatusLine === null) ? null : (
3273 - <>
3274 - {pendingHandoff === null ? null : (
3275 - <div className="chat-content-lane">
3276 - <HandoffRow
3277 - environmentId={environmentId}
3278 - endpoints={pendingHandoff}
3279 - providers={providerStatuses}
3280 - pending
3281 - />
3282 - </div>
3283 - )}
3284 - {pendingGuestMessageCount > 0 && isServerThread && activeThread ? (
3285 - <GuestPendingMessages
3286 - threadRef={scopeThreadRef(activeThread.environmentId, activeThread.id)}
3287 - onImageExpand={onExpandTimelineImageStable}
3288 - onFileOpen={openFileAttachmentStable}
3289 - />
3290 - ) : null}
3291 - {threadStatusLine}
3292 - </>
3293 - )
3294 - }
3293 + footer={paintOnlyDisplayedTimeline ? null : timelineFooter}
3294 listRef={legendListRef}
3295 runs={paintOnlyDisplayedTimeline ? [] : (serverProjection?.runs ?? [])}
3296 latestRun={paintOnlyDisplayedTimeline ? null : activeActivityRun}
@@ -3367,6 +3366,7 @@ export default function ChatView(props: ChatViewProps) {
3366 onContentOverflowChange={setTimelineOverflows}
3367 onToolOutputCollapsedAtEnd={onToolOutputCollapsedAtEndStable}
3368 onViewportAttach={attachTimelineViewport}
3369 + onFooterGrow={onTimelineFooterGrowStable}
3370 hideEmptyPlaceholder={isDraftHeroState || threadDetailLoading}
3371 emptyPlaceholderInset={composerReservedHeight}
3372 topFadeEnabled={!hasTimelineTopBanner}
@@ -3378,6 +3378,7 @@ export default function ChatView(props: ChatViewProps) {
3378 {showScrollToBottom && !isThreadFindActive && (
3379 <ScrollToEndButton
3380 bottom={scrollToEndClearance + 4}
3381 + summary={scrollToEndSummary}
3382 onScrollToEnd={() => {
3383 composerRef.current?.restoreAfterTimelineReachedEnd();
3384 scrollToEnd(true);
@@ -3521,7 +3522,6 @@ export default function ChatView(props: ChatViewProps) {
3522 : projectCloneSendBlockReason
3523 }
3524 isPreparingWorktree={isPreparingWorktree && !sendQueuesBehindSetup}
3524 - queuedRunsControl={queuedRunsControl}
3525 bannerItems={composerBannerItems}
3526 resumeCompactionTokens={resumeCompactionTokens}
3527 keepFullHistory={keepFullHistory}
@@ -3559,8 +3559,6 @@ export default function ChatView(props: ChatViewProps) {
3559 activeThreadModelSelection={activeThread?.modelSelection}
3560 activeProjectId={activeProject?.id ?? null}
3561 activeContextWindow={activeContextWindow}
3562 - activeTasksProgress={activeComposerTasksProgress}
3563 - activeTaskSteps={activeComposerTaskSteps}
3562 compactThreadUnavailable={compactThreadUnavailable}
3563 compactDisabled={compactDisabled}
3564 compactDisabledReason={compactDisabledReason}
apps/web/src/components/chat/ChatComposer.tsx
+11 -121
@@ -48,7 +48,6 @@ import { createModelSelection, normalizeModelSlug } from "@t3tools/shared/model"
48 import { USAGE_LIMITS_COMMAND } from "@t3tools/shared/usageLimits";
49 import {
50 memo,
51 - type ReactNode,
51 useEffect,
52 useEffectEvent,
53 useId,
@@ -105,14 +104,6 @@ import { useComposerTriggerState } from "./useComposerTriggerState";
104 import { useComposerMenuItems } from "./useComposerMenuItems";
105 import { useComposerFocusState } from "./useComposerFocusState";
106 import { useComposerMultilinePrompt } from "./useComposerMultilinePrompt";
108 -import {
109 - ComposerTasksBadge,
110 - ComposerTasksContent,
111 - ComposerTasksDrawer,
112 - type ComposerTaskStep,
113 - type ComposerTasksProgress,
114 -} from "./ComposerTasksBadge";
115 -import { ComposerActivityRow } from "./ComposerActivityStatus";
107 import {
108 reconcileAttachmentContextReferences,
109 useRetainedContextPayloads,
@@ -120,11 +111,7 @@ import {
111 import type { ThreadSyncPhase } from "../../threadSync";
112 import { ComposerBanner } from "./ComposerBanner";
113 import { ComposerSurface } from "./ComposerSurface";
123 -import {
124 - ComposerBannerStack,
125 - type ComposerBannerStackContent,
126 - type ComposerBannerStackItem,
127 -} from "./ComposerBannerStack";
114 +import { ComposerBannerStack, type ComposerBannerStackItem } from "./ComposerBannerStack";
115 import {
116 attachmentsToReleaseOnUploadCapabilityLoss,
117 composerOtherFilesForPresentation,
@@ -274,7 +261,6 @@ import {
261 resolveProviderSkillsForCwd,
262 resolveProviderSlashCommandsForCwd,
263 } from "@t3tools/client-runtime/providerSkills";
277 -import { useDelayedStatus } from "../../hooks/useDelayedStatus";
264 import { useMediaQuery } from "../../hooks/useMediaQuery";
265 import { useSoftwareKeyboardOpen } from "../../hooks/useSoftwareKeyboardOpen";
266 import { useStableCallback } from "../../hooks/useStableCallback";
@@ -435,8 +421,6 @@ export interface ChatComposerProps {
421
422 showPlanFollowUpPrompt: boolean;
423 activeProposedPlan: LatestProposedPlanState | null;
438 - activeTasksProgress: ComposerTasksProgress | null;
439 - activeTaskSteps: readonly ComposerTaskStep[] | null;
424 threadSyncPhase: ThreadSyncPhase | null;
425
426 runtimeMode: RuntimeMode;
@@ -481,7 +465,6 @@ export interface ChatComposerProps {
465 onPageScrollKeyUp: (key: string) => void;
466 onPageScrollRelease: () => void;
467
484 - queuedRunsControl?: ReactNode;
468 editingQueuedAttachments: ReadonlyArray<{
469 readonly attachment: ContractChatAttachment;
470 readonly url: string | null;
@@ -663,9 +646,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
646 const activePendingProgress = holdingUserInput ? null : incomingPendingProgress;
647 const activePendingIsResponding = !holdingUserInput && incomingPendingIsResponding;
648 const isLiteralPendingAnswer = activePendingProgress?.activeQuestion?.initialAnswer !== undefined;
666 - const shownSyncPhase = useDelayedStatus(composerDraftTargetKey, props.threadSyncPhase);
667 - const activeTasksProgress = shownSyncPhase === null ? props.activeTasksProgress : null;
668 - const activeTaskSteps = shownSyncPhase === null ? props.activeTaskSteps : null;
649 const isEditingQueuedMessage = editingQueuedAttachments !== null;
650 const composerDraft = useComposerThreadDraft(composerDraftTarget);
651 const composerDraftTargetKeyRef = useRef("");
@@ -1097,7 +1077,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
1077 const [composerMenuAnchor, setComposerMenuAnchor] = useState<HTMLDivElement | null>(null);
1078 const [hasWrappedPrompt, observeWrappedPrompt] = useComposerMultilinePrompt();
1079 const hasMultilinePrompt = prompt.includes("\n") || hasWrappedPrompt;
1100 - const [isTasksDrawerOpen, setIsTasksDrawerOpen] = useState(false);
1080 // A pending question stays expanded: its card moves into the banner dock,
1081 // so collapsing would leave the surface empty and squashed beneath it.
1082 const isComposerCollapsedMobile =
@@ -2309,28 +2288,8 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2288 importContextRecords,
2289 expandMobileComposer: expandMobileComposerStable,
2290 });
2312 - const toggleTasksDrawer = () => {
2313 - setIsTasksDrawerOpen((open) => !open);
2314 - };
2315 - const toggleTasksDrawerStable = useStableCallback(toggleTasksDrawer);
2316 - const hasBannerItems = props.bannerItems.length > 0;
2291 const hasBlockingComposerTopDrawer =
2292 activePendingApproval !== null || pendingUserInputs.length > 0;
2319 - const showInlineTasksBadge =
2320 - activeTasksProgress !== null &&
2321 - activeTaskSteps !== null &&
2322 - !isTasksDrawerOpen &&
2323 - !hasBlockingComposerTopDrawer &&
2324 - (hasBannerItems || showComposerTopDrawer || isComposerCollapsedMobile);
2325 - const inlineTasksBadge = showInlineTasksBadge ? (
2326 - <ComposerTasksBadge
2327 - expanded={false}
2328 - onToggle={toggleTasksDrawerStable}
2329 - placement="inline"
2330 - progress={activeTasksProgress}
2331 - steps={activeTaskSteps}
2332 - />
2333 - ) : null;
2293 const hasImageAttachmentAttention = standaloneComposerImages.some((image) => {
2294 const upload = uploadsByImageId[image.id];
2295 const failedInCurrentEnvironment =
@@ -2341,7 +2300,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2300 });
2301 const composerHasExpandedChrome =
2302 showComposerTopDrawer ||
2344 - isTasksDrawerOpen ||
2303 composerMenuOpen ||
2304 isStashMenuOpen ||
2305 isDragOverComposer ||
@@ -2421,8 +2379,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2379 canTrackComposerScrollGesture &&
2380 settings.composerCollapseOnScroll &&
2381 !hasMultilinePrompt &&
2424 - !composerHasExpandedChrome &&
2425 - !showInlineTasksBadge;
2382 + !composerHasExpandedChrome;
2383 const composerScrollCollapseEligible = canScrollCollapseComposer && !isComposerResting;
2384 useLayoutEffect(() => {
2385 composerScrollCollapseEligibleRef.current = composerScrollCollapseEligible;
@@ -2586,48 +2543,14 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2543 getModelDisabledReason={getModelDisabledReason}
2544 />
2545 );
2589 - const showTasksTab =
2590 - !hasBannerItems &&
2591 - !showComposerTopDrawer &&
2592 - !isTasksDrawerOpen &&
2593 - !isComposerCollapsedMobile &&
2594 - activeTasksProgress !== null &&
2595 - activeTaskSteps !== null &&
2596 - activeTasksProgress.totalSteps > 0;
2597 - const activityStackContent = hasBannerItems ? (
2598 - shownSyncPhase ? (
2599 - <ComposerActivityRow phase={shownSyncPhase} />
2600 - ) : !hasBlockingComposerTopDrawer && activeTasksProgress && activeTaskSteps ? (
2601 - <ComposerTasksContent
2602 - expanded={isTasksDrawerOpen}
2603 - onToggle={toggleTasksDrawerStable}
2604 - progress={activeTasksProgress}
2605 - steps={activeTaskSteps}
2606 - />
2607 - ) : null
2608 - ) : null;
2609 - const activityStackItem: ComposerBannerStackContent | null = activityStackContent
2610 - ? {
2611 - id: "composer-activity",
2612 - variant: "default",
2613 - priority: "activity",
2614 - content: activityStackContent,
2615 - }
2616 - : null;
2617 - const bannerStackItems = activityStackItem
2618 - ? [activityStackItem, ...props.bannerItems]
2546 + // An open approval or question owns the space above the composer. Only a machine problem,
2547 + // which is why an answer could not go through, stays beside it.
2548 + const shelfItems = hasBlockingComposerTopDrawer
2549 + ? props.bannerItems.filter(
2550 + (item) =>
2551 + item.group === "environment" && (item.variant === "error" || item.variant === "warning"),
2552 + )
2553 : props.bannerItems;
2620 - const [tasksDrawerThreadId, setTasksDrawerThreadId] = useState(activeThreadId);
2621 - if (
2622 - isTasksDrawerOpen &&
2623 - (activeTasksProgress === null ||
2624 - activeTaskSteps === null ||
2625 - hasBlockingComposerTopDrawer ||
2626 - tasksDrawerThreadId !== activeThreadId)
2627 - ) {
2628 - setIsTasksDrawerOpen(false);
2629 - }
2630 - if (tasksDrawerThreadId !== activeThreadId) setTasksDrawerThreadId(activeThreadId);
2554
2555 const insertComposerText = (
2556 text: string,
@@ -3478,20 +3401,8 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
3401 : null}
3402 <ComposerBanner.Dock>
3403 <ComposerBanner.Column>
3481 - <ComposerBannerStack
3482 - key={activeThreadId}
3483 - className="relative z-0"
3484 - items={bannerStackItems}
3485 - attachedAbove={props.queuedRunsControl}
3486 - />
3487 - {!activityStackItem && (shownSyncPhase || inlineTasksBadge) ? (
3488 - <ComposerBanner.Attachment>
3489 - <ComposerBanner.Root data-chat-composer-activity-strip="true">
3490 - {shownSyncPhase ? <ComposerActivityRow phase={shownSyncPhase} /> : inlineTasksBadge}
3491 - </ComposerBanner.Root>
3492 - </ComposerBanner.Attachment>
3493 - ) : null}
3494 - {showComposerTopDrawer && (!isTasksDrawerOpen || hasBlockingComposerTopDrawer) ? (
3404 + <ComposerBannerStack items={shelfItems} />
3405 + {showComposerTopDrawer ? (
3406 <ComposerBanner.Attachment>
3407 <ComposerBanner.Root
3408 data-chat-composer-top-drawer="true"
@@ -3551,27 +3462,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
3462 </ComposerBanner.Root>
3463 </ComposerBanner.Attachment>
3464 ) : null}
3554 - {!activityStackItem &&
3555 - isTasksDrawerOpen &&
3556 - !hasBlockingComposerTopDrawer &&
3557 - activeTasksProgress &&
3558 - activeTaskSteps ? (
3559 - <ComposerTasksDrawer
3560 - onCollapse={toggleTasksDrawerStable}
3561 - progress={activeTasksProgress}
3562 - steps={activeTaskSteps}
3563 - />
3564 - ) : null}
3565 - {showTasksTab ? (
3566 - <ComposerBanner.Attachment>
3567 - <ComposerTasksBadge
3568 - expanded={false}
3569 - onToggle={toggleTasksDrawerStable}
3570 - progress={activeTasksProgress}
3571 - steps={activeTaskSteps}
3572 - />
3573 - </ComposerBanner.Attachment>
3574 - ) : null}
3465 </ComposerBanner.Column>
3466 <ComposerStashBadge
3467 count={stashQueue.length}
apps/web/src/components/chat/ComposerActivityStatus.tsx deleted
-23
@@ -1,23 +0,0 @@
1 -import { Spinner } from "~/components/ui/spinner";
2 -
3 -import { threadSyncLabel, type ThreadSyncPhase } from "../../threadSync";
4 -import { ComposerBanner } from "./ComposerBanner";
5 -
6 -export function ComposerActivityRow({ phase }: { readonly phase: ThreadSyncPhase }) {
7 - return (
8 - <ComposerBanner.Row>
9 - <ComposerBanner.Icon>
10 - <Spinner />
11 - </ComposerBanner.Icon>
12 - <ComposerBanner.Content>
13 - <span
14 - className="shrink-0 whitespace-nowrap text-muted-foreground"
15 - data-composer-sync-status={phase}
16 - role="status"
17 - >
18 - {threadSyncLabel(phase)}
19 - </span>
20 - </ComposerBanner.Content>
21 - </ComposerBanner.Row>
22 - );
23 -}
apps/web/src/components/chat/ComposerBanner.tsx
+3 -48
@@ -34,26 +34,22 @@ const variantColors: Record<ComposerBannerVariant, string> = {
34 };
35
36 function Surface({
37 - placement = "attached",
37 variant = "default",
38 className,
39 ...props
40 }: ComponentProps<"div"> & {
42 - placement?: "attached" | "floating";
41 variant?: ComposerBannerVariant;
42 }) {
43 return (
44 <div
47 - data-composer-banner-surface={placement}
45 + data-composer-banner-surface="attached"
46 data-variant={variant}
47 className={cn(
48 surfaceColors,
49 "relative isolate border-0 bg-transparent shadow-none [--chat-composer-attached-tint:transparent]",
50 variantColors[variant],
51 // Bleed the mask 1px past the seam to cover Chromium's fractional-pixel backdrop loss.
54 - placement === "attached"
55 - ? "[--chat-composer-attachment-overlap:calc(1rem+1px)] before:rounded-t-2xl before:mask-t-from-transparent before:mask-t-from-4 before:mask-t-to-black before:mask-t-to-4"
56 - : "[--chat-composer-attachment-overlap:0px] before:rounded-2xl",
52 + "[--chat-composer-attachment-overlap:calc(1rem+1px)] before:rounded-t-2xl before:mask-t-from-transparent before:mask-t-from-4 before:mask-t-to-black before:mask-t-to-4",
53 "before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:border before:border-(--chat-composer-attached-outline)",
54 "before:bg-(--chat-composer-attached-surface)/(--glass-opacity) before:bg-linear-to-b before:from-(--chat-composer-attached-tint) before:to-(--chat-composer-attached-tint) before:backdrop-blur-(--glass-blur) before:backdrop-saturate-(--glass-saturation)",
55 "before:shadow-composer dark:before:shadow-composer-dark",
@@ -66,38 +62,6 @@ function Surface({
62 );
63 }
64
69 -const peekBorder: Record<ComposerBannerVariant, string> = {
70 - default: "border-(--chat-composer-attached-outline)",
71 - error: "border-destructive/24",
72 - info: "border-(--chat-composer-attached-outline)",
73 - success: "border-(--chat-composer-attached-outline)",
74 - warning: "border-warning/24",
75 -};
76 -
77 -function Peek({
78 - className,
79 - variant = "default",
80 - ...props
81 -}: ComponentProps<"button"> & { variant?: ComposerBannerVariant }) {
82 - return (
83 - <button
84 - type="button"
85 - data-slot="composer-banner-peek"
86 - className={cn(
87 - surfaceColors,
88 - neutralOutline,
89 - "absolute inset-x-0 bottom-0 z-0 mx-auto h-3 w-[96%] cursor-pointer rounded-t-2xl border border-b-0",
90 - "bg-(--chat-composer-attached-surface)/(--glass-opacity) backdrop-blur-(--glass-blur) backdrop-saturate-(--glass-saturation)",
91 - "not-supports-[((backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px)))]:bg-(--chat-composer-attached-surface)",
92 - "transition-opacity duration-150 ease-out focus-visible:outline-2 focus-visible:outline-ring",
93 - peekBorder[variant],
94 - className,
95 - )}
96 - {...props}
97 - />
98 - );
99 -}
100 -
65 function Attachment({ className, ...props }: ComponentProps<"div">) {
66 return (
67 <div
@@ -141,13 +105,11 @@ function Column({ className, ...props }: ComponentProps<"div">) {
105 function Root({
106 className,
107 density = "default",
144 - placement = "attached",
108 variant = "default",
109 width = "fill",
110 ...props
111 }: ComponentProps<"div"> & {
112 density?: "default" | "comfortable" | "spacious";
150 - placement?: "attached" | "floating";
113 variant?: ComposerBannerVariant;
114 width?: "fill" | "content";
115 }) {
@@ -165,15 +127,9 @@ function Root({
127 "[&>[data-composer-banner-row]:first-child>[data-slot=composer-banner-actions]>:last-child>[data-slot=button]:last-of-type]:rounded-se-xl",
128 "[&>:first-child>[data-composer-banner-row]:first-child>[data-slot=composer-banner-actions]>[data-slot=button]:last-child]:rounded-se-xl",
129 ],
168 - placement === "floating" &&
169 - density !== "spacious" && [
170 - "[&>[data-composer-banner-row]:only-child>[data-slot=composer-banner-actions]>[data-slot=button]:last-child]:rounded-ee-xl",
171 - "[&>[data-composer-banner-row]:only-child>[data-slot=composer-banner-actions]>:last-child>[data-slot=button]:last-of-type]:rounded-ee-xl",
172 - ],
130 className,
131 )}
132 data-slot="composer-banner"
176 - placement={placement}
133 data-composer-banner-width={width}
134 variant={variant}
135 {...props}
@@ -193,7 +149,7 @@ function Row({
149 className: cn(
150 "group/banner-row grid min-h-(--composer-banner-icon-column) w-full min-w-0 grid-cols-[var(--composer-banner-icon-column)_minmax(0,1fr)_auto] items-center gap-x-1 text-start",
151 "not-has-[>[data-slot=composer-banner-actions]]:grid-cols-[var(--composer-banner-icon-column)_minmax(0,1fr)]",
196 - "[&:is(button)]:cursor-pointer [&:is(button)]:rounded-md [&:is(button)]:focus-visible:outline-2 [&:is(button)]:focus-visible:-outline-offset-2 [&:is(button)]:focus-visible:outline-ring",
152 + "[&:is(button)]:cursor-pointer [&:is(button)]:rounded-xl [&:is(button)]:hover:bg-foreground/5 [&:is(button)]:focus-visible:outline-2 [&:is(button)]:focus-visible:-outline-offset-2 [&:is(button)]:focus-visible:outline-ring",
153 layout === "wrap-actions" &&
154 "flex flex-wrap *:data-[slot=composer-banner-content]:max-w-[calc(100%-var(--composer-banner-icon-column)-var(--spacing))] *:data-[slot=composer-banner-content]:grow",
155 layout === "approval" && "items-start gap-x-2 gap-y-3",
@@ -338,7 +294,6 @@ function Dismiss({ className, children, ...props }: ComponentProps<typeof Button
294
295 export const ComposerBanner = {
296 Surface,
341 - Peek,
297 Attachment,
298 Dock,
299 Column,
apps/web/src/components/chat/ComposerBannerStack.browser.test.tsx
+27 -17
@@ -1,25 +1,35 @@
1 import { InfoIcon } from "lucide-react";
2 -import { expect, it, vi } from "vite-plus/test";
3 -import { userEvent } from "vite-plus/test/browser";
2 +import { expect, it } from "vite-plus/test";
3 +
4 +import "~/index.css";
5
6 import { render } from "../../../test/render";
7 +import { ComposerBanner } from "./ComposerBanner";
8 import { ComposerBannerStack, type ComposerBannerStackItem } from "./ComposerBannerStack";
9
8 -it("commits a dismissal when the thread switches during the exit transition", async () => {
9 - const onDismiss = vi.fn();
10 - const item: ComposerBannerStackItem = {
11 - id: "notice",
12 - variant: "info",
13 - icon: <InfoIcon />,
14 - title: "Thread A notice",
15 - dismissLabel: "Dismiss notice",
16 - onDismiss,
17 - };
18 - await using screen = await render(<ComposerBannerStack key="thread-a" items={[item]} />);
10 +function notice(title: string, group?: ComposerBannerStackItem["group"]): ComposerBannerStackItem {
11 + return { id: title, variant: "default", icon: <InfoIcon />, title, ...(group ? { group } : {}) };
12 +}
13 +
14 +it("puts machine notices first, whatever order the notices arrive in", async () => {
15 + await using screen = await render(
16 + <ComposerBannerStack items={[notice("Branch changed"), notice("Offline", "environment")]} />,
17 + );
18 +
19 + expect(screen.container.textContent).toBe("OfflineBranch changed");
20 +});
21
20 - await userEvent.click(screen.getByRole("button", { name: "Dismiss notice" }));
21 - // The composer keys the stack by thread, so switching threads remounts it mid-exit.
22 - await screen.rerender(<ComposerBannerStack key="thread-b" items={[]} />);
22 +it("leaves the next attachment its own top edge when there are no notices", async () => {
23 + await using screen = await render(
24 + <ComposerBanner.Column>
25 + <ComposerBannerStack items={[]} />
26 + <ComposerBanner.Attachment>
27 + <ComposerBanner.Root data-testid="drawer">Approval</ComposerBanner.Root>
28 + </ComposerBanner.Attachment>
29 + </ComposerBanner.Column>,
30 + );
31
24 - await vi.waitFor(() => expect(onDismiss).toHaveBeenCalledTimes(1));
32 + const surface = getComputedStyle(screen.getByTestId("drawer").element(), "::before");
33 + expect(surface.borderTopWidth).toBe("1px");
34 + expect(surface.borderTopLeftRadius).not.toBe("0px");
35 });
apps/web/src/components/chat/ComposerBannerStack.tsx
+44 -240
@@ -1,20 +1,21 @@
1 import { InfoIcon } from "lucide-react";
2 -import { useId, useLayoutEffect, useRef, useState, type ReactNode } from "react";
3 -import { flushSync } from "react-dom";
2 +import { useLayoutEffect, useRef, useState, type ReactNode } from "react";
3
5 -import { cn } from "~/lib/utils";
4 import { Button } from "../ui/button";
5 import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
6 import { ComposerBanner, type ComposerBannerVariant } from "./ComposerBanner";
7 import { observeResize } from "~/lib/observeResize";
8
11 -// Match the duration-220 exit transition before removing a dismissed notice.
12 -const DISMISS_TRANSITION_MS = 220;
9 +/**
10 + * Where a notice sits above the composer. The machine comes first, then what needs you; the
11 + * order is fixed so rows never trade places as notices come and go.
12 + */
13 +export type ComposerBannerGroup = "environment" | "attention";
14
15 export interface ComposerBannerStackItem {
16 readonly id: string;
17 readonly variant: ComposerBannerVariant;
17 - readonly priority?: "urgent" | "activity" | "notice";
18 + readonly group?: ComposerBannerGroup;
19 readonly icon: ReactNode;
20 readonly title: ReactNode;
21 readonly description?: ReactNode;
@@ -24,214 +25,31 @@ export interface ComposerBannerStackItem {
25 readonly onDismiss?: () => void;
26 }
27
27 -export type ComposerBannerStackContent = Pick<
28 - ComposerBannerStackItem,
29 - "id" | "variant" | "priority"
30 -> & { readonly content: ReactNode };
28 +const GROUPS = ["environment", "attention"] as const;
29
32 -type ComposerBannerStackEntry = ComposerBannerStackItem | ComposerBannerStackContent;
33 -
34 -function bannerPriority(item: ComposerBannerStackEntry) {
35 - if (item.priority === "urgent" || item.variant === "error" || item.variant === "warning") {
36 - return 0;
37 - }
38 - if (item.priority === "activity") {
39 - return 1;
40 - }
41 - return 2;
42 -}
43 -
44 -interface ComposerBannerStackProps {
45 - readonly className?: string;
46 - readonly items: ReadonlyArray<ComposerBannerStackEntry>;
47 - readonly attachedAbove?: ReactNode;
48 -}
49 -
50 -export function ComposerBannerStack({ className, items, attachedAbove }: ComposerBannerStackProps) {
51 - const [stackExpanded, setStackExpanded] = useState(false);
52 - const noticesRef = useRef<HTMLDivElement>(null);
53 - const peekRef = useRef<HTMLButtonElement>(null);
54 - const expandedItemsRef = useRef<HTMLDivElement>(null);
55 - const expandedItemsId = useId();
56 - const [requestedExitingItemId, setExitingItemId] = useState<string | null>(null);
57 - const exitingItemId =
58 - requestedExitingItemId !== null && items.some((item) => item.id === requestedExitingItemId)
59 - ? requestedExitingItemId
60 - : null;
61 -
62 - if (items.length < 2 && stackExpanded) {
63 - setStackExpanded(false);
64 - }
65 -
66 - const expandAndFocusNotice = () => {
67 - flushSync(() => setStackExpanded(true));
68 - const container = expandedItemsRef.current;
69 - const firstControl = container?.querySelector<HTMLElement>(
70 - 'button:not(:disabled), a[href], input:not(:disabled), [tabindex="0"]',
71 - );
72 - (firstControl ?? container)?.focus({ preventScroll: true });
73 - };
74 -
75 - const orderedItems = items.toSorted((a, b) => bannerPriority(a) - bannerPriority(b));
76 - const frontItem = orderedItems[0];
77 - if (!frontItem) {
78 - return (
79 - <>
80 - {null}
81 - {attachedAbove}
82 - {null}
83 - </>
84 - );
85 - }
86 - const stackedItems = orderedItems.slice(1);
87 - const hasStack = stackedItems.length > 0;
88 - const showCollapsedStackCap = hasStack && exitingItemId !== frontItem.id;
89 - const firstStackedItem = stackedItems[0];
90 -
91 - const requestDismiss = (item: ComposerBannerStackEntry) => {
92 - if (!("onDismiss" in item) || !item.onDismiss || exitingItemId) {
93 - return;
94 - }
95 - setExitingItemId(item.id);
96 - // A timer, not transitionend: the dismissal must commit even when the stack unmounts
97 - // (thread switch) or a collapsed composer hides it mid-exit, and transitionend never fires then.
98 - setTimeout(() => item.onDismiss?.(), DISMISS_TRANSITION_MS);
99 - };
100 -
101 - return (
102 - <>
103 - {hasStack ? (
104 - <div
105 - ref={noticesRef}
106 - data-composer-banner-stack="true"
107 - data-chat-composer-collapsed-controls="true"
108 - className={cn("relative z-20 min-h-3", stackExpanded && "z-50")}
109 - onPointerEnter={(event) => {
110 - if (event.pointerType === "touch") return;
111 - if (document.activeElement === peekRef.current) {
112 - expandAndFocusNotice();
113 - return;
114 - }
115 - setStackExpanded(true);
116 - }}
117 - onPointerLeave={(event) => {
118 - if (!event.currentTarget.contains(document.activeElement)) setStackExpanded(false);
119 - }}
120 - onBlurCapture={(event) => {
121 - if (
122 - !event.currentTarget.contains(event.relatedTarget) &&
123 - !event.currentTarget.matches(":hover")
124 - ) {
125 - setStackExpanded(false);
126 - }
127 - }}
128 - onKeyDown={(event) => {
129 - if (event.key !== "Escape" || !stackExpanded) return;
130 - event.preventDefault();
131 - event.stopPropagation();
132 - flushSync(() => setStackExpanded(false));
133 - peekRef.current?.focus({ preventScroll: true });
134 - }}
135 - >
136 - {showCollapsedStackCap && firstStackedItem ? (
137 - <ComposerBanner.Peek
138 - ref={peekRef}
139 - variant={firstStackedItem.variant}
140 - aria-label="Show other notices"
141 - aria-expanded={stackExpanded}
142 - aria-controls={expandedItemsId}
143 - aria-hidden={stackExpanded || undefined}
144 - tabIndex={stackExpanded ? -1 : 0}
145 - onClick={(event) => {
146 - event.currentTarget.focus({ preventScroll: true });
147 - expandAndFocusNotice();
148 - }}
149 - className={cn(stackExpanded && "pointer-events-none invisible opacity-0")}
150 - />
151 - ) : null}
152 - <div
153 - id={expandedItemsId}
154 - ref={expandedItemsRef}
155 - role="group"
156 - aria-label="Other notices"
157 - tabIndex={-1}
158 - data-composer-banner-stack-expanded-items="true"
159 - className={cn(
160 - "grid transition-[grid-template-rows] duration-150 ease-out focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",
161 - stackExpanded ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
162 - )}
163 - >
164 - {/* Horizontal clipping shaves the right border at fractional widths. */}
165 - <div className="min-h-0 overflow-y-clip">
166 - <div
167 - className={cn(
168 - "transform-gpu space-y-2 pb-2 transition-[opacity,transform] duration-150 ease-out will-change-transform",
169 - stackExpanded
170 - ? "pointer-events-auto visible translate-y-0 opacity-100"
171 - : "pointer-events-none invisible translate-y-1 opacity-0",
172 - )}
173 - >
174 - {stackedItems.map((item) => (
175 - <div
176 - key={item.id}
177 - className={cn(
178 - "transition-[opacity,translate] duration-220 ease-in",
179 - exitingItemId === item.id
180 - ? "pointer-events-none translate-y-28 opacity-0"
181 - : "opacity-100",
182 - )}
183 - >
184 - <ComposerBannerStackAlert
185 - item={item}
186 - attached={false}
187 - exiting={exitingItemId === item.id}
188 - onDismissRequest={() => requestDismiss(item)}
189 - />
190 - </div>
191 - ))}
192 - </div>
193 - </div>
194 - </div>
195 - </div>
196 - ) : null}
197 - {attachedAbove}
198 - <ComposerBanner.Attachment
199 - className={className}
200 - data-composer-banner-drawer="true"
201 - data-chat-composer-collapsed-controls="true"
202 - >
203 - <div
204 - key={frontItem.id}
205 - className={cn(
206 - "relative z-10 transition-[opacity,translate] duration-220 ease-in",
207 - exitingItemId === frontItem.id
208 - ? "pointer-events-none translate-y-16 opacity-0"
209 - : "opacity-100",
210 - )}
211 - onPointerDownCapture={() => {
212 - setStackExpanded(false);
213 - const activeElement = document.activeElement;
214 - if (
215 - activeElement instanceof HTMLElement &&
216 - noticesRef.current?.contains(activeElement)
217 - ) {
218 - activeElement.blur();
219 - }
220 - }}
221 - >
222 - <ComposerBannerStackAlert
223 - item={frontItem}
224 - attached
225 - exiting={exitingItemId === frontItem.id}
226 - onDismissRequest={() => requestDismiss(frontItem)}
227 - />
228 - </div>
229 - </ComposerBanner.Attachment>
230 - </>
231 - );
30 +/**
31 + * Notices about sending from this composer, each its own attached card. Consecutive cards join
32 + * edge to edge, and the last joins the composer or the drawer below it.
33 + */
34 +export function ComposerBannerStack({
35 + items,
36 +}: {
37 + readonly items: ReadonlyArray<ComposerBannerStackItem>;
38 +}) {
39 + return GROUPS.flatMap((group) =>
40 + items.filter((item) => (item.group ?? "attention") === group),
41 + ).map((item) => (
42 + <ComposerBanner.Attachment
43 + key={item.id}
44 + data-composer-banner-stack="true"
45 + className="transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none"
46 + >
47 + <NoticeCard item={item} />
48 + </ComposerBanner.Attachment>
49 + ));
50 }
51
234 -function NoticeText({
52 +export function NoticeText({
53 children,
54 className,
55 detailsLabel,
@@ -306,49 +124,36 @@ function NoticeText({
124 );
125 }
126
309 -function ComposerBannerStackAlert({
310 - item,
311 - attached,
312 - exiting,
313 - onDismissRequest,
314 -}: {
315 - readonly item: ComposerBannerStackEntry;
316 - readonly attached: boolean;
317 - readonly exiting: boolean;
318 - readonly onDismissRequest: () => void;
319 -}) {
320 - if ("content" in item) {
321 - return (
322 - <ComposerBanner.Root
323 - density="comfortable"
324 - placement={attached ? "attached" : "floating"}
325 - variant={item.variant}
326 - >
327 - {item.content}
328 - </ComposerBanner.Root>
329 - );
330 - }
127 +function NoticeCard({ item }: { readonly item: ComposerBannerStackItem }) {
128 return (
129 <ComposerBanner.Root
333 - role="alert"
334 - placement={attached ? "attached" : "floating"}
130 + role={item.variant === "error" || item.variant === "warning" ? "alert" : undefined}
131 variant={item.variant}
132 density="comfortable"
133 + data-chat-composer-collapsed-controls="true"
134 >
338 - <ComposerBanner.Row layout={item.priority === "activity" ? "inline" : "wrap-actions"}>
135 + <ComposerBanner.Row layout="wrap-actions">
136 <ComposerBanner.Icon className="h-(--composer-banner-icon-column) self-start">
137 {item.icon}
138 </ComposerBanner.Icon>
139 <ComposerBanner.Content className="whitespace-nowrap">
140 <NoticeText
344 - detailsLabel="Show title details"
141 + detailsLabel={
142 + typeof item.title === "string"
143 + ? `Show full title: ${item.title}`
144 + : "Show title details"
145 + }
146 className="min-w-0 truncate font-medium leading-7 sm:leading-6"
147 >
148 {item.title}
149 </NoticeText>
150 {item.description ? (
151 <NoticeText
351 - detailsLabel="Show notice details"
152 + detailsLabel={
153 + typeof item.title === "string"
154 + ? `Show details: ${item.title}`
155 + : "Show notice details"
156 + }
157 className="w-0 min-w-0 grow truncate text-muted-foreground @max-[400px]:sr-only"
158 >
159 {item.description}
@@ -361,8 +166,7 @@ function ComposerBannerStackAlert({
166 {item.onDismiss ? (
167 <ComposerBanner.Dismiss
168 aria-label={item.dismissLabel ?? "Dismiss warning"}
364 - disabled={exiting}
365 - onClick={onDismissRequest}
169 + onClick={item.onDismiss}
170 />
171 ) : null}
172 </ComposerBanner.Actions>
apps/web/src/components/chat/ComposerFeedback.tsx
-1
@@ -19,7 +19,6 @@ export function feedbackBannerItem(
19 id: `feedback:${submission.id}`,
20 variant:
21 submission.status === "failed" ? "error" : submission.status === "sent" ? "success" : "info",
22 - priority: submission.status === "uploading" ? "activity" : "notice",
22 icon: <MessageSquareIcon />,
23 ...notice,
24 actions:
apps/web/src/components/chat/ComposerServerUpdateStatus.tsx
+1 -4
@@ -1,15 +1,12 @@
1 -import { Spinner } from "~/components/ui/spinner";
1 import type { ServerUpdateState } from "@t3tools/client-runtime/state/server";
2 import { CircleAlertIcon, DownloadIcon } from "lucide-react";
3
4 +// Static on purpose: the title says when an update is running, and spinners repaint every frame.
5 export function ComposerServerUpdateIcon({
6 status,
7 }: {
8 readonly status: ServerUpdateState["status"];
9 }) {
10 - if (status === "running") {
11 - return <Spinner aria-hidden />;
12 - }
10 if (status === "failed") {
11 return <CircleAlertIcon aria-hidden className="text-error" />;
12 }
apps/web/src/components/chat/ComposerTasksBadge.tsx deleted
-236
@@ -1,236 +0,0 @@
1 -import { CheckIcon, CircleDotIcon, CircleIcon, ListTodoIcon } from "lucide-react";
2 -import { memo, type ComponentProps } from "react";
3 -
4 -import { formatDuration } from "../../session-logic";
5 -import { cn } from "~/lib/utils";
6 -import { ComposerBanner } from "./ComposerBanner";
7 -
8 -export interface ComposerTasksProgress {
9 - readonly step: string;
10 - readonly completedSteps: number;
11 - readonly totalSteps: number;
12 - readonly live: boolean;
13 -}
14 -
15 -export interface ComposerTaskStep {
16 - readonly durationMs?: number;
17 - readonly step: string;
18 - readonly status: "pending" | "inProgress" | "completed";
19 -}
20 -
21 -const MAX_TASK_SEGMENTS = 10;
22 -
23 -const taskStatusLabels = {
24 - pending: "Pending",
25 - inProgress: "Running",
26 - completed: "Completed",
27 -} satisfies Record<ComposerTaskStep["status"], string>;
28 -
29 -function keyedTaskSteps(steps: readonly ComposerTaskStep[]) {
30 - const occurrences = new Map<string, number>();
31 - return steps.map((step) => {
32 - const occurrence = occurrences.get(step.step) ?? 0;
33 - occurrences.set(step.step, occurrence + 1);
34 - return { key: `${step.step}:${occurrence}`, step };
35 - });
36 -}
37 -
38 -function TaskSegments({
39 - className,
40 - steps,
41 -}: {
42 - readonly className?: string;
43 - readonly steps: readonly ComposerTaskStep[];
44 -}) {
45 - if (steps.length <= 1 || steps.length > MAX_TASK_SEGMENTS) return null;
46 -
47 - return (
48 - <span aria-hidden className={cn("flex w-10 shrink-0 items-center gap-0.5", className)}>
49 - {keyedTaskSteps(steps).map(({ key, step }) => (
50 - <span
51 - key={key}
52 - className={cn(
53 - "h-[3px] min-w-0 flex-1 rounded-full",
54 - step.status === "completed"
55 - ? "bg-success"
56 - : step.status === "inProgress"
57 - ? "bg-primary"
58 - : "bg-muted-foreground/25",
59 - )}
60 - />
61 - ))}
62 - </span>
63 - );
64 -}
65 -
66 -function TaskSummary({
67 - expanded,
68 - progress,
69 - steps,
70 -}: {
71 - readonly expanded: boolean;
72 - readonly progress: ComposerTasksProgress;
73 - readonly steps: readonly ComposerTaskStep[];
74 -}) {
75 - return (
76 - <>
77 - <ComposerBanner.Icon>
78 - <ListTodoIcon />
79 - </ComposerBanner.Icon>
80 - <ComposerBanner.Content>
81 - <span className="shrink-0 text-muted-foreground">Tasks</span>
82 - <span
83 - className="min-w-0 flex-1 truncate text-left font-medium text-foreground/80"
84 - data-composer-task-current="true"
85 - >
86 - {progress.step}
87 - </span>
88 - </ComposerBanner.Content>
89 - <ComposerBanner.Actions>
90 - <ComposerBanner.Count
91 - className={progress.completedSteps >= progress.totalSteps ? "text-success" : undefined}
92 - data-composer-task-progress="true"
93 - >
94 - {progress.completedSteps}/{progress.totalSteps}
95 - </ComposerBanner.Count>
96 - <TaskSegments className="hidden w-20 @min-[560px]:flex" steps={steps} />
97 - <ComposerBanner.ToggleIcon expanded={expanded} />
98 - </ComposerBanner.Actions>
99 - </>
100 - );
101 -}
102 -
103 -export const ComposerTasksBadge = memo(function ComposerTasksBadge({
104 - expanded,
105 - onToggle,
106 - placement = "tab",
107 - progress,
108 - steps,
109 -}: {
110 - readonly expanded: boolean;
111 - readonly onToggle: () => void;
112 - readonly placement?: "inline" | "tab";
113 - readonly progress: ComposerTasksProgress;
114 - readonly steps: readonly ComposerTaskStep[];
115 -}) {
116 - if (progress.totalSteps <= 0) return null;
117 -
118 - const row = (
119 - <ComposerBanner.Row
120 - render={<button type="button" />}
121 - aria-expanded={expanded}
122 - aria-label={`${expanded ? "Collapse tasks" : "Tasks"}: ${progress.completedSteps} of ${progress.totalSteps} complete. Current task: ${progress.step}`}
123 - data-composer-tasks-badge="true"
124 - onClick={onToggle}
125 - onPointerDown={(event) => event.preventDefault()}
126 - >
127 - <TaskSummary expanded={expanded} progress={progress} steps={steps} />
128 - </ComposerBanner.Row>
129 - );
130 - return placement === "inline" ? (
131 - row
132 - ) : (
133 - <ComposerBanner.Root density="comfortable" data-composer-shoulder-tab>
134 - {row}
135 - </ComposerBanner.Root>
136 - );
137 -});
138 -
139 -export const ComposerTasksContent = memo(function ComposerTasksContent({
140 - expanded,
141 - onToggle,
142 - progress,
143 - steps,
144 -}: {
145 - readonly expanded: boolean;
146 - readonly onToggle: () => void;
147 - readonly progress: ComposerTasksProgress;
148 - readonly steps: readonly ComposerTaskStep[];
149 -}) {
150 - return (
151 - <div
152 - data-chat-composer-collapsed-controls="true"
153 - data-chat-composer-tasks-drawer={expanded ? "true" : undefined}
154 - >
155 - <ComposerTasksBadge
156 - expanded={expanded}
157 - onToggle={onToggle}
158 - placement="inline"
159 - progress={progress}
160 - steps={steps}
161 - />
162 - {expanded ? (
163 - <ComposerBanner.Scroll data-composer-tasks-scroll="true">
164 - <ComposerBanner.Children
165 - render={<ul role="list" />}
166 - aria-label={`Task list. ${progress.completedSteps} of ${progress.totalSteps} complete.`}
167 - data-composer-tasks-list="true"
168 - >
169 - {keyedTaskSteps(steps).map(({ key, step }) => (
170 - <ComposerBanner.Row key={key} render={<li />} className="items-start py-1 pe-2">
171 - <ComposerBanner.Icon
172 - className={cn(
173 - "h-4",
174 - step.status === "completed"
175 - ? "text-success"
176 - : step.status === "inProgress"
177 - ? "text-primary"
178 - : "text-muted-foreground/40",
179 - )}
180 - >
181 - {step.status === "completed" ? (
182 - <CheckIcon />
183 - ) : step.status === "inProgress" ? (
184 - <CircleDotIcon />
185 - ) : (
186 - <CircleIcon />
187 - )}
188 - </ComposerBanner.Icon>
189 - <ComposerBanner.Content
190 - className={cn(
191 - "block wrap-anywhere",
192 - step.status === "completed"
193 - ? "text-muted-foreground/55"
194 - : step.status === "inProgress"
195 - ? "text-foreground/90"
196 - : "text-muted-foreground/70",
197 - )}
198 - >
199 - <span className="sr-only">{taskStatusLabels[step.status]}: </span>
200 - {step.step}
201 - </ComposerBanner.Content>
202 - <ComposerBanner.Actions>
203 - <span
204 - className="min-w-12 text-right text-3xs/4 whitespace-nowrap text-muted-foreground/45 tabular-nums"
205 - data-composer-task-duration="true"
206 - >
207 - {step.durationMs !== undefined
208 - ? formatDuration(step.durationMs)
209 - : step.status === "inProgress" && progress.live
210 - ? "now"
211 - : null}
212 - </span>
213 - </ComposerBanner.Actions>
214 - </ComposerBanner.Row>
215 - ))}
216 - </ComposerBanner.Children>
217 - </ComposerBanner.Scroll>
218 - ) : null}
219 - </div>
220 - );
221 -});
222 -
223 -export const ComposerTasksDrawer = memo(function ComposerTasksDrawer({
224 - onCollapse,
225 - ...props
226 -}: Omit<ComponentProps<typeof ComposerTasksContent>, "expanded" | "onToggle"> & {
227 - readonly onCollapse: () => void;
228 -}) {
229 - return (
230 - <ComposerBanner.Attachment>
231 - <ComposerBanner.Root>
232 - <ComposerTasksContent {...props} expanded onToggle={onCollapse} />
233 - </ComposerBanner.Root>
234 - </ComposerBanner.Attachment>
235 - );
236 -});
apps/web/src/components/chat/ComposerUsageLimits.tsx
-1
@@ -58,7 +58,6 @@ export function usageLimitsBannerItem(
58 return {
59 id,
60 variant: "info",
61 - priority: "notice",
61 icon: <GaugeIcon />,
62 title: "Usage limits",
63 description: summary,
apps/web/src/components/chat/MessagesTimeline.tsx
+22 -2
@@ -143,14 +143,28 @@ const TIMELINE_LIST_FADE_HEADER = (
143 );
144 function TimelineListFooter({
145 composerInset,
146 + onGrow,
147 children,
148 }: {
149 readonly composerInset: number;
150 + readonly onGrow: (() => void) | undefined;
151 readonly children?: ReactNode;
152 }) {
153 + const contentRef = useRef<HTMLDivElement>(null);
154 + // oxlint-disable-next-line t3code/react-effect-budget -- reports growth of the footer's content, which the list does not follow
155 + useLayoutEffect(() => {
156 + const content = contentRef.current;
157 + if (!content || !onGrow) return;
158 + let height = content.offsetHeight;
159 + return observeResize(content, () => {
160 + const next = content.offsetHeight;
161 + if (next > height) onGrow();
162 + height = next;
163 + });
164 + }, [onGrow]);
165 return (
166 <div>
153 - {children}
167 + <div ref={contentRef}>{children}</div>
168 <div aria-hidden style={{ height: composerInset }} />
169 <div aria-hidden className="h-3 sm:h-4" />
170 </div>
@@ -266,6 +280,8 @@ interface MessagesTimelineProps {
280 onToolOutputCollapsedAtEnd?: () => void;
281 /** Receives the list's viewport when it mounts; the returned cleanup runs when it goes away. */
282 onViewportAttach?: (viewport: TimelineViewport) => () => void;
283 + /** The footer's content grew, such as a new queued turn or status line. */
284 + onFooterGrow?: () => void;
285 findOpen?: boolean;
286 hideEmptyPlaceholder?: boolean;
287 /** Composer space to center the empty state against; held steady through collapse. */
@@ -360,6 +376,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
376 liveFollowEnabled,
377 onToolOutputCollapsedAtEnd,
378 onViewportAttach,
379 + onFooterGrow,
380 hideEmptyPlaceholder = false,
381 emptyPlaceholderInset,
382 topFadeEnabled = false,
@@ -794,7 +811,10 @@ const ConversationTimeline = memo(function ConversationTimeline({
811 shouldRestorePosition: shouldRestoreVisibleContentPosition,
812 };
813 const timelineListFooter = (
797 - <TimelineListFooter composerInset={anchoredEndSpace ? 0 : contentInsetEndAdjustment}>
814 + <TimelineListFooter
815 + composerInset={anchoredEndSpace ? 0 : contentInsetEndAdjustment}
816 + onGrow={onFooterGrow}
817 + >
818 {footer}
819 </TimelineListFooter>
820 );
apps/web/src/components/chat/QueuedRunsControl.tsx
+275 -245
@@ -10,11 +10,13 @@ import type {
10 ThreadId,
11 } from "@t3tools/contracts";
12 import {
13 + ChevronDownIcon,
14 Clock3Icon,
15 CornerUpRightIcon,
16 GripVerticalIcon,
17 ListOrderedIcon,
18 PencilIcon,
19 + XIcon,
20 } from "lucide-react";
21 import { useId, useImperativeHandle, useRef, useState, type Ref } from "react";
22
@@ -24,8 +26,7 @@ import { useThreadProjection } from "../../state/entities";
26 import { useAtomCommand } from "../../state/use-atom-command";
27 import { isImageAttachment, type ChatMessage } from "../../types";
28 import { cn } from "~/lib/utils";
27 -import { ComposerBanner } from "./ComposerBanner";
28 -import { Button } from "../ui/button";
29 +import { Button, InlineButton } from "../ui/button";
30 import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
31
32 export interface EditQueuedRunRequest {
@@ -42,6 +43,8 @@ interface QueuedRowThumbnail {
43 }
44
45 const QUEUED_RUN_DRAG_TYPE = "application/x-t3code-queued-run";
46 +// A longer queue shows its first messages and a button that shows the rest.
47 +const QUEUE_VISIBLE_ROWS = 3;
48
49 export interface QueuedRunsControlHandle {
50 steerNext: (repeat: boolean) => boolean;
@@ -86,7 +89,7 @@ export function QueuedRunsControl({
89 const promote = useAtomCommand(threadEnvironment.promoteQueuedRun);
90 const resume = useAtomCommand(threadEnvironment.resumeThreadQueue);
91 const cancel = useAtomCommand(threadEnvironment.cancelQueuedRun);
89 - const [expanded, setExpanded] = useState(true);
92 + const [showAll, setShowAll] = useState(false);
93 const queueListId = useId();
94 const [busyRunId, setBusyRunId] = useState<RunId | null>(null);
95 const [dragState, setDragState] = useState<{
@@ -215,7 +218,7 @@ export function QueuedRunsControl({
218 return false;
219 }
220 if (!repeat) {
218 - setExpanded(true);
221 + setShowAll(true);
222 props.onEditQueuedRun({
223 runId: latest.run.id,
224 messageId: latest.run.userMessageId,
@@ -238,258 +241,285 @@ export function QueuedRunsControl({
241 setBusyRunId(null);
242 };
243
244 + const collapsible = items.length > QUEUE_VISIBLE_ROWS;
245 + const visibleItems = collapsible && !showAll ? items.slice(0, QUEUE_VISIBLE_ROWS - 1) : items;
246 +
247 return (
242 - <ComposerBanner.Attachment>
243 - <ComposerBanner.Root
244 - role="region"
245 - aria-label={`${items.length} queued message${items.length === 1 ? "" : "s"}`}
246 - aria-live="polite"
247 - data-chat-composer-collapsed-controls="true"
248 - className="relative z-0"
249 - >
250 - <ComposerBanner.Row
251 - render={<button type="button" />}
252 - aria-label={expanded ? "Collapse queued messages" : "Expand queued messages"}
253 - aria-expanded={expanded}
254 - aria-controls={queueListId}
255 - onPointerDown={(event) => event.preventDefault()}
256 - onClick={() => setExpanded((value) => !value)}
257 - >
258 - <ComposerBanner.Icon>
259 - <ListOrderedIcon />
260 - </ComposerBanner.Icon>
261 - <ComposerBanner.Content className="text-muted-foreground">Queued</ComposerBanner.Content>
262 - <ComposerBanner.Actions>
263 - <ComposerBanner.Count>{items.length}</ComposerBanner.Count>
264 - <ComposerBanner.ToggleIcon expanded={expanded} />
265 - </ComposerBanner.Actions>
266 - </ComposerBanner.Row>
267 - <ComposerBanner.Scroll className={cn("max-h-32", !expanded && "hidden")}>
268 - <ComposerBanner.Children render={<ol />} id={queueListId}>
269 - {items.map((item) => {
270 - const previewText = assistantCitationsToPlainText(
271 - replaceComposerContextReferences(item.text, (reference) =>
272 - reference.kind === "image" && item.thumbnails.length > 0 ? "" : reference.label,
273 - ),
274 - ).trim();
275 - const rowRunId = item.runId;
276 - const rowServerIndex = item.serverIndex;
277 - const isEditing = rowRunId !== null && rowRunId === props.editingRunId;
278 - const rowDraggable =
279 - rowRunId !== null && rowServerIndex !== null && canReorder && busyRunId === null;
280 - return (
281 - <ComposerBanner.Row
282 - render={<li />}
283 - key={item.key}
284 - aria-current={isEditing ? "true" : undefined}
285 - className={cn(
286 - "relative rounded-sm",
287 - isEditing && "bg-accent text-accent-foreground",
288 - dragState !== null && dragState.runId === item.runId && "opacity-50",
289 - )}
290 - draggable={rowDraggable}
291 - onDragStart={(event) => {
292 - if (item.runId === null || dragArmedRunIdRef.current !== item.runId) {
293 - event.preventDefault();
294 - return;
295 - }
296 - event.dataTransfer.setData(QUEUED_RUN_DRAG_TYPE, item.runId);
297 - event.dataTransfer.effectAllowed = "move";
298 - setDragState({ runId: item.runId, insertIndex: null });
299 - }}
300 - onDragEnd={() => {
301 - dragArmedRunIdRef.current = null;
302 - setDragState(null);
303 - }}
304 - onDragOver={(event) => {
305 - if (dragState === null || item.serverIndex === null) return;
306 - event.preventDefault();
307 - event.dataTransfer.dropEffect = "move";
308 - const rect = event.currentTarget.getBoundingClientRect();
309 - const insertIndex =
310 - event.clientY < rect.top + rect.height / 2
311 - ? item.serverIndex
312 - : item.serverIndex + 1;
313 - if (dragState.insertIndex !== insertIndex) {
314 - setDragState({ runId: dragState.runId, insertIndex });
315 - }
316 - }}
317 - onDrop={(event) => {
318 - if (dragState === null) return;
319 - event.preventDefault();
320 - completeDrag(dragState.runId, dragState.insertIndex);
321 - }}
322 - >
323 - {item.serverIndex !== null && dragState?.insertIndex === item.serverIndex ? (
324 - <span
325 - aria-hidden
326 - className="pointer-events-none absolute inset-x-0 top-0 h-0.5 rounded bg-primary/70"
327 - />
328 - ) : null}
329 - {item.serverIndex === queued.length - 1 &&
330 - dragState?.insertIndex === queued.length ? (
331 - <span
332 - aria-hidden
333 - className="pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded bg-primary/70"
334 - />
335 - ) : null}
336 - <ComposerBanner.Icon aria-hidden={false}>
337 - {canReorder && rowRunId !== null && rowServerIndex !== null ? (
338 - <Button
339 - size="icon-xs"
340 - variant="ghost-muted"
341 - aria-label="Reorder queued message (drag, or press the arrow keys)"
342 - className="cursor-grab active:cursor-grabbing disabled:cursor-default"
343 - disabled={busyRunId !== null}
344 - onPointerDown={() => {
345 - dragArmedRunIdRef.current = rowRunId;
346 - }}
347 - onKeyDown={(event) => {
348 - if (busyRunId !== null) return;
349 - if (event.key === "ArrowUp" && rowServerIndex > 0) {
350 - event.preventDefault();
351 - void move(rowRunId, queued[rowServerIndex - 1]?.run.id ?? null);
352 - }
353 - if (event.key === "ArrowDown" && rowServerIndex < queued.length - 1) {
354 - event.preventDefault();
355 - void move(rowRunId, queued[rowServerIndex + 2]?.run.id ?? null);
356 - }
357 - }}
248 + <section
249 + aria-label={`Up next: ${items.length} queued message${items.length === 1 ? "" : "s"}`}
250 + data-thread-queue="true"
251 + className="mx-auto flex w-full max-w-(--chat-content-max-width) flex-col gap-2 pb-4"
252 + >
253 + <h3 className="flex min-h-5 items-center gap-1.5 px-1 text-xs font-normal text-muted-foreground [&_svg]:size-3.5">
254 + <ListOrderedIcon aria-hidden />
255 + Up next
256 + <span className="tabular-nums" aria-live="polite">
257 + · {items.length} queued
258 + </span>
259 + </h3>
260 + <ol className="flex flex-col items-end gap-3" id={queueListId}>
261 + {visibleItems.map((item, position) => {
262 + const previewText = assistantCitationsToPlainText(
263 + replaceComposerContextReferences(item.text, (reference) =>
264 + reference.kind === "image" && item.thumbnails.length > 0 ? "" : reference.label,
265 + ),
266 + ).trim();
267 + const rowRunId = item.runId;
268 + const rowServerIndex = item.serverIndex;
269 + const isEditing = rowRunId !== null && rowRunId === props.editingRunId;
270 + const rowDraggable =
271 + rowRunId !== null && rowServerIndex !== null && canReorder && busyRunId === null;
272 + return (
273 + <li
274 + key={item.key}
275 + aria-label={`Queued message ${position + 1} of ${items.length}, not sent`}
276 + aria-posinset={position + 1}
277 + aria-setsize={items.length}
278 + aria-current={isEditing ? "true" : undefined}
279 + className={cn(
280 + "group/queued relative flex w-full flex-col items-end gap-1 transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none",
281 + dragState !== null && dragState.runId === item.runId && "opacity-50",
282 + )}
283 + draggable={rowDraggable}
284 + onDragStart={(event) => {
285 + if (item.runId === null || dragArmedRunIdRef.current !== item.runId) {
286 + event.preventDefault();
287 + return;
288 + }
289 + event.dataTransfer.setData(QUEUED_RUN_DRAG_TYPE, item.runId);
290 + event.dataTransfer.effectAllowed = "move";
291 + setDragState({ runId: item.runId, insertIndex: null });
292 + }}
293 + onDragEnd={() => {
294 + dragArmedRunIdRef.current = null;
295 + setDragState(null);
296 + }}
297 + onDragOver={(event) => {
298 + if (dragState === null || item.serverIndex === null) return;
299 + event.preventDefault();
300 + event.dataTransfer.dropEffect = "move";
301 + const rect = event.currentTarget.getBoundingClientRect();
302 + const insertIndex =
303 + event.clientY < rect.top + rect.height / 2
304 + ? item.serverIndex
305 + : item.serverIndex + 1;
306 + if (dragState.insertIndex !== insertIndex) {
307 + setDragState({ runId: dragState.runId, insertIndex });
308 + }
309 + }}
310 + onDrop={(event) => {
311 + if (dragState === null) return;
312 + event.preventDefault();
313 + completeDrag(dragState.runId, dragState.insertIndex);
314 + }}
315 + >
316 + {item.serverIndex !== null && dragState?.insertIndex === item.serverIndex ? (
317 + <span
318 + aria-hidden
319 + className="pointer-events-none absolute inset-x-0 -top-1.5 h-0.5 rounded bg-primary/70"
320 + />
321 + ) : null}
322 + {item.serverIndex === queued.length - 1 &&
323 + dragState?.insertIndex === queued.length ? (
324 + <span
325 + aria-hidden
326 + className="pointer-events-none absolute inset-x-0 -bottom-1.5 h-0.5 rounded bg-primary/70"
327 + />
328 + ) : null}
329 + {/* Dashed and unfilled: a turn that has not been sent yet. */}
330 + <div
331 + className={cn(
332 + "flex min-w-0 max-w-[80%] flex-col gap-2 rounded-2xl border border-dashed px-3 py-2 text-sm",
333 + isEditing
334 + ? "border-primary/60 text-foreground"
335 + : "border-muted-foreground/40 text-muted-foreground",
336 + )}
337 + >
338 + {item.thumbnails.length > 0 ? (
339 + <span className="flex flex-wrap items-center gap-1">
340 + {item.thumbnails.map((thumbnail) => (
341 + <span
342 + key={thumbnail.key}
343 + className="size-8 overflow-hidden rounded-md border border-border/70 bg-background"
344 >
359 - <GripVerticalIcon />
360 - </Button>
361 - ) : null}
362 - </ComposerBanner.Icon>
363 - <ComposerBanner.Content className="text-foreground/80">
364 - {isEditing ? <span className="sr-only">Editing queued message: </span> : null}
365 - {item.pending ? (
366 - <Clock3Icon
367 - aria-label="Saving queued message"
368 - className="size-3 shrink-0 text-muted-foreground/60"
369 - />
370 - ) : null}
371 - {item.thumbnails.length > 0 ? (
372 - <span className="flex shrink-0 items-center gap-0.5">
373 - {item.thumbnails.map((thumbnail) => (
345 + {thumbnail.url ? (
346 + <img
347 + src={thumbnail.url}
348 + alt={thumbnail.name}
349 + className="size-full object-cover"
350 + />
351 + ) : (
352 <span
375 - key={thumbnail.key}
376 - className="size-4 overflow-hidden rounded border border-border/70 bg-background"
377 - >
378 - {thumbnail.url ? (
379 - <img
380 - src={thumbnail.url}
381 - alt={thumbnail.name}
382 - className="size-full object-cover"
383 - />
384 - ) : (
385 - <span
386 - aria-label={thumbnail.name}
387 - className="block size-full bg-muted/60"
388 - />
389 - )}
390 - </span>
391 - ))}
353 + aria-label={thumbnail.name}
354 + className="block size-full bg-muted/60"
355 + />
356 + )}
357 </span>
393 - ) : null}
358 + ))}
359 + </span>
360 + ) : null}
361 + {/* In full, like a sent turn: a queued message is read before it is sent. */}
362 + {previewText ? (
363 + <p className="whitespace-pre-wrap wrap-anywhere">
364 {item.guestName === undefined ? null : (
395 - <span className="shrink-0 text-guest-foreground">{item.guestName}</span>
365 + <span className="text-guest-foreground">{item.guestName} </span>
366 )}
367 + {previewText}
368 + </p>
369 + ) : null}
370 + </div>
371 + <div className="flex items-center gap-0.5 pe-1 text-xs text-muted-foreground">
372 + {items.length > 1 && canReorder && rowRunId !== null && rowServerIndex !== null ? (
373 + <Button
374 + size="icon-xs"
375 + variant="ghost-muted"
376 + aria-label={`Reorder queued message ${position + 1} of ${items.length} (drag, or press the arrow keys)`}
377 + className="group/grip cursor-grab active:cursor-grabbing"
378 + // Not `disabled`: that drops keyboard focus mid-move and breaks repeated arrow presses.
379 + aria-disabled={busyRunId !== null || undefined}
380 + onPointerDown={() => {
381 + if (busyRunId === null) dragArmedRunIdRef.current = rowRunId;
382 + }}
383 + onKeyDown={(event) => {
384 + if (busyRunId !== null) return;
385 + if (event.key === "ArrowUp" && rowServerIndex > 0) {
386 + event.preventDefault();
387 + void move(rowRunId, queued[rowServerIndex - 1]?.run.id ?? null);
388 + }
389 + if (event.key === "ArrowDown" && rowServerIndex < queued.length - 1) {
390 + event.preventDefault();
391 + // Moving into the collapsed rows would unmount the focused grip.
392 + if (rowServerIndex + 1 >= visibleItems.length) setShowAll(true);
393 + void move(rowRunId, queued[rowServerIndex + 2]?.run.id ?? null);
394 + }
395 + }}
396 + >
397 + <span className="text-xs font-medium tabular-nums group-hover/queued:hidden group-focus-visible/grip:hidden">
398 + {position + 1}
399 + </span>
400 + <GripVerticalIcon className="hidden group-hover/queued:block group-focus-visible/grip:block" />
401 + </Button>
402 + ) : items.length > 1 ? (
403 + <span className="px-1.5 font-medium tabular-nums">{position + 1}</span>
404 + ) : null}
405 + {item.pending ? (
406 + <span className="flex items-center gap-1 px-1">
407 + <Clock3Icon aria-hidden className="size-3" />
408 + Saving
409 + </span>
410 + ) : null}
411 + {isEditing ? (
412 + <>
413 + <span className="px-1 text-foreground">Editing in the composer</span>
414 + <Button
415 + size="xs"
416 + variant="ghost"
417 + aria-label="Cancel editing queued message"
418 + onClick={props.onCancelEdit}
419 + >
420 + Cancel
421 + </Button>
422 + </>
423 + ) : (
424 + <>
425 <Tooltip>
398 - <TooltipTrigger render={<span className="min-w-0 flex-1 truncate" />}>
399 - {previewText}
426 + {/* The span keeps the tooltip, and its reason, on a disabled button. */}
427 + <TooltipTrigger render={<span className="flex shrink-0" />}>
428 + <Button
429 + size="icon-xs"
430 + variant="ghost-muted"
431 + aria-label="Edit queued message"
432 + disabled={
433 + item.runId === null ||
434 + !item.editable ||
435 + busyRunId !== null ||
436 + props.editBlockedReason !== null
437 + }
438 + onClick={() => {
439 + if (item.runId !== null && item.messageId !== null) {
440 + props.onEditQueuedRun({
441 + runId: item.runId,
442 + messageId: item.messageId,
443 + text: item.text,
444 + attachments: item.attachments,
445 + });
446 + }
447 + }}
448 + >
449 + <PencilIcon />
450 + </Button>
451 </TooltipTrigger>
401 - <TooltipPopup side="top" className="max-w-96 break-words">
402 - {previewText}
452 + <TooltipPopup>
453 + {props.editBlockedReason ??
454 + `Edit in the composer${item.serverIndex === queued.length - 1 && props.editShortcutLabel ? ` (${props.editShortcutLabel})` : ""}`}
455 </TooltipPopup>
456 </Tooltip>
405 - </ComposerBanner.Content>
406 - <ComposerBanner.Actions>
407 - {isEditing ? (
408 - <Button
409 - size="xs"
410 - variant="ghost"
411 - aria-label="Cancel editing queued message"
412 - onClick={props.onCancelEdit}
413 - >
414 - Cancel
415 - </Button>
416 - ) : (
417 - <>
418 - <Tooltip>
419 - {/* The span keeps the tooltip, and its reason, on a disabled button. */}
420 - <TooltipTrigger render={<span className="flex shrink-0" />}>
421 - <Button
422 - size="icon-xs"
423 - variant="ghost-muted"
424 - aria-label="Edit queued message"
425 - disabled={
426 - item.runId === null ||
427 - !item.editable ||
428 - busyRunId !== null ||
429 - props.editBlockedReason !== null
430 - }
431 - onClick={() => {
432 - if (item.runId !== null && item.messageId !== null) {
433 - props.onEditQueuedRun({
434 - runId: item.runId,
435 - messageId: item.messageId,
436 - text: item.text,
437 - attachments: item.attachments,
438 - });
439 - }
440 - }}
441 - >
442 - <PencilIcon />
443 - </Button>
444 - </TooltipTrigger>
445 - <TooltipPopup>
446 - {props.editBlockedReason ??
447 - `Edit in the composer${item.serverIndex === queued.length - 1 && props.editShortcutLabel ? ` (${props.editShortcutLabel})` : ""}`}
448 - </TooltipPopup>
449 - </Tooltip>
450 - <Tooltip>
451 - <TooltipTrigger render={<span className="flex shrink-0" />}>
452 - <Button
453 - size="xs"
454 - variant="ghost-muted"
455 - disabled={item.runId === null || busyRunId !== null || !canSend}
456 - onClick={() => {
457 - if (item.runId !== null) {
458 - void sendQueuedMessage(item.runId);
459 - }
460 - }}
461 - >
462 - <CornerUpRightIcon />
463 - {workflow?.canSendNow ? "Send now" : "Steer"}
464 - </Button>
465 - </TooltipTrigger>
466 - <TooltipPopup>
467 - {`${workflow?.canSendNow ? "Start a turn with this message" : "Send as a steer instead"}${item.serverIndex === 0 && props.steerShortcutLabel ? ` (${props.steerShortcutLabel})` : ""}`}
468 - </TooltipPopup>
469 - </Tooltip>
470 - <Tooltip>
471 - <TooltipTrigger
472 - render={
473 - <ComposerBanner.Dismiss
474 - aria-label="Remove queued message"
475 - disabled={item.runId === null || busyRunId !== null}
476 - onClick={() => {
477 - if (item.runId !== null) void remove(item.runId);
478 - }}
479 - />
457 + <Tooltip>
458 + <TooltipTrigger render={<span className="flex shrink-0" />}>
459 + <Button
460 + size="xs"
461 + variant="ghost-muted"
462 + disabled={item.runId === null || busyRunId !== null || !canSend}
463 + onClick={() => {
464 + if (item.runId !== null) {
465 + void sendQueuedMessage(item.runId);
466 }
467 + }}
468 + >
469 + <CornerUpRightIcon />
470 + {workflow?.canSendNow ? "Send now" : "Steer"}
471 + </Button>
472 + </TooltipTrigger>
473 + <TooltipPopup>
474 + {`${workflow?.canSendNow ? "Start a turn with this message" : "Send as a steer instead"}${item.serverIndex === 0 && props.steerShortcutLabel ? ` (${props.steerShortcutLabel})` : ""}`}
475 + </TooltipPopup>
476 + </Tooltip>
477 + <Tooltip>
478 + <TooltipTrigger
479 + render={
480 + <Button
481 + size="icon-xs"
482 + variant="ghost-muted"
483 + aria-label="Remove queued message"
484 + disabled={item.runId === null || busyRunId !== null}
485 + onClick={() => {
486 + if (item.runId !== null) void remove(item.runId);
487 + }}
488 />
482 - <TooltipPopup>Remove from queue</TooltipPopup>
483 - </Tooltip>
484 - </>
485 - )}
486 - </ComposerBanner.Actions>
487 - </ComposerBanner.Row>
488 - );
489 - })}
490 - </ComposerBanner.Children>
491 - </ComposerBanner.Scroll>
492 - </ComposerBanner.Root>
493 - </ComposerBanner.Attachment>
489 + }
490 + >
491 + <XIcon />
492 + </TooltipTrigger>
493 + <TooltipPopup>Remove from queue</TooltipPopup>
494 + </Tooltip>
495 + </>
496 + )}
497 + </div>
498 + </li>
499 + );
500 + })}
501 + </ol>
502 + {collapsible ? (
503 + <div className="self-end pe-1 text-xs pointer-coarse:[&_[data-slot=inline-button]]:relative pointer-coarse:[&_[data-slot=inline-button]]:after:absolute pointer-coarse:[&_[data-slot=inline-button]]:after:-inset-x-1.5 pointer-coarse:[&_[data-slot=inline-button]]:after:-inset-y-3.5">
504 + <InlineButton
505 + tone="muted"
506 + aria-expanded={showAll}
507 + aria-controls={queueListId}
508 + // Keep the composer focused; keyboard activation still works.
509 + onPointerDown={(event) => event.preventDefault()}
510 + onClick={() => setShowAll((value) => !value)}
511 + >
512 + {showAll ? "Show fewer" : `Show all ${items.length} queued`}
513 + <ChevronDownIcon
514 + aria-hidden
515 + className={cn(
516 + "size-3.5 transition-transform duration-150 motion-reduce:transition-none",
517 + showAll && "rotate-180",
518 + )}
519 + />
520 + </InlineButton>
521 + </div>
522 + ) : null}
523 + </section>
524 );
525 }
apps/web/src/components/chat/ThreadActivityBanners.tsx
+32 -35
@@ -15,21 +15,25 @@ 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 +import type { ThreadNowItem } from "./ThreadNow";
19
20 /** Subagents waiting on the user, unless the parent is itself waiting on them. */
20 -export function childInputBannerItem(input: {
21 +export function childInputNowItem(input: {
22 readonly childThreadInputs: ReadonlyArray<EnvironmentThreadShell>;
23 readonly parentAwaitingUser: boolean;
24 readonly onOpenThread: (threadId: ThreadId) => void;
24 -}): ComposerBannerStackItem | null {
25 +}): ThreadNowItem | null {
26 const { childThreadInputs, onOpenThread } = input;
27 const first = childThreadInputs[0];
28 if (!first || input.parentAwaitingUser) return null;
29 return {
30 id: `child-input:${first.id}`,
30 - variant: "info",
31 - priority: "activity",
32 - icon: first.hasPendingApprovals ? <ShieldQuestionIcon /> : <MessageCircleIcon />,
31 + // The only line at the end of the timeline that needs you gets the info color.
32 + icon: first.hasPendingApprovals ? (
33 + <ShieldQuestionIcon className="text-info-foreground" />
34 + ) : (
35 + <MessageCircleIcon className="text-info-foreground" />
36 + ),
37 title: childThreadInputsTitle(childThreadInputs),
38 description: childThreadInputs.map((child, index) => (
39 <Fragment key={child.id}>
@@ -43,25 +47,24 @@ export function childInputBannerItem(input: {
47 </Fragment>
48 )),
49 actions: (
46 - <Button size="xs" variant="ghost" onClick={() => onOpenThread(first.id)}>
50 + <InlineButton onClick={() => onOpenThread(first.id)}>
51 {first.hasPendingApprovals ? "Open approval" : "Open question"}
48 - </Button>
52 + </InlineButton>
53 ),
54 };
55 }
56
53 -export function goalBannerItem(input: {
57 +/** The thread's goal, for the end of the timeline. */
58 +export function goalNowItem(input: {
59 readonly threadId: ThreadId;
60 readonly goal: OrchestrationV2ProviderGoal;
61 readonly isWorking: boolean;
62 readonly onSendCommand: (text: string, failureMessage: string) => Promise<void>;
58 -}): ComposerBannerStackItem {
63 +}): ThreadNowItem {
64 const { isWorking, onSendCommand } = input;
65 const presentation = presentProviderGoal(input.goal, isWorking);
66 return {
67 id: `goal:${input.threadId}`,
63 - variant: "default",
64 - priority: "activity",
68 icon: <TargetIcon />,
69 title:
70 presentation.usage === null
@@ -72,46 +75,45 @@ export function goalBannerItem(input: {
75 actions: (
76 <>
77 {presentation.canResume && !isWorking ? (
75 - <Button
76 - size="xs"
77 - variant="ghost"
78 - onClick={() => void onSendCommand("/goal resume", "Failed to resume goal.")}
79 - >
80 - Resume
81 - </Button>
78 + <>
79 + <InlineButton
80 + onClick={() => void onSendCommand("/goal resume", "Failed to resume goal.")}
81 + >
82 + Resume
83 + </InlineButton>
84 + <span aria-hidden>·</span>
85 + </>
86 ) : null}
83 - <Button
84 - size="xs"
85 - variant="ghost"
87 + <InlineButton
88 + tone="muted"
89 onClick={() => void onSendCommand("/goal clear", "Failed to clear goal.")}
90 >
91 Clear
89 - </Button>
92 + </InlineButton>
93 </>
94 ),
95 };
96 }
97
95 -export function backgroundWorkBannerItem(input: {
98 +/** Background commands and subagents, for the end of the timeline. */
99 +export function backgroundWorkNowItem(input: {
100 readonly threadId: ThreadId;
101 readonly tasks: ReadonlyArray<OrchestrationV2PendingBackgroundTask>;
102 readonly stopDisabled: boolean;
103 readonly stopping: boolean;
104 readonly onStop: () => Promise<void>;
105 readonly onOpenThread: (threadId: ThreadId) => void;
102 -}): ComposerBannerStackItem | null {
106 +}): ThreadNowItem | null {
107 const { onOpenThread } = input;
108 const presentation = presentPendingBackgroundWork(input.tasks);
109 if (presentation === null) return null;
110 return {
111 id: `background-work:${input.threadId}`,
108 - variant: "default",
109 - priority: "activity",
112 icon: (
113 <span
114 className={cn(
113 - "size-1.5 rounded-full bg-foreground",
114 - presentation.waiting && "motion-safe:animate-status-pulse",
115 + "size-1.5 rounded-full",
116 + presentation.waiting ? "bg-foreground" : "bg-muted-foreground",
117 )}
118 aria-hidden="true"
119 />
@@ -147,14 +149,9 @@ export function backgroundWorkBannerItem(input: {
149 );
150 }),
151 actions: (
150 - <Button
151 - size="xs"
152 - variant="ghost"
153 - disabled={input.stopDisabled}
154 - onClick={() => void input.onStop()}
155 - >
152 + <InlineButton disabled={input.stopDisabled} onClick={() => void input.onStop()}>
153 {input.stopping ? "Stopping..." : "Stop"}
157 - </Button>
154 + </InlineButton>
155 ),
156 };
157 }
apps/web/src/components/chat/ThreadNow.tsx new
+104
@@ -0,0 +1,104 @@
1 +import { RefreshCwIcon } from "lucide-react";
2 +import type { ReactNode } from "react";
3 +
4 +import { threadSyncLabel, type ThreadSyncPhase } from "../../threadSync";
5 +import { cn } from "~/lib/utils";
6 +import { NoticeText } from "./ComposerBannerStack";
7 +
8 +/** A line of thread state for the end of the timeline. */
9 +export interface ThreadNowItem {
10 + readonly id: string;
11 + readonly icon: ReactNode;
12 + readonly title: ReactNode;
13 + readonly description?: ReactNode;
14 + readonly actions?: ReactNode;
15 +}
16 +
17 +/** Matches ThreadStatusLine, so every line at the end of the timeline reads as one family. */
18 +const lineClassName = cn(
19 + "mx-auto flex w-full min-w-0 max-w-(--chat-content-max-width) items-center gap-1.5 px-1 pb-2 text-xs text-muted-foreground [&_svg]:size-3.5 [&_svg]:shrink-0",
20 + // A details button must not make its line taller than the others.
21 + "[&_[data-slot=popover-trigger]]:-my-1.5",
22 + // Inline actions keep their text size but get a finger-sized hit area on touch.
23 + "pointer-coarse:[&_[data-slot=inline-button]]:relative pointer-coarse:[&_[data-slot=inline-button]]:after:absolute pointer-coarse:[&_[data-slot=inline-button]]:after:-inset-x-1.5 pointer-coarse:[&_[data-slot=inline-button]]:after:-inset-y-3.5",
24 + "transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none",
25 +);
26 +
27 +/** One line of thread state at the end of the timeline: icon, title, detail, then actions. */
28 +function ThreadNowLine({
29 + item,
30 + announce = false,
31 +}: {
32 + readonly item: ThreadNowItem;
33 + /** Announces the line when it appears; only for something that needs the user. */
34 + readonly announce?: boolean;
35 +}) {
36 + return (
37 + <div
38 + role={announce ? "alert" : undefined}
39 + className={lineClassName}
40 + data-thread-now-line="true"
41 + >
42 + <span aria-hidden className="flex size-3.5 shrink-0 items-center justify-center">
43 + {item.icon}
44 + </span>
45 + {/* Title and detail read as one line that gives way before the actions, so Stop stays
46 + reachable; when it is cut, its details button shows all of it. */}
47 + <NoticeText
48 + detailsLabel={
49 + typeof item.title === "string" ? `Show details: ${item.title}` : "Show details"
50 + }
51 + className="min-w-0 truncate"
52 + >
53 + {item.title}
54 + {item.description ? (
55 + <>
56 + {" "}
57 + <span aria-hidden>·</span> {item.description}
58 + </>
59 + ) : null}
60 + </NoticeText>
61 + {item.actions ? (
62 + <>
63 + <span aria-hidden>·</span>
64 + <span className="flex shrink-0 items-center gap-1.5">{item.actions}</span>
65 + </>
66 + ) : null}
67 + </div>
68 + );
69 +}
70 +
71 +function ThreadSyncLine({ phase }: { readonly phase: ThreadSyncPhase }) {
72 + return (
73 + <div className={lineClassName} role="status" data-composer-sync-status={phase}>
74 + <RefreshCwIcon aria-hidden />
75 + <span className="truncate">{threadSyncLabel(phase)}</span>
76 + </div>
77 + );
78 +}
79 +
80 +/**
81 + * What the thread is doing now, at the end of the timeline: what needs you, background work,
82 + * the sync status while messages load, then the goal.
83 + */
84 +export function ThreadNow({
85 + attention,
86 + work,
87 + syncPhase,
88 + goal,
89 +}: {
90 + /** Something that needs you elsewhere, such as a subagent's question. */
91 + readonly attention: ThreadNowItem | null;
92 + readonly work: ThreadNowItem | null;
93 + readonly syncPhase: ThreadSyncPhase | null;
94 + readonly goal: ThreadNowItem | null;
95 +}): ReactNode {
96 + return (
97 + <>
98 + {attention ? <ThreadNowLine item={attention} announce /> : null}
99 + {work ? <ThreadNowLine item={work} /> : null}
100 + {syncPhase ? <ThreadSyncLine phase={syncPhase} /> : null}
101 + {goal ? <ThreadNowLine item={goal} /> : null}
102 + </>
103 + );
104 +}
apps/web/src/components/chat/TimelineOverlays.tsx
+12 -2
@@ -19,9 +19,13 @@ export function WorkspaceFileDropOverlay() {
19 );
20 }
21
22 -/** Sits `bottom` pixels up, clear of the composer and its attached banners. */
22 +/**
23 + * Sits `bottom` pixels up, clear of the composer and its attached banners. The summary names
24 + * what waits at the end of the timeline, which is out of view while it shows.
25 + */
26 export function ScrollToEndButton(props: {
27 readonly bottom: number;
28 + readonly summary: string | null;
29 readonly onScrollToEnd: () => void;
30 }) {
31 return (
@@ -30,7 +34,7 @@ export function ScrollToEndButton(props: {
34 style={{ bottom: props.bottom }}
35 >
36 <Button
33 - aria-label="Scroll to end"
37 + data-scroll-to-end="true"
38 onPointerDown={(event) => event.preventDefault()}
39 onClick={props.onScrollToEnd}
40 className="pointer-events-auto"
@@ -39,6 +43,12 @@ export function ScrollToEndButton(props: {
43 >
44 <ChevronDownIcon className="size-3.5" />
45 Scroll to end
46 + {props.summary === null ? null : (
47 + <span className="text-muted-foreground">
48 + <span aria-hidden>· </span>
49 + {props.summary}
50 + </span>
51 + )}
52 </Button>
53 </div>
54 );
apps/web/src/components/chat/TimelineToolActivityIcon.tsx
+4
@@ -11,6 +11,7 @@ import {
11 CircleAlertIcon,
12 EyeIcon,
13 GlobeIcon,
14 + ListTodoIcon,
15 MessageCircleIcon,
16 SearchIcon,
17 SmartphoneIcon,
@@ -37,6 +38,7 @@ export type WorkEntryIconName =
38 | "brain"
39 | "browser"
40 | "check"
41 + | "list-todo"
42 | "circle-alert"
43 | "computer"
44 | "code"
@@ -246,6 +248,8 @@ function WorkEntryIcon({ name, className }: { name: WorkEntryIconName; className
248 return <T3Wordmark className={className} aria-hidden />;
249 case "check":
250 return <CheckIcon className={className} aria-hidden />;
251 + case "list-todo":
252 + return <ListTodoIcon className={className} aria-hidden />;
253 case "circle-alert":
254 return <CircleAlertIcon className={className} aria-hidden />;
255 case "eye":
apps/web/src/components/chat/TimelineWorkEntryRow.logic.ts
+1
@@ -167,6 +167,7 @@ export function workEntryIconName(workEntry: TimelineWorkEntry): WorkEntryIconNa
167 if (workEntry.itemType === "user_input_request" || workEntry.itemType === "approval_request") {
168 return "message-circle";
169 }
170 + if (workEntry.itemType === "todo_list") return "list-todo";
171 if (workEntry.toolSurface) return workEntry.toolSurface;
172 if (
173 workEntry.structuredPayload?.type === "dynamic_tool" &&
apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx
-1
@@ -29,7 +29,6 @@ export function usageLimitRecoveryBannerItem(props: RecoveryProps): ComposerBann
29 return {
30 id: `usage-limit-recovery:${runId}`,
31 variant: "warning",
32 - priority: "urgent",
32 icon: <GaugeIcon />,
33 title: "Usage limit reached",
34 description: resetAt
apps/web/src/components/chat/V2ItemInspector.tsx
+4 -1
@@ -415,7 +415,10 @@ export const V2ItemInspector = memo(function V2ItemInspector(props: V2ItemInspec
415 {item.type === "todo_list" ? (
416 <StructuredValue
417 value={item.steps
418 - .map((step) => `${step.status === "completed" ? "✓" : "○"} ${step.text}`)
418 + .map(
419 + (step) =>
420 + `${step.status === "completed" ? "✓" : step.status === "running" ? "◉" : "○"} ${step.text}`,
421 + )
422 .join("\n")}
423 />
424 ) : null}
apps/web/src/components/chat/useAutoBalanceUpdateBanner.tsx
+1 -1
@@ -89,7 +89,7 @@ export function useAutoBalanceUpdateBanner(
89 return {
90 id: `auto-balance-server-updates-${dismissedNotices.size}`,
91 variant: failed ? "error" : "default",
92 - priority: running ? "urgent" : "notice",
92 + group: "environment",
93 icon: <ComposerServerUpdateIcon status={status} />,
94 title: (
95 <Popover>
apps/web/src/components/chat/useProjectCloneBanner.tsx
-1
@@ -77,7 +77,6 @@ export function useProjectCloneBanner(activeProjectRef: ScopedProjectRef | null)
77 return {
78 id: `project-clone:${projectId}`,
79 variant: "info",
80 - priority: "activity",
80 icon: <DownloadIcon />,
81 title: `Cloning ${name}`,
82 description: projectCloneProgressSummary(activeProjectClone),
apps/web/src/components/chat/useSystemComposerBanners.tsx
+21 -65
@@ -23,19 +23,14 @@ import type { ComposerBannerStackItem } from "./ComposerBannerStack";
23 import { ENVIRONMENT_RECONNECT_WARNING_GRACE_MS } from "../ChatView.logic";
24 import { useAtomCommand } from "../../state/use-atom-command";
25 import { Button } from "../ui/button";
26 -import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
26 import { ServerUpdateAction, serverUpdateStageLabel } from "../ServerUpdateAction";
27 import { useAutoBalanceUpdateBanner } from "./useAutoBalanceUpdateBanner";
28 import { ComposerServerUpdateIcon } from "./ComposerServerUpdateStatus";
29 import {
31 - buildVersionMismatchDismissalKey,
30 dismissServerUpdateFailure,
33 - dismissVersionMismatch,
31 isServerUpdateFailureDismissed,
35 - isVersionMismatchDismissed,
32 resolveServerConfigVersionMismatch,
33 resolveServerSelfUpdateCapability,
38 - serverUpdateGuidance,
34 supportsDesktopAppUpdate,
35 supportsServerUpdateThreadContinuation,
36 } from "../../versionSkew";
@@ -138,18 +133,6 @@ export function useSystemComposerBanners(input: SystemComposerBannersInput) {
133 );
134 const autoBalanceUpdateBanner = useAutoBalanceUpdateBanner(autoUpdateEnvironments);
135 const versionMismatch = resolveServerConfigVersionMismatch(serverConfig);
141 - const versionMismatchDismissKey =
142 - versionMismatch && activeThreadEnvironmentId !== null
143 - ? buildVersionMismatchDismissalKey(activeThreadEnvironmentId, versionMismatch)
144 - : null;
145 - const [dismissedVersionMismatchKey, setDismissedVersionMismatchKey] = useState<string | null>(
146 - null,
147 - );
148 - const versionMismatchDismissed =
149 - versionMismatchDismissKey === dismissedVersionMismatchKey ||
150 - isVersionMismatchDismissed(versionMismatchDismissKey);
151 - const showVersionMismatchBanner =
152 - versionMismatch !== null && versionMismatchDismissKey !== null && !versionMismatchDismissed;
136 const versionMismatchServerLabel =
137 hasMultipleRegisteredEnvironments && activeThreadEnvironmentId !== null
138 ? `${activeEnvironment?.label ?? serverConfig?.environment.label ?? activeThreadEnvironmentId} server`
@@ -194,10 +177,15 @@ export function useSystemComposerBanners(input: SystemComposerBannersInput) {
177 unavailableConnection.phase === "reconnecting");
178 const suppressUnavailableBanner =
179 environmentReconnecting && (updateRunning || !reconnectWarningGraceElapsed);
197 - if (activeEnvironmentUnavailableState && unavailableConnection && !suppressUnavailableBanner) {
180 + const showUnavailableBanner =
181 + activeEnvironmentUnavailableState !== null &&
182 + unavailableConnection !== null &&
183 + !suppressUnavailableBanner;
184 + if (showUnavailableBanner) {
185 items.push({
186 id: `environment-unavailable:${activeEnvironmentUnavailableState.environmentId}`,
187 variant: unavailableConnection.phase === "error" ? "error" : "warning",
188 + group: "environment",
189 icon: <WifiOffIcon />,
190 title: `${activeEnvironmentUnavailableState.label} is ${environmentReconnecting ? "reconnecting" : "offline"}`,
191 description: activeEnvironment ? (
@@ -223,54 +211,26 @@ export function useSystemComposerBanners(input: SystemComposerBannersInput) {
211 ),
212 });
213 }
214 + // An available update is offered by the sidebar's update pill; the composer only shows one
215 + // that is running or failed, since either explains what this thread's server is doing.
216 if (
217 !automaticEnvironment &&
218 serverUpdateEnvironmentId &&
229 - (serverUpdateState.status === "idle"
230 - ? showVersionMismatchBanner
231 - : !serverUpdateFailureDismissed)
219 + serverUpdateState.status !== "idle" &&
220 + !serverUpdateFailureDismissed
221 ) {
233 - const updateInProgress = serverUpdateState.status === "running";
222 const updateFailed = serverUpdateState.status === "failed";
223 items.push({
224 id: `server-version:${serverUpdateEnvironmentId}`,
225 variant: updateFailed ? "error" : "default",
238 - priority: updateInProgress ? "urgent" : "notice",
226 + group: "environment",
227 icon: <ComposerServerUpdateIcon status={serverUpdateState.status} />,
240 - title:
241 - updateInProgress || updateFailed ? (
242 - `${updateFailed ? "Could not update" : "Updating"} ${versionMismatchServerLabel}`
243 - ) : versionMismatch ? (
244 - <Tooltip>
245 - <TooltipTrigger
246 - render={
247 - <button
248 - type="button"
249 - className="block max-w-full cursor-help truncate rounded-sm text-left"
250 - >
251 - Server update available
252 - </button>
253 - }
254 - />
255 - <TooltipPopup side="top">
256 - {versionMismatchServerLabel} {versionMismatch.serverVersion}{" "}
257 - <span aria-hidden="true">→</span> {versionMismatch.clientVersion}
258 - </TooltipPopup>
259 - </Tooltip>
260 - ) : (
261 - "Server update available"
262 - ),
228 + title: `${updateFailed ? "Could not update" : "Updating"} ${versionMismatchServerLabel}`,
229 description:
230 serverUpdateState.status === "failed"
231 ? serverUpdateState.message
266 - : serverUpdateState.status === "running"
267 - ? serverUpdateStageLabel(serverUpdateState.stage)
268 - : versionMismatchSelfUpdate !== null &&
269 - (versionMismatchSelfUpdate !== "desktop-managed" ||
270 - !versionMismatchDesktopAppUpdate)
271 - ? serverUpdateGuidance(versionMismatchSelfUpdate)
272 - : undefined,
273 - actions: updateInProgress ? (
232 + : serverUpdateStageLabel(serverUpdateState.stage),
233 + actions: !updateFailed ? (
234 disconnectAction
235 ) : !versionMismatch ||
236 (versionMismatchSelfUpdate === "desktop-managed" &&
@@ -283,23 +243,19 @@ export function useSystemComposerBanners(input: SystemComposerBannersInput) {
243 desktopAppUpdate={versionMismatchDesktopAppUpdate}
244 threadContinuation={versionMismatchThreadContinuation}
245 targetVersion={versionMismatch.clientVersion}
286 - label={updateFailed ? "Retry" : "Update"}
246 + label="Retry"
247 variant="ghost"
248 />
249 ),
290 - ...(updateInProgress || (!updateFailed && !versionMismatchDismissKey)
291 - ? {}
292 - : {
250 + ...(updateFailed
251 + ? {
252 dismissLabel: "Dismiss update notice",
253 onDismiss: () => {
295 - if (updateFailed) {
296 - dismissServerUpdateFailure(serverUpdateState);
297 - setDismissedServerUpdateState(serverUpdateState);
298 - }
299 - dismissVersionMismatch(versionMismatchDismissKey);
300 - setDismissedVersionMismatchKey(versionMismatchDismissKey);
254 + dismissServerUpdateFailure(serverUpdateState);
255 + setDismissedServerUpdateState(serverUpdateState);
256 },
302 - }),
257 + }
258 + : {}),
259 });
260 }
261 if (autoBalanceUpdateBanner) items.push(autoBalanceUpdateBanner);
apps/web/src/components/chat/useThreadLifecycle.tsx
+10 -14
@@ -58,11 +58,7 @@ import { appAtomRegistry } from "../../rpc/atomRegistry";
58 import { readEnvironmentScope } from "../../state/session";
59 import { useAtomCommand } from "../../state/use-atom-command";
60 import { useOrchestrationCommand } from "../../state/use-orchestration-command";
61 -import {
62 - backgroundWorkBannerItem,
63 - childInputBannerItem,
64 - goalBannerItem,
65 -} from "./ThreadActivityBanners";
61 +import { backgroundWorkNowItem, childInputNowItem, goalNowItem } from "./ThreadActivityBanners";
62 import type { useLocalDispatchState } from "./useLocalDispatchState";
63 const RELATED_THREAD_SHELL_WAIT_MS = 1_000;
64
@@ -85,7 +81,7 @@ interface ThreadLifecycleInput {
81 readonly serverConfig: EnvironmentServerConfig | null;
82 readonly runtimeMode: RuntimeMode;
83 readonly isWorking: boolean;
88 - readonly pendingBackgroundTasks: Parameters<typeof backgroundWorkBannerItem>[0]["tasks"];
84 + readonly pendingBackgroundTasks: Parameters<typeof backgroundWorkNowItem>[0]["tasks"];
85 readonly activePendingApproval: PendingThreadRequests["activePendingApproval"];
86 readonly activePendingUserInput: PendingThreadRequests["activePendingUserInput"];
87 readonly localCheckoutBranchMismatch: {
@@ -433,7 +429,7 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
429 };
430 const onOpenRelatedThreadStable = useStableCallback(onOpenRelatedThread);
431 const childThreadInputs = useChildThreadInputs(activeThreadRef);
436 - const childInputBanner = childInputBannerItem({
432 + const childInputNow = childInputNowItem({
433 childThreadInputs,
434 parentAwaitingUser: Boolean(
435 activePendingApproval || activePendingUserInput || activeThreadShell?.hasPendingUserInput,
@@ -503,9 +499,9 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
499 };
500 const sendStandaloneCommandStable = useStableCallback(sendStandaloneCommand);
501 const activeGoal = activeThreadShell?.goal ?? null;
506 - const goalBanner =
502 + const goalNow =
503 activeThread && activeGoal !== null
508 - ? goalBannerItem({
504 + ? goalNowItem({
505 threadId: activeThread.id,
506 goal: activeGoal,
507 isWorking,
@@ -513,8 +509,8 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
509 })
510 : null;
511
516 - const backgroundWorkBanner = activeThread
517 - ? backgroundWorkBannerItem({
512 + const backgroundWorkNow = activeThread
513 + ? backgroundWorkNowItem({
514 threadId: activeThread.id,
515 tasks: activeBackgroundTasks,
516 stopDisabled: !canOperateThread || isStoppingBackgroundWork,
@@ -595,9 +591,9 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
591 shortcuts,
592 acknowledgeActiveThreadWoke,
593 activeBranchMismatchKey,
598 - backgroundWorkBanner,
599 - childInputBanner,
600 - goalBanner,
594 + backgroundWorkNow,
595 + childInputNow,
596 + goalNow,
597 handleSwitchCheckoutToThread,
598 handleSwitchCheckoutToThreadStable,
599 isRestoringThreadBranch,
apps/web/src/components/chat/useTimelineFollow.ts
+16
@@ -355,6 +355,15 @@ export function useTimelineFollow(input: TimelineFollowInput) {
355 });
356 };
357 const scrollToEndStable = useStableCallback(scrollToEnd);
358 + // The list does not follow footer layout, so the resting composer cannot scroll it. Growth
359 + // above the composer (a new notice) would cover the last rows instead.
360 + const followedInsetRef = useRef(composerTimelineInset);
361 + // oxlint-disable-next-line t3code/react-effect-budget -- scrolls the list after its bottom inset grows
362 + useLayoutEffect(() => {
363 + const grew = composerTimelineInset > followedInsetRef.current;
364 + followedInsetRef.current = composerTimelineInset;
365 + if (grew && readCurrentFollow().mode === "following") scrollToEndStable();
366 + }, [composerTimelineInset, readCurrentFollow, scrollToEndStable]);
367
368 const handleNavigation = (navigation: TimelineNavigation) => {
369 const composer = composerRef.current;
@@ -501,6 +510,12 @@ export function useTimelineFollow(input: TimelineFollowInput) {
510 composerRef.current?.restoreAfterTimelineReachedEnd();
511 };
512 const onToolOutputCollapsedAtEndStable = useStableCallback(onToolOutputCollapsedAtEnd);
513 + // The list ignores footer layout, so a new queued turn or status line there would land
514 + // under the composer. Follow it when the reader was following the end.
515 + const onTimelineFooterGrow = () => {
516 + if (readFollow().mode === "following") scrollToEndStable();
517 + };
518 + const onTimelineFooterGrowStable = useStableCallback(onTimelineFooterGrow);
519
520 const onIsAtEndChange = (isAtEnd: boolean) => {
521 const scroll = visitScroll();
@@ -578,6 +593,7 @@ export function useTimelineFollow(input: TimelineFollowInput) {
593 onTimelineAnchorReadyStable,
594 onTimelineAnchorSizeChangedStable,
595 onToolOutputCollapsedAtEndStable,
596 + onTimelineFooterGrowStable,
597 onIsAtEndChangeStable,
598 anchorNewTurn,
599 attachTimelineViewport,
apps/web/src/components/composerFooterLayout.test.ts
-29
@@ -29,35 +29,6 @@ describe("resolveComposerTimelineInset", () => {
29 }),
30 ).toBe(expanded);
31 });
32 -
33 - it("keeps the timeline reservation stable through notice expansion and collapse", () => {
34 - const collapsed = resolveComposerTimelineInset({
35 - currentInset: 0,
36 - overlayHeight: 172,
37 - isResting: false,
38 - });
39 - const expanded = resolveComposerTimelineInset({
40 - currentInset: collapsed,
41 - overlayHeight: 532,
42 - isResting: false,
43 - expandedNoticesHeight: 360,
44 - });
45 - expect(expanded).toBe(collapsed);
46 - const resting = resolveComposerTimelineInset({
47 - currentInset: expanded,
48 - overlayHeight: 470,
49 - isResting: true,
50 - expandedNoticesHeight: 360,
51 - });
52 - expect(resting).toBe(collapsed);
53 - expect(
54 - resolveComposerTimelineInset({
55 - currentInset: resting,
56 - overlayHeight: 110,
57 - isResting: true,
58 - }),
59 - ).toBe(collapsed);
60 - });
32 });
33
34 describe("context strip labels and resting composer controls", () => {
apps/web/src/components/composerFooterLayout.ts
+1 -4
@@ -55,11 +55,8 @@ export function resolveComposerTimelineInset(input: {
55 overlayHeight: number;
56 isResting: boolean;
57 restingOnlyHeight?: number;
58 - expandedNoticesHeight?: number;
58 }): number {
60 - // Expanded notices temporarily cover the timeline. Remove their growth before
61 - // rounding so fractional measurements reserve exactly the collapsed height.
62 - const overlayHeight = Math.ceil(input.overlayHeight - (input.expandedNoticesHeight ?? 0));
59 + const overlayHeight = Math.ceil(input.overlayHeight);
60 return input.isResting
61 ? Math.max(
62 input.currentInset,
apps/web/src/components/guest/GuestPage.tsx
+5 -1
@@ -488,7 +488,11 @@ function GuestThread({
488 }
489 />
490 {follow.showScrollToBottom ? (
491 - <ScrollToEndButton bottom={4} onScrollToEnd={() => follow.scrollToEnd(true)} />
491 + <ScrollToEndButton
492 + summary={null}
493 + bottom={4}
494 + onScrollToEnd={() => follow.scrollToEnd(true)}
495 + />
496 ) : null}
497 </div>
498 <div className={cn(LANE, "shrink-0 pb-4")}>
apps/web/src/performance.bench.ts
+1 -23
@@ -1,4 +1,4 @@
1 -import { NodeId, PlanId, ProjectId, RunId } from "@t3tools/contracts";
1 +import { ProjectId } from "@t3tools/contracts";
2 import {
3 getLatestThreadForProject,
4 sortActiveThreadsByOrderKey,
@@ -8,11 +8,7 @@ import {
8 import { formatHourShort, formatRelativeHourShort } from "@t3tools/shared/usageFormat";
9 import { describe, test } from "vite-plus/test";
10
11 -import { makeThreadProjectionFixture } from "./test-fixtures";
12 -import { deriveActivePlanState } from "./session-logic";
13 -
11 const projectId = ProjectId.make("benchmark-project");
15 -const runId = RunId.make("benchmark-run");
12 const start = Date.parse("2026-08-11T00:00:00.000Z");
13 const threads = Array.from({ length: 1_000 }, (_, index) => {
14 const timestamp = new Date(start + ((index * 997) % 1_000) * 60_000).toISOString();
@@ -26,19 +22,6 @@ const threads = Array.from({ length: 1_000 }, (_, index) => {
22 unsettledAt: null,
23 };
24 });
29 -const baseProjection = makeThreadProjectionFixture();
30 -const projection = {
31 - ...baseProjection,
32 - plans: Array.from({ length: 5 }, (_, index) => ({
33 - id: PlanId.make(`plan-${index}`),
34 - runId,
35 - threadId: baseProjection.thread.id,
36 - nodeId: NodeId.make("bench-node"),
37 - status: "active" as const,
38 - kind: "todo_list" as const,
39 - steps: [{ id: "check", text: "Run checks", status: "running" as const }],
40 - })),
41 -};
25 const hours = Array.from({ length: 24 }, (_, index) =>
26 new Date(start + index * 3_600_000).toISOString(),
27 );
@@ -65,11 +48,6 @@ describe("client performance", () => {
48 getLatestThreadForProject(threads, projectId, "updated_at");
49 }).run();
50 });
68 - test("derive current plan from 5 normalized plans", async ({ bench }) => {
69 - await bench("derive", () => {
70 - deriveActivePlanState(projection, runId);
71 - }).run();
72 - });
51 test("format 24 hourly usage labels and tooltips", async ({ bench }) => {
52 await bench("format", () => {
53 hours.map((hour) => [
apps/web/src/session-logic.test.ts
+12 -227
@@ -5,7 +5,6 @@ import {
5 CheckpointScopeId,
6 NodeId,
7 PlanId,
8 - ProviderDriverKind,
8 ProviderInstanceId,
9 ProviderThreadId,
10 RunAttemptId,
@@ -24,14 +23,12 @@ import * as DateTime from "effect/DateTime";
23 import { describe, expect, it } from "vite-plus/test";
24
25 import {
27 - deriveActivePlanState,
26 deriveCanInterruptRunningThread,
27 deriveTimelineEntriesFromVisibleTurnItems,
28 deriveTimelineEntriesFromVisibleTurnItemsWithState,
29 deriveRevertTurnCountByUserMessageId,
30 derivePhase,
31 isLatestRunSettled,
34 - selectComposerTasksPlan,
32 selectHandoffImageResources,
33 selectMessageImageResources,
34 createMessageAttachmentPreviewProjector,
@@ -465,7 +462,7 @@ describe("V2 session presentation", () => {
462 ...base("item-todo", 4),
463 type: "todo_list" as const,
464 planId: PlanId.make("plan-visible"),
468 - explanation: "Keep task detail in the Tasks panel",
465 + explanation: "Show task updates where the agent wrote them",
466 steps: [
467 { id: "step-1", text: "First", status: "completed" as const },
468 { id: "step-2", text: "Second", status: "pending" as const },
@@ -526,6 +523,7 @@ describe("V2 session presentation", () => {
523 ["event", requestItem.id],
524 ["work", commandItem.id],
525 ["event", resultItem.id],
526 + ["work", todoItem.id],
527 ["work", errorItem.id],
528 ["work", threadCreatedItem.id],
529 ]);
@@ -545,7 +543,7 @@ describe("V2 session presentation", () => {
543 expect(commandEntry.entry.command).toBe(commandItem.input);
544 expect(commandEntry.entry.detail).toBeUndefined();
545 }
548 - const errorEntry = entries[4];
546 + const errorEntry = entries[5];
547 expect(errorEntry?.kind).toBe("work");
548 if (errorEntry?.kind === "work") {
549 expect(errorEntry.entry.projectedItem).toBe(visibleTurnItems[5]);
@@ -554,7 +552,7 @@ describe("V2 session presentation", () => {
552 expect(errorEntry.entry.tone).toBe("info");
553 expect(errorEntry.entry.toolLifecycleStatus).toBe("failed");
554 }
557 - const threadCreatedEntry = entries[5];
555 + const threadCreatedEntry = entries[6];
556 expect(threadCreatedEntry?.kind).toBe("work");
557 if (threadCreatedEntry?.kind === "work") {
558 expect(threadCreatedEntry.entry.projectedItem?.item.type).toBe("thread_created");
@@ -562,7 +560,7 @@ describe("V2 session presentation", () => {
560 });
561
562 it.each(["pending", "running", "completed"] as const)(
565 - "keeps %s task progress available to the composer and out of the timeline",
563 + "shows a %s todo update in the timeline where the agent wrote it",
564 (stepStatus) => {
565 const projection = makeThreadProjectionFixture();
566 const now = DateTime.makeUnsafe("2026-09-04T00:00:00.000Z");
@@ -615,46 +613,17 @@ describe("V2 session presentation", () => {
613 optimisticMessages: [],
614 plans,
615 }),
618 - ).toEqual([]);
619 - expect(
620 - deriveActivePlanState({ ...projection, plans, turnItems: [item] }, runId),
621 - ).toMatchObject({
622 - runId,
623 - steps: [
624 - {
625 - step: "Verify the change",
626 - status: stepStatus === "running" ? "inProgress" : stepStatus,
616 + ).toMatchObject([
617 + {
618 + kind: "work",
619 + entry: {
620 + label: stepStatus === "completed" ? "Tasks 1/1" : "Tasks 0/1 · Verify the change",
621 },
628 - ],
629 - });
622 + },
623 + ]);
624 },
625 );
626
633 - it("preserves independently derived durations for repeated plan-step labels", () => {
634 - const projection = makeThreadProjectionFixture();
635 - const runId = RunId.make("run-timed-tasks");
636 - const planId = PlanId.make("plan-timed-tasks");
637 - const plan = {
638 - id: planId,
639 - threadId: projection.thread.id,
640 - runId,
641 - nodeId: NodeId.make("node-timed-tasks"),
642 - kind: "todo_list" as const,
643 - status: "active" as const,
644 - steps: [
645 - { id: "verify-a", text: "Verify", status: "completed" as const, durationMs: 3_000 },
646 - { id: "verify-b", text: "Verify", status: "completed" as const, durationMs: 4_000 },
647 - { id: "report", text: "Report", status: "pending" as const },
648 - ],
649 - };
650 -
651 - expect(deriveActivePlanState({ ...projection, plans: [plan] }, runId)?.steps).toEqual([
652 - { step: "Verify", status: "completed", durationMs: 3_000 },
653 - { step: "Verify", status: "completed", durationMs: 4_000 },
654 - { step: "Report", status: "pending" },
655 - ]);
656 - });
657 -
627 it("waits for a dispatched turn item before adding queued input to the timeline", () => {
628 const projection = makeThreadProjectionFixture();
629 const now = DateTime.makeUnsafe("2026-06-20T00:00:00.000Z");
@@ -1041,190 +1010,6 @@ describe("V2 session presentation", () => {
1010 });
1011 });
1012
1044 -describe("composer tasks drawer", () => {
1045 - const projection = makeThreadProjectionFixture();
1046 - const now = projection.updatedAt;
1047 -
1048 - function providerThread(id: string, driver: string) {
1049 - return {
1050 - id: ProviderThreadId.make(id),
1051 - driver: ProviderDriverKind.make(driver),
1052 - providerInstanceId: ProviderInstanceId.make(driver),
1053 - providerSessionId: null,
1054 - appThreadId: projection.thread.id,
1055 - ownerNodeId: null,
1056 - nativeThreadRef: null,
1057 - nativeConversationHeadRef: null,
1058 - status: "idle" as const,
1059 - firstRunOrdinal: null,
1060 - lastRunOrdinal: null,
1061 - handoffIds: [],
1062 - forkedFrom: null,
1063 - createdAt: now,
1064 - updatedAt: now,
1065 - };
1066 - }
1067 -
1068 - function run(id: string, ordinal: number, providerThreadId: string | null) {
1069 - return {
1070 - id: RunId.make(id),
1071 - threadId: projection.thread.id,
1072 - ordinal,
1073 - providerInstanceId: projection.thread.providerInstanceId,
1074 - modelSelection: projection.thread.modelSelection,
1075 - providerThreadId: providerThreadId === null ? null : ProviderThreadId.make(providerThreadId),
1076 - userMessageId: MessageId.make(`message-${id}`),
1077 - rootNodeId: null,
1078 - activeAttemptId: null,
1079 - status: "completed" as const,
1080 - requestedAt: now,
1081 - startedAt: now,
1082 - completedAt: now,
1083 - checkpointId: null,
1084 - contextHandoffId: null,
1085 - };
1086 - }
1087 -
1088 - const openList = {
1089 - createdAt: "2026-06-20T00:00:00.000Z",
1090 - runId: RunId.make("run-1"),
1091 - steps: [
1092 - { step: "Inspect", status: "completed" as const },
1093 - { step: "Implement", status: "inProgress" as const },
1094 - { step: "Verify", status: "pending" as const },
1095 - ],
1096 - };
1097 - const completedList = {
1098 - ...openList,
1099 - steps: openList.steps.map((step) => ({ ...step, status: "completed" as const })),
1100 - };
1101 -
1102 - it.each(["claudeAgent", "codex"])(
1103 - "shows %s tasks through the run lifecycle, retaining unfinished tasks only for Claude",
1104 - (driver) => {
1105 - const firstRun = run("run-1", 1, driver);
1106 - const settled = {
1107 - ...projection,
1108 - providerThreads: [providerThread(driver, driver)],
1109 - runs: [firstRun],
1110 - };
1111 - const running = {
1112 - ...settled,
1113 - runs: [{ ...firstRun, status: "running" as const, completedAt: null }],
1114 - };
1115 - expect(selectComposerTasksPlan(running, openList, firstRun.id, false)).toBe(openList);
1116 - expect(selectComposerTasksPlan(running, completedList, firstRun.id, false)).toBe(
1117 - completedList,
1118 - );
1119 -
1120 - const retainedList = driver === "claudeAgent" ? openList : null;
1121 - expect(selectComposerTasksPlan(settled, openList, firstRun.id, true)).toBe(retainedList);
1122 - expect(selectComposerTasksPlan(settled, completedList, firstRun.id, true)).toBeNull();
1123 -
1124 - const nextRun = {
1125 - ...run("run-2", 2, driver),
1126 - status: "running" as const,
1127 - completedAt: null,
1128 - };
1129 - const later = { ...settled, runs: [...settled.runs, nextRun] };
1130 - expect(selectComposerTasksPlan(later, openList, nextRun.id, false)).toBe(retainedList);
1131 - },
1132 - );
1133 -
1134 - it("retains the newest unfinished Claude list after loading plans in snapshot order", () => {
1135 - const olderRun = run("run:ordinal:8", 8, "claudeAgent");
1136 - const planRun = run("run:ordinal:12", 12, "claudeAgent");
1137 - const laterRun = {
1138 - ...run("run:ordinal:13", 13, "claudeAgent"),
1139 - status: "running" as const,
1140 - completedAt: null,
1141 - };
1142 - const newestPlan = {
1143 - id: PlanId.make("plan:run:ordinal:12"),
1144 - threadId: projection.thread.id,
1145 - runId: planRun.id,
1146 - nodeId: NodeId.make("node:ordinal:12"),
1147 - kind: "todo_list" as const,
1148 - status: "active" as const,
1149 - steps: [{ id: "new", text: "Finish the current task", status: "pending" as const }],
1150 - };
1151 - for (const status of ["superseded", "active"] as const) {
1152 - const snapshot = {
1153 - ...projection,
1154 - providerThreads: [providerThread("claudeAgent", "claudeAgent")],
1155 - runs: [olderRun, planRun, laterRun],
1156 - plans: [
1157 - newestPlan,
1158 - {
1159 - ...newestPlan,
1160 - id: PlanId.make("plan:run:ordinal:8"),
1161 - runId: olderRun.id,
1162 - nodeId: NodeId.make("node:ordinal:8"),
1163 - status,
1164 - steps: [{ id: "old", text: "Stale task", status: "pending" as const }],
1165 - },
1166 - ],
1167 - };
1168 - const plan = deriveActivePlanState(snapshot, laterRun.id);
1169 - expect
1170 - .soft(selectComposerTasksPlan(snapshot, plan, laterRun.id, false), status)
1171 - .toMatchObject({
1172 - runId: planRun.id,
1173 - steps: [{ step: "Finish the current task", status: "pending" }],
1174 - });
1175 - }
1176 - });
1177 -
1178 - it.each(["codex", "claudeAgent"])(
1179 - "drops retained Claude tasks only after a new %s session actually starts",
1180 - (driver) => {
1181 - const settled = {
1182 - ...projection,
1183 - providerThreads: [
1184 - providerThread("claude-original", "claudeAgent"),
1185 - providerThread("next-session", driver),
1186 - ],
1187 - runs: [run("run-1", 1, "claude-original")],
1188 - };
1189 - const nextRun = run("run-2", 2, "next-session");
1190 - for (const status of ["queued", "cancelled"] as const) {
1191 - const unstarted = {
1192 - ...settled,
1193 - runs: [
1194 - ...settled.runs,
1195 - {
1196 - ...nextRun,
1197 - status,
1198 - startedAt: null,
1199 - completedAt: status === "cancelled" ? now : null,
1200 - },
1201 - ],
1202 - };
1203 - expect
1204 - .soft(
1205 - selectComposerTasksPlan(unstarted, openList, nextRun.id, status === "cancelled"),
1206 - `A ${status} run with an assigned provider thread has not switched sessions`,
1207 - )
1208 - .toBe(openList);
1209 - }
1210 -
1211 - const started = {
1212 - ...settled,
1213 - runs: [...settled.runs, { ...nextRun, status: "running" as const, completedAt: null }],
1214 - };
1215 - expect(selectComposerTasksPlan(started, openList, nextRun.id, false)).toBeNull();
1216 - expect(
1217 - selectComposerTasksPlan(
1218 - { ...settled, runs: [...settled.runs, nextRun] },
1219 - openList,
1220 - nextRun.id,
1221 - true,
1222 - ),
1223 - ).toBeNull();
1224 - },
1225 - );
1226 -});
1227 -
1013 describe("native provider presentation in the v2 timeline", () => {
1014 const timestamp = DateTime.makeUnsafe("2026-09-04T12:00:00.000Z");
1015 const base = {
apps/web/src/session-logic.ts
+12 -78
@@ -7,7 +7,6 @@ import {
7 type OrchestrationV2PlanArtifact,
8 type OrchestrationV2ProjectedTurnItem,
9 type OrchestrationV2RunAttempt,
10 - type OrchestrationV2ThreadProjection,
10 type OrchestrationV2TurnItem,
11 type PlanId,
12 type RunId,
@@ -99,17 +98,6 @@ export interface WorkLogEntry {
98 export type PendingApproval = ThreadPendingApproval;
99 export type PendingUserInput = ThreadPendingUserInput;
100
102 -export interface ActivePlanState {
103 - readonly createdAt: string;
104 - readonly runId: RunId | null;
105 - readonly explanation?: string | null;
106 - readonly steps: Array<{
107 - readonly step: string;
108 - readonly status: "pending" | "inProgress" | "completed";
109 - readonly durationMs?: number;
110 - }>;
111 -}
112 -
101 export interface LatestProposedPlanState {
102 readonly id: PlanId;
103 readonly createdAt: string;
@@ -251,71 +239,6 @@ export function derivePendingUserInputs(
239 return [...inputs].toSorted((left, right) => left.createdAt.localeCompare(right.createdAt));
240 }
241
254 -export function deriveActivePlanState(
255 - projection: ThreadStructure | null,
256 - latestRunId: RunId | undefined,
257 -): ActivePlanState | null {
258 - if (projection === null) return null;
259 - const plans = projection.plans
260 - .filter((plan) => plan.kind === "todo_list")
261 - .filter((plan) => plan.status !== "superseded");
262 - const runOrdinals = new Map<RunId | null, number>(
263 - projection.runs.map((run) => [run.id, run.ordinal]),
264 - );
265 - const plan =
266 - plans.findLast((candidate) => candidate.runId === latestRunId) ??
267 - plans.reduce<(typeof plans)[number] | null>(
268 - (latest, candidate) =>
269 - latest === null ||
270 - (runOrdinals.get(candidate.runId) ?? -1) >= (runOrdinals.get(latest.runId) ?? -1)
271 - ? candidate
272 - : latest,
273 - null,
274 - );
275 - if (plan === null || plan.steps.length === 0) return null;
276 - return {
277 - createdAt: planItemTime(projection, plan),
278 - runId: plan.runId,
279 - explanation: plan.explanation ?? null,
280 - steps: plan.steps.map(({ text, status, durationMs }) => ({
281 - step: text,
282 - status: status === "running" ? "inProgress" : status,
283 - ...(durationMs === undefined ? {} : { durationMs }),
284 - })),
285 - };
286 -}
287 -
288 -// Claude's unfinished tasks belong to the provider session, not just the turn.
289 -export function selectComposerTasksPlan(
290 - projection: ThreadStructure | null,
291 - plan: ActivePlanState | null,
292 - activeRunId: RunId | null,
293 - activeRunSettled: boolean,
294 -): ActivePlanState | null {
295 - if (projection === null || plan === null) return null;
296 - if (activeRunId !== null && !activeRunSettled && plan.runId === activeRunId) return plan;
297 - if (plan.steps.every((step) => step.status === "completed")) return null;
298 - const planProviderThreadId = projection.runs.find(
299 - (run) => run.id === plan.runId,
300 - )?.providerThreadId;
301 - if (planProviderThreadId === undefined || planProviderThreadId === null) return null;
302 - const planDriver = projection.providerThreads.find(
303 - (providerThread) => providerThread.id === planProviderThreadId,
304 - )?.driver;
305 - if (planDriver !== "claudeAgent") return null;
306 - let latestStartedRun: OrchestrationV2ThreadProjection["runs"][number] | null = null;
307 - for (const run of projection.runs) {
308 - if (
309 - run.startedAt !== null &&
310 - run.providerThreadId !== null &&
311 - (latestStartedRun === null || run.ordinal > latestStartedRun.ordinal)
312 - ) {
313 - latestStartedRun = run;
314 - }
315 - }
316 - return latestStartedRun?.providerThreadId === planProviderThreadId ? plan : null;
317 -}
318 -
242 function planItemTime(
243 projection: ThreadStructure,
244 plan: Pick<OrchestrationV2PlanArtifact, "id" | "runId">,
@@ -589,6 +512,17 @@ function projectedWorkEntry(row: OrchestrationV2ProjectedTurnItem): WorkLogEntry
512 toolData: { input: item.input, output: item.output },
513 };
514 }
515 + case "todo_list": {
516 + // Each todo update is a quiet row where the agent wrote it; it opens to every step.
517 + const done = item.steps.filter((step) => step.status === "completed").length;
518 + const current =
519 + item.steps.find((step) => step.status === "running") ??
520 + item.steps.find((step) => step.status === "pending");
521 + return {
522 + ...common,
523 + label: `Tasks ${done}/${item.steps.length}${current ? ` · ${current.text}` : ""}`,
524 + };
525 + }
526 case "approval_request":
527 return {
528 ...common,
@@ -666,7 +600,7 @@ export function deriveTimelineEntriesFromVisibleTurnItems(
600 for (const row of input.visibleTurnItems) {
601 const { item } = row;
602 if (turnItemIsWorkspacePreparation(item)) continue;
669 - if (item.type === "todo_list" || item.type === "checkpoint") continue;
603 + if (item.type === "checkpoint") continue;
604 if (item.type === "user_message" && foldedAnswerMessageIds.has(item.messageId)) continue;
605 const createdAt = projectedItemCreatedAt(row);
606 const attempt = resolveAttempt(item);
apps/web/src/versionSkew.ts
-4
@@ -114,10 +114,6 @@ export function manualServerUpdateCommand(
114 return `${runner} t3@${targetVersion}`;
115 }
116
117 -export function serverUpdateGuidance(capability: ServerSelfUpdateCapability): string {
118 - return capability === "desktop-managed" ? "Update the desktop app" : "Update to stay in sync";
119 -}
120 -
117 export function buildVersionMismatchDismissalKey(
118 environmentId: EnvironmentId,
119 mismatch: Pick<VersionMismatch, "clientVersion" | "serverVersion">,
docs/user/composer.md
+10 -8
@@ -54,7 +54,7 @@ See [images and videos](#images-and-videos-in-messages) for previewing and savin
54 On web and desktop, choose **Settings → Chat → Follow-up behavior** to queue
55 new messages for a later turn or steer the running turn immediately. The setting
56 applies to this client; already queued messages keep their place. Queued messages
57 -are saved on the server and can be edited, reordered, or removed above the composer.
57 +are saved on the server and can be edited, reordered, or removed before they send.
58 When Enter sends, `Cmd+Enter` on macOS or `Ctrl+Enter` on Windows and Linux uses
59 the opposite action: it steers when your default is Queue and queues when your
60 default is Steer.
@@ -204,19 +204,20 @@ Steer. Click it or press your send shortcut to use that action. Hold `Cmd` on ma
204 Windows and Linux to switch the button to the opposite action, then click, or use the opposite-action
205 shortcut described above.
206
207 -Queued messages appear above the composer. Rows show a thumbnail of any attached image alongside
208 -the text. Drag a row by its handle to reorder it, use the handle's arrow keys, promote the message
209 -to a steer, or remove it.
207 +On web and desktop, queued messages appear at the end of the thread under **Up next**, as dashed
208 +messages that have not been sent yet. On mobile they appear above the composer. Each shows its text
209 +and any attached images. Drag a message by its handle to reorder it, use the handle's arrow keys,
210 +promote the message to a steer, or remove it.
211
212 If you stop the agent or the server restarts, queued messages keep their order and are held.
213 Press **Resume** in an empty composer on web and desktop, or **Resume queue** on mobile, to
214 continue. Sending a new message also resumes the queue, unless it steers a turn that is already
215 running. You can edit, reorder, or remove held messages without starting them.
216
216 -The pencil on a queued row opens that message in the composer for editing. The original message
217 -stays in the queue until you save, and its row is highlighted while you edit. The message's
217 +The pencil on a queued message opens it in the composer for editing. The original message
218 +stays in the queue until you save, and it is highlighted while you edit. The message's
219 attachments appear above the text with a remove control, and new images can be added the usual way.
219 -The checkmark saves the queued message in place; **Cancel** on its row leaves it unchanged. Whatever
220 +The checkmark saves the queued message in place; **Cancel** next to it leaves it unchanged. Whatever
221 you had typed in the composer before starting the edit is restored afterwards. If the queued
222 message starts or is removed while you are editing, the edit ends: changed content moves into the
223 composer when it is empty, and is discarded otherwise.
@@ -248,7 +249,8 @@ Claude instances can also compact idle threads for you. See
249 With Codex and Claude, send `/goal` followed by what "done" means, for example
250 `/goal all tests in packages/api pass`. The agent keeps working across turns
251 until it judges the goal met. The thread shows **Goal** while it works, and a
251 -row above the composer shows the goal and its progress.
252 +line at the end of the thread (above the composer on mobile) shows the goal and
253 +its progress.
254
255 - `/goal` alone shows the current goal. `/goal clear` removes it.
256 - Codex also supports `/goal pause` and `/goal resume`. Stopping a Codex goal
docs/user/providers-claude.md
+2 -2
@@ -91,8 +91,8 @@ tool, which refuses skills reserved for manual invocation.
91
92 To show Claude task lists in the web and desktop apps, add
93 `CLAUDE_CODE_ENABLE_TODO_TOOLS=1` under **Variables** in the Claude instance's
94 -**Environment** section in **Settings > Providers**. Unfinished tasks stay visible
95 -between turns in the same Claude session.
94 +**Environment** section in **Settings > Providers**. Each update shows as a Tasks
95 +row in the thread; open it to see every step.
96
97 ## OpenRouter
98
docs/user/updating.md
+4 -5
@@ -1,9 +1,8 @@
1 # Updating T3 Code
2
3 The app you use and the server running your agents can be on different machines.
4 -When a server is behind your web or desktop app, an update notice appears in the
5 -conversation and **Settings → Environments**. Update the machine named in that
6 -notice.
4 +When a server is behind your web or desktop app, the update button at the bottom
5 +of the sidebar and **Settings → Environments** offer to update it.
6
7 ## Update everything at once
8
@@ -25,8 +24,8 @@ restarts.
24
25 Server updates appear only after that version is published to npm. Remote
26 desktop apps do not wait for npm. The confirmation lists each machine it skips
28 -and why, such as a machine that is offline or needs a manual update. Use the
29 -notice or **Settings → Environments** for those.
27 +and why, such as a machine that is offline or needs a manual update. Use
28 +**Settings → Environments** for those.
29
30 If a desktop app restarts on its old version, T3 Code tells you the update did
31 not apply. It does not install that version again on its own, even when another