Skip to content

Commit da4dbba

Browse files
t3dotggclaude
andcommitted
feat(web): thread state lives at the end of the timeline, not on the composer
Queued messages, the goal, background work, tasks, sync and subagent requests move from cards above the composer to the end of the timeline: what the thread is doing now, then your queued turns as unsent messages under "Up next". The composer keeps only what affects sending (offline, branch changed, usage limit, clone, feedback) plus approvals and questions. An available server update is left to the sidebar's update pill; progress and failures still show. When the end of the timeline is out of view, Scroll to end names what waits there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6ba29c0 commit da4dbba

14 files changed

Lines changed: 667 additions & 771 deletions

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 74 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ import {
8585
resolveWorkflowOpening,
8686
workflowOpeningParentThreadId,
8787
} from "@t3tools/client-runtime/state/subagentRuntime";
88-
import { threadSupportsProviderHandoff } from "@t3tools/client-runtime/state/thread-workflows";
88+
import {
89+
deriveThreadQueueWorkflowState,
90+
threadSupportsProviderHandoff,
91+
} from "@t3tools/client-runtime/state/thread-workflows";
8992
import { resolvePendingHandoff } from "@t3tools/client-runtime/handoff";
9093
import { HandoffRow } from "./chat/V2LifecycleRow";
9194
import {
@@ -350,6 +353,8 @@ import { ChatTerminalDrawers } from "./chat/ChatTerminalDrawers";
350353
import { ChatRightPanel } from "./chat/ChatRightPanel";
351354
import { useDraftEnvironmentRouting } from "./chat/useDraftEnvironmentRouting";
352355
import { branchMismatchBannerItem } from "./chat/ThreadActivityBanners";
356+
import { ThreadNow } from "./chat/ThreadNow";
357+
import { useDelayedStatus } from "../hooks/useDelayedStatus";
353358
import { useTimelineFollow } from "./chat/useTimelineFollow";
354359
import {
355360
type EnvironmentUnavailableState,
@@ -510,6 +515,8 @@ export default function ChatView(props: ChatViewProps) {
510515
status: threadStatus,
511516
});
512517
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);
513520
const activeProviderThread = serverProjection?.providerThreads.find(
514521
(thread) => thread.id === serverProjection.thread.activeProviderThreadId,
515522
);
@@ -2215,9 +2222,8 @@ export default function ChatView(props: ChatViewProps) {
22152222
const mainSurface = composerOverlayElement?.querySelector<HTMLElement>(
22162223
'[data-chat-composer-main-surface="true"]',
22172224
);
2218-
const button = composerOverlayElement?.parentElement?.querySelector<HTMLElement>(
2219-
'button[aria-label="Scroll to end"]',
2220-
);
2225+
const button =
2226+
composerOverlayElement?.parentElement?.querySelector<HTMLElement>("[data-scroll-to-end]");
22212227
const clearance =
22222228
composerOverlayElement && mainSurface && button
22232229
? resolveScrollToEndClearance({
@@ -2372,9 +2378,9 @@ export default function ChatView(props: ChatViewProps) {
23722378
const {
23732379
acknowledgeActiveThreadWoke,
23742380
activeBranchMismatchKey,
2375-
backgroundWorkBanner,
2376-
childInputBanner,
2377-
goalBanner,
2381+
backgroundWorkNow,
2382+
childInputNow,
2383+
goalNow,
23782384
handleSwitchCheckoutToThread,
23792385
handleSwitchCheckoutToThreadStable,
23802386
isRestoringThreadBranch,
@@ -2539,9 +2545,6 @@ export default function ChatView(props: ChatViewProps) {
25392545
: null;
25402546
const composerBannerItems = (() => {
25412547
const limitRecoveryItems = limitRecoveryBanner === null ? [] : [limitRecoveryBanner];
2542-
const backgroundWorkItems = [childInputBanner, goalBanner, backgroundWorkBanner].filter(
2543-
(item) => item !== null,
2544-
);
25452548
const usageLimitsItems = usageLimitsBanner === null ? [] : [usageLimitsBanner];
25462549
const projectCloneItems = projectCloneBannerItem === null ? [] : [projectCloneBannerItem];
25472550
if (!localCheckoutBranchMismatch || !showBranchMismatchBanner || !activeBranchMismatchKey) {
@@ -2551,7 +2554,6 @@ export default function ChatView(props: ChatViewProps) {
25512554
...usageLimitsItems,
25522555
...projectCloneItems,
25532556
...systemComposerBannerItems,
2554-
...backgroundWorkItems,
25552557
];
25562558
}
25572559
return [
@@ -2560,7 +2562,6 @@ export default function ChatView(props: ChatViewProps) {
25602562
...usageLimitsItems,
25612563
...projectCloneItems,
25622564
...systemComposerBannerItems,
2563-
...backgroundWorkItems,
25642565
branchMismatchBannerItem({
25652566
mismatchKey: activeBranchMismatchKey,
25662567
mismatch: localCheckoutBranchMismatch,
@@ -2965,6 +2966,65 @@ export default function ChatView(props: ChatViewProps) {
29652966
openExpandedImagePreview(routeThreadKey, preview);
29662967
};
29672968
const onExpandTimelineImageStable = useStableCallback(onExpandTimelineImage);
2969+
const shownThreadSyncPhase = activeEnvironmentUnavailable ? null : delayedThreadSyncPhase;
2970+
const threadNowTasks =
2971+
activeComposerTasksProgress && activeComposerTaskSteps
2972+
? { progress: activeComposerTasksProgress, steps: activeComposerTaskSteps }
2973+
: null;
2974+
const hasThreadNow =
2975+
childInputNow !== null ||
2976+
backgroundWorkNow !== null ||
2977+
goalNow !== null ||
2978+
shownThreadSyncPhase !== null ||
2979+
threadNowTasks !== null;
2980+
const queuedRunCount = serverProjection
2981+
? deriveThreadQueueWorkflowState(serverProjection).queuedRuns.length
2982+
: 0;
2983+
const scrollToEndSummary =
2984+
[
2985+
childInputNow === null ? null : "Needs input",
2986+
queuedRunCount === 0 ? null : `${queuedRunCount} queued`,
2987+
]
2988+
.filter((part) => part !== null)
2989+
.join(" · ") || null;
2990+
// The end of the timeline holds the thread's present and next turns: what it is doing now,
2991+
// its lifecycle status, guest messages awaiting you, then your queued messages.
2992+
const timelineFooter =
2993+
pendingHandoff === null &&
2994+
!hasThreadNow &&
2995+
threadStatusLine === null &&
2996+
pendingGuestMessageCount === 0 &&
2997+
queuedRunsControl === null ? null : (
2998+
<>
2999+
{pendingHandoff === null ? null : (
3000+
<div className="chat-content-lane">
3001+
<HandoffRow
3002+
environmentId={environmentId}
3003+
endpoints={pendingHandoff}
3004+
providers={providerStatuses}
3005+
pending
3006+
/>
3007+
</div>
3008+
)}
3009+
<ThreadNow
3010+
key={routeThreadKey}
3011+
attention={childInputNow}
3012+
work={backgroundWorkNow}
3013+
tasks={threadNowTasks}
3014+
syncPhase={shownThreadSyncPhase}
3015+
goal={goalNow}
3016+
/>
3017+
{threadStatusLine}
3018+
{pendingGuestMessageCount > 0 && isServerThread && activeThread ? (
3019+
<GuestPendingMessages
3020+
threadRef={scopeThreadRef(activeThread.environmentId, activeThread.id)}
3021+
onImageExpand={onExpandTimelineImageStable}
3022+
onFileOpen={openFileAttachmentStable}
3023+
/>
3024+
) : null}
3025+
{queuedRunsControl}
3026+
</>
3027+
);
29683028

29693029
const pendingSidebarFileDrops = useSidebarPendingFileDropStore((state) => state.pending);
29703030
const consumePendingFileDrop = useSidebarPendingFileDropStore(
@@ -3251,33 +3311,7 @@ export default function ChatView(props: ChatViewProps) {
32513311
: {})}
32523312
{...(onOpenWorktreeSetupTerminal ? { onOpenWorktreeSetupTerminal } : {})}
32533313
isPreparingWorktree={!paintOnlyDisplayedTimeline && isPreparingWorktree}
3254-
footer={
3255-
paintOnlyDisplayedTimeline ||
3256-
(pendingHandoff === null &&
3257-
pendingGuestMessageCount === 0 &&
3258-
threadStatusLine === null) ? null : (
3259-
<>
3260-
{pendingHandoff === null ? null : (
3261-
<div className="chat-content-lane">
3262-
<HandoffRow
3263-
environmentId={environmentId}
3264-
endpoints={pendingHandoff}
3265-
providers={providerStatuses}
3266-
pending
3267-
/>
3268-
</div>
3269-
)}
3270-
{pendingGuestMessageCount > 0 && isServerThread && activeThread ? (
3271-
<GuestPendingMessages
3272-
threadRef={scopeThreadRef(activeThread.environmentId, activeThread.id)}
3273-
onImageExpand={onExpandTimelineImageStable}
3274-
onFileOpen={openFileAttachmentStable}
3275-
/>
3276-
) : null}
3277-
{threadStatusLine}
3278-
</>
3279-
)
3280-
}
3314+
footer={paintOnlyDisplayedTimeline ? null : timelineFooter}
32813315
listRef={legendListRef}
32823316
runs={paintOnlyDisplayedTimeline ? [] : (serverProjection?.runs ?? [])}
32833317
latestRun={paintOnlyDisplayedTimeline ? null : activeActivityRun}
@@ -3365,6 +3399,7 @@ export default function ChatView(props: ChatViewProps) {
33653399
{showScrollToBottom && !isThreadFindActive && (
33663400
<ScrollToEndButton
33673401
bottom={scrollToEndClearance + 4}
3402+
summary={scrollToEndSummary}
33683403
onScrollToEnd={() => {
33693404
composerRef.current?.restoreAfterTimelineReachedEnd();
33703405
scrollToEnd(true);
@@ -3505,7 +3540,6 @@ export default function ChatView(props: ChatViewProps) {
35053540
: projectCloneSendBlockReason
35063541
}
35073542
isPreparingWorktree={isPreparingWorktree && !sendQueuesBehindSetup}
3508-
queuedRunsControl={queuedRunsControl}
35093543
bannerItems={composerBannerItems}
35103544
resumeCompactionTokens={resumeCompactionTokens}
35113545
keepFullHistory={keepFullHistory}
@@ -3543,8 +3577,6 @@ export default function ChatView(props: ChatViewProps) {
35433577
activeThreadModelSelection={activeThread?.modelSelection}
35443578
activeProjectId={activeProject?.id ?? null}
35453579
activeContextWindow={activeContextWindow}
3546-
activeTasksProgress={activeComposerTasksProgress}
3547-
activeTaskSteps={activeComposerTaskSteps}
35483580
compactThreadUnavailable={compactThreadUnavailable}
35493581
compactDisabled={compactDisabled}
35503582
compactDisabledReason={compactDisabledReason}

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import { createModelSelection, normalizeModelSlug } from "@t3tools/shared/model"
4848
import { USAGE_LIMITS_COMMAND } from "@t3tools/shared/usageLimits";
4949
import {
5050
memo,
51-
type ReactNode,
5251
useEffect,
5352
useEffectEvent,
5453
useId,
@@ -105,12 +104,6 @@ import { useComposerTriggerState } from "./useComposerTriggerState";
105104
import { useComposerMenuItems } from "./useComposerMenuItems";
106105
import { useComposerFocusState } from "./useComposerFocusState";
107106
import { useComposerMultilinePrompt } from "./useComposerMultilinePrompt";
108-
import {
109-
ComposerTasksContent,
110-
type ComposerTaskStep,
111-
type ComposerTasksProgress,
112-
} from "./ComposerTasksBadge";
113-
import { ComposerActivityRow } from "./ComposerActivityStatus";
114107
import {
115108
reconcileAttachmentContextReferences,
116109
useRetainedContextPayloads,
@@ -268,7 +261,6 @@ import {
268261
resolveProviderSkillsForCwd,
269262
resolveProviderSlashCommandsForCwd,
270263
} from "@t3tools/client-runtime/providerSkills";
271-
import { useDelayedStatus } from "../../hooks/useDelayedStatus";
272264
import { useMediaQuery } from "../../hooks/useMediaQuery";
273265
import { useSoftwareKeyboardOpen } from "../../hooks/useSoftwareKeyboardOpen";
274266
import { useStableCallback } from "../../hooks/useStableCallback";
@@ -429,8 +421,6 @@ export interface ChatComposerProps {
429421

430422
showPlanFollowUpPrompt: boolean;
431423
activeProposedPlan: LatestProposedPlanState | null;
432-
activeTasksProgress: ComposerTasksProgress | null;
433-
activeTaskSteps: readonly ComposerTaskStep[] | null;
434424
threadSyncPhase: ThreadSyncPhase | null;
435425

436426
runtimeMode: RuntimeMode;
@@ -475,7 +465,6 @@ export interface ChatComposerProps {
475465
onPageScrollKeyUp: (key: string) => void;
476466
onPageScrollRelease: () => void;
477467

478-
queuedRunsControl?: ReactNode;
479468
editingQueuedAttachments: ReadonlyArray<{
480469
readonly attachment: ContractChatAttachment;
481470
readonly url: string | null;
@@ -657,9 +646,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
657646
const activePendingProgress = holdingUserInput ? null : incomingPendingProgress;
658647
const activePendingIsResponding = !holdingUserInput && incomingPendingIsResponding;
659648
const isLiteralPendingAnswer = activePendingProgress?.activeQuestion?.initialAnswer !== undefined;
660-
const shownSyncPhase = useDelayedStatus(composerDraftTargetKey, props.threadSyncPhase);
661-
const activeTasksProgress = shownSyncPhase === null ? props.activeTasksProgress : null;
662-
const activeTaskSteps = shownSyncPhase === null ? props.activeTaskSteps : null;
663649
const isEditingQueuedMessage = editingQueuedAttachments !== null;
664650
const composerDraft = useComposerThreadDraft(composerDraftTarget);
665651
const composerDraftTargetKeyRef = useRef("");
@@ -1092,7 +1078,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
10921078
const [composerMenuAnchor, setComposerMenuAnchor] = useState<HTMLDivElement | null>(null);
10931079
const [hasWrappedPrompt, observeWrappedPrompt] = useComposerMultilinePrompt();
10941080
const hasMultilinePrompt = prompt.includes("\n") || hasWrappedPrompt;
1095-
const [isTasksDrawerOpen, setIsTasksDrawerOpen] = useState(false);
10961081
// A pending question stays expanded: its card moves into the banner dock,
10971082
// so collapsing would leave the surface empty and squashed beneath it.
10981083
const isComposerCollapsedMobile =
@@ -2304,10 +2289,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
23042289
importContextRecords,
23052290
expandMobileComposer: expandMobileComposerStable,
23062291
});
2307-
const toggleTasksDrawer = () => {
2308-
setIsTasksDrawerOpen((open) => !open);
2309-
};
2310-
const toggleTasksDrawerStable = useStableCallback(toggleTasksDrawer);
23112292
const hasBlockingComposerTopDrawer =
23122293
activePendingApproval !== null || pendingUserInputs.length > 0;
23132294
const hasImageAttachmentAttention = standaloneComposerImages.some((image) => {
@@ -2320,7 +2301,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
23202301
});
23212302
const composerHasExpandedChrome =
23222303
showComposerTopDrawer ||
2323-
isTasksDrawerOpen ||
23242304
composerMenuOpen ||
23252305
isStashMenuOpen ||
23262306
isDragOverComposer ||
@@ -2572,27 +2552,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
25722552
item.group === "environment" && (item.variant === "error" || item.variant === "warning"),
25732553
)
25742554
: props.bannerItems;
2575-
const shelfActivity = hasBlockingComposerTopDrawer ? null : shownSyncPhase ? (
2576-
<ComposerActivityRow phase={shownSyncPhase} />
2577-
) : activeTasksProgress && activeTaskSteps && activeTasksProgress.totalSteps > 0 ? (
2578-
<ComposerTasksContent
2579-
expanded={isTasksDrawerOpen}
2580-
onToggle={toggleTasksDrawerStable}
2581-
progress={activeTasksProgress}
2582-
steps={activeTaskSteps}
2583-
/>
2584-
) : null;
2585-
const [tasksDrawerThreadId, setTasksDrawerThreadId] = useState(activeThreadId);
2586-
if (
2587-
isTasksDrawerOpen &&
2588-
(activeTasksProgress === null ||
2589-
activeTaskSteps === null ||
2590-
hasBlockingComposerTopDrawer ||
2591-
tasksDrawerThreadId !== activeThreadId)
2592-
) {
2593-
setIsTasksDrawerOpen(false);
2594-
}
2595-
if (tasksDrawerThreadId !== activeThreadId) setTasksDrawerThreadId(activeThreadId);
25962555

25972556
const insertComposerText = (
25982557
text: string,
@@ -3443,12 +3402,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
34433402
: null}
34443403
<ComposerBanner.Dock>
34453404
<ComposerBanner.Column>
3446-
<ComposerBannerStack
3447-
key={activeThreadId}
3448-
items={shelfItems}
3449-
activity={shelfActivity}
3450-
queue={hasBlockingComposerTopDrawer ? null : props.queuedRunsControl}
3451-
/>
3405+
<ComposerBannerStack items={shelfItems} />
34523406
{showComposerTopDrawer ? (
34533407
<ComposerBanner.Attachment>
34543408
<ComposerBanner.Root

‎apps/web/src/components/chat/ComposerActivityStatus.tsx‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎apps/web/src/components/chat/ComposerBannerStack.browser.test.tsx‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,20 @@ function notice(title: string, group?: ComposerBannerStackItem["group"]): Compos
1111
return { id: title, variant: "default", icon: <InfoIcon />, title, ...(group ? { group } : {}) };
1212
}
1313

14-
function EmptyQueue() {
15-
return null;
16-
}
17-
18-
it("keeps rows in fixed groups whatever order the notices arrive in", async () => {
14+
it("puts machine notices first, whatever order the notices arrive in", async () => {
1915
await using screen = await render(
20-
<ComposerBannerStack
21-
items={[
22-
notice("Goal", "activity"),
23-
notice("Branch changed"),
24-
notice("Offline", "environment"),
25-
]}
26-
activity={<span>Tasks</span>}
27-
queue={<span>Queued</span>}
28-
/>,
16+
<ComposerBannerStack items={[notice("Branch changed"), notice("Offline", "environment")]} />,
2917
);
3018

31-
expect(screen.getByRole("region", { name: "Thread status" }).element().textContent).toBe(
32-
"OfflineBranch changedGoalTasksQueued",
19+
expect(screen.getByRole("region", { name: "Notices" }).element().textContent).toBe(
20+
"OfflineBranch changed",
3321
);
3422
});
3523

36-
it("leaves the next attachment its own top edge when the shelf has nothing to show", async () => {
24+
it("leaves the next attachment its own top edge when there are no notices", async () => {
3725
await using screen = await render(
3826
<ComposerBanner.Column>
39-
<ComposerBannerStack items={[]} queue={<EmptyQueue />} />
27+
<ComposerBannerStack items={[]} />
4028
<ComposerBanner.Attachment>
4129
<ComposerBanner.Root data-testid="drawer">Approval</ComposerBanner.Root>
4230
</ComposerBanner.Attachment>

0 commit comments

Comments
 (0)