@@ -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" ;
8992import { resolvePendingHandoff } from "@t3tools/client-runtime/handoff" ;
9093import { HandoffRow } from "./chat/V2LifecycleRow" ;
9194import {
@@ -350,6 +353,8 @@ import { ChatTerminalDrawers } from "./chat/ChatTerminalDrawers";
350353import { ChatRightPanel } from "./chat/ChatRightPanel" ;
351354import { useDraftEnvironmentRouting } from "./chat/useDraftEnvironmentRouting" ;
352355import { branchMismatchBannerItem } from "./chat/ThreadActivityBanners" ;
356+ import { ThreadNow } from "./chat/ThreadNow" ;
357+ import { useDelayedStatus } from "../hooks/useDelayedStatus" ;
353358import { useTimelineFollow } from "./chat/useTimelineFollow" ;
354359import {
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 }
0 commit comments