@@ -82,7 +82,6 @@ import { isPasteAsTextShortcut } from "@t3tools/client-runtime/text-paste";
8282import { effectiveSnoozed , threadWokeAt } from "@t3tools/client-runtime/state/thread-settled" ;
8383import { declinePendingApprovals } from "@t3tools/client-runtime/state/thread-requests" ;
8484import { presentThreadShell } from "@t3tools/client-runtime/state/shell" ;
85- import { childThreadInputsTitle } from "@t3tools/client-runtime/state/threads" ;
8685import { useAcknowledgeThreadWoke , useThreadActions } from "../hooks/useThreadActions" ;
8786import {
8887 deriveProviderSubagentStatus ,
@@ -92,8 +91,6 @@ import {
9291 deriveThreadActivityRun ,
9392 deriveLatestThreadRun ,
9493 deriveThreadRuntime ,
95- presentPendingBackgroundWork ,
96- presentProviderGoal ,
9794} from "@t3tools/client-runtime/state/thread-execution" ;
9895import {
9996 resolveWorkflowOpening ,
@@ -137,7 +134,7 @@ import { truncate } from "@t3tools/shared/String";
137134import { resolveThreadReferenceCopyTarget } from "@t3tools/shared/threadReference" ;
138135import { resolveTerminalSessionLabel } from "@t3tools/shared/terminalLabels" ;
139136import { useAtomValue } from "@effect/atom-react" ;
140- import { Fragment , type SetStateAction , useEffect , useLayoutEffect , useRef , useState } from "react" ;
137+ import { type SetStateAction , useEffect , useLayoutEffect , useRef , useState } from "react" ;
141138import { flushSync } from "react-dom" ;
142139import { useLocation , useNavigate , useRouter } from "@tanstack/react-router" ;
143140import { assistantCitationFromLocation } from "../lib/assistantCitationNavigation" ;
@@ -234,13 +231,9 @@ import { shortcutLabelForCommand } from "../keybindings";
234231import {
235232 AlarmClockIcon ,
236233 CheckCircle2Icon ,
237- MessageCircleIcon ,
238234 PaperclipIcon ,
239235 ChevronDownIcon ,
240236 DownloadIcon ,
241- GitBranchIcon ,
242- ShieldQuestionIcon ,
243- TargetIcon ,
244237} from "lucide-react" ;
245238import { cn } from "~/lib/utils" ;
246239import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar" ;
@@ -483,8 +476,7 @@ import { readEnvironmentScope, readPreparedConnection } from "../state/session";
483476import { useAtomCommand } from "../state/use-atom-command" ;
484477import { useOrchestrationCommand } from "../state/use-orchestration-command" ;
485478import { useAtomQueryRunner } from "../state/use-atom-query-runner" ;
486- import { Button , InlineButton } from "./ui/button" ;
487- import { Tooltip , TooltipPopup , TooltipTrigger } from "./ui/tooltip" ;
479+ import { Button } from "./ui/button" ;
488480import { useAssetUrls } from "../assets/assetUrls" ;
489481import {
490482 ATTACHMENT_ONLY_BOOTSTRAP_PROMPT ,
@@ -494,6 +486,12 @@ import { observeResize } from "~/lib/observeResize";
494486import { ThreadVisitWatermark } from "./chat/ThreadVisitWatermark" ;
495487import { ChatTerminalDrawers } from "./chat/ChatTerminalDrawers" ;
496488import { ChatRightPanel } from "./chat/ChatRightPanel" ;
489+ import {
490+ backgroundWorkBannerItem ,
491+ branchMismatchBannerItem ,
492+ childInputBannerItem ,
493+ goalBannerItem ,
494+ } from "./chat/ThreadActivityBanners" ;
497495import { useTimelineFollow } from "./chat/useTimelineFollow" ;
498496import {
499497 type EnvironmentUnavailableState ,
@@ -4019,35 +4017,13 @@ export default function ChatView(props: ChatViewProps) {
40194017 } ;
40204018 const onOpenRelatedThreadStable = useStableCallback ( onOpenRelatedThread ) ;
40214019 const childThreadInputs = useChildThreadInputs ( activeThreadRef ) ;
4022- const childInputBannerItem = ( ( ) => {
4023- const first = childThreadInputs [ 0 ] ;
4024- const parentAwaitingUser =
4025- activePendingApproval || activePendingUserInput || activeThreadShell ?. hasPendingUserInput ;
4026- if ( ! first || parentAwaitingUser ) return null ;
4027- return {
4028- id : `child-input:${ first . id } ` ,
4029- variant : "info" ,
4030- priority : "activity" ,
4031- icon : first . hasPendingApprovals ? < ShieldQuestionIcon /> : < MessageCircleIcon /> ,
4032- title : childThreadInputsTitle ( childThreadInputs ) ,
4033- description : childThreadInputs . map ( ( child , index ) => (
4034- < Fragment key = { child . id } >
4035- { index > 0 ? " " : null }
4036- < span className = "whitespace-nowrap" >
4037- < InlineButton tone = "muted" onClick = { ( ) => onOpenRelatedThreadStable ( child . id ) } >
4038- { child . title }
4039- </ InlineButton >
4040- { index < childThreadInputs . length - 1 ? "," : null }
4041- </ span >
4042- </ Fragment >
4043- ) ) ,
4044- actions : (
4045- < Button size = "xs" variant = "ghost" onClick = { ( ) => onOpenRelatedThreadStable ( first . id ) } >
4046- { first . hasPendingApprovals ? "Open approval" : "Open question" }
4047- </ Button >
4048- ) ,
4049- } ;
4050- } ) ( ) as ComposerBannerStackItem | null ;
4020+ const childInputBanner = childInputBannerItem ( {
4021+ childThreadInputs,
4022+ parentAwaitingUser : Boolean (
4023+ activePendingApproval || activePendingUserInput || activeThreadShell ?. hasPendingUserInput ,
4024+ ) ,
4025+ onOpenThread : onOpenRelatedThreadStable ,
4026+ } ) ;
40514027
40524028 const sendStandaloneCommand = async ( text : string , failureMessage : string ) => {
40534029 if ( ! activeThread || ! clientSettingsHydrated || sendInFlightRef . current ) return ;
@@ -4111,104 +4087,26 @@ export default function ChatView(props: ChatViewProps) {
41114087 } ;
41124088 const sendStandaloneCommandStable = useStableCallback ( sendStandaloneCommand ) ;
41134089 const activeGoal = activeThreadShell ?. goal ?? null ;
4114- const goalBannerItem = ( ( ) => {
4115- if ( ! activeThread || activeGoal === null ) return null ;
4116- const presentation = presentProviderGoal ( activeGoal , isWorking ) ;
4117- return {
4118- id : `goal:${ activeThread . id } ` ,
4119- variant : "default" ,
4120- priority : "activity" ,
4121- icon : < TargetIcon /> ,
4122- title :
4123- presentation . usage === null
4124- ? presentation . title
4125- : `${ presentation . title } · ${ presentation . usage } ` ,
4126- description : presentation . objective ,
4127- actions : isWorking ? undefined : (
4128- < >
4129- { presentation . canResume ? (
4130- < Button
4131- size = "xs"
4132- variant = "ghost"
4133- onClick = { ( ) =>
4134- void sendStandaloneCommandStable ( "/goal resume" , "Failed to resume goal." )
4135- }
4136- >
4137- Resume
4138- </ Button >
4139- ) : null }
4140- < Button
4141- size = "xs"
4142- variant = "ghost"
4143- onClick = { ( ) => void sendStandaloneCommandStable ( "/goal clear" , "Failed to clear goal." ) }
4144- >
4145- Clear
4146- </ Button >
4147- </ >
4148- ) ,
4149- } ;
4150- } ) ( ) as ComposerBannerStackItem | null ;
4090+ const goalBanner =
4091+ activeThread && activeGoal !== null
4092+ ? goalBannerItem ( {
4093+ threadId : activeThread . id ,
4094+ goal : activeGoal ,
4095+ isWorking,
4096+ onSendCommand : sendStandaloneCommandStable ,
4097+ } )
4098+ : null ;
41514099
4152- const backgroundWorkBannerItem = ( ( ) => {
4153- const presentation = presentPendingBackgroundWork ( activeBackgroundTasks ) ;
4154- if ( presentation === null || ! activeThread ) {
4155- return null ;
4156- }
4157- return {
4158- id : `background-work:${ activeThread . id } ` ,
4159- variant : "default" ,
4160- priority : "activity" ,
4161- icon : (
4162- < span
4163- className = { cn (
4164- "size-1.5 rounded-full bg-foreground" ,
4165- presentation . waiting && "motion-safe:animate-status-pulse" ,
4166- ) }
4167- aria-hidden = "true"
4168- />
4169- ) ,
4170- title : presentation . title ,
4171- description :
4172- presentation . items . length === 1 && presentation . items [ 0 ] ?. childThreadId === undefined
4173- ? undefined
4174- : presentation . items . map ( ( item , index ) => {
4175- const childThreadId = item . childThreadId ;
4176- const separator = index < presentation . items . length - 1 ? "," : null ;
4177- return (
4178- < Fragment key = { item . taskId } >
4179- { index > 0 ? " " : null }
4180- { childThreadId === undefined ? (
4181- < >
4182- { item . label }
4183- { separator }
4184- </ >
4185- ) : (
4186- < span className = "whitespace-nowrap" >
4187- < InlineButton
4188- tone = "muted"
4189- aria-label = { `${ presentation . items . length === 1 ? "Show" : "Open" } subagent ${ item . label } ` }
4190- onClick = { ( ) => onOpenRelatedThreadStable ( childThreadId ) }
4191- >
4192- { presentation . items . length === 1 ? "Show" : item . label }
4193- </ InlineButton >
4194- { separator }
4195- </ span >
4196- ) }
4197- </ Fragment >
4198- ) ;
4199- } ) ,
4200- actions : (
4201- < Button
4202- size = "xs"
4203- variant = "ghost"
4204- disabled = { ! canOperateThread || isStoppingBackgroundWork }
4205- onClick = { ( ) => void handleStopBackgroundWorkStable ( ) }
4206- >
4207- { isStoppingBackgroundWork ? "Stopping..." : "Stop" }
4208- </ Button >
4209- ) ,
4210- } ;
4211- } ) ( ) as ComposerBannerStackItem | null ;
4100+ const backgroundWorkBanner = activeThread
4101+ ? backgroundWorkBannerItem ( {
4102+ threadId : activeThread . id ,
4103+ tasks : activeBackgroundTasks ,
4104+ stopDisabled : ! canOperateThread || isStoppingBackgroundWork ,
4105+ stopping : isStoppingBackgroundWork ,
4106+ onStop : handleStopBackgroundWorkStable ,
4107+ onOpenThread : onOpenRelatedThreadStable ,
4108+ } )
4109+ : null ;
42124110 // The relative times read the clock; nowMinute re-renders them on the minute.
42134111 const snoozedUntil = activeThreadShell ?. snoozedUntil ?? null ;
42144112 const settledAt = activeThreadShell ?. settledAt ?? null ;
@@ -4353,11 +4251,9 @@ export default function ChatView(props: ChatViewProps) {
43534251 : null ;
43544252 const composerBannerItems = ( ( ) => {
43554253 const limitRecoveryItems = limitRecoveryBanner === null ? [ ] : [ limitRecoveryBanner ] ;
4356- const backgroundWorkItems = [
4357- childInputBannerItem ,
4358- goalBannerItem ,
4359- backgroundWorkBannerItem ,
4360- ] . filter ( ( item ) => item !== null ) ;
4254+ const backgroundWorkItems = [ childInputBanner , goalBanner , backgroundWorkBanner ] . filter (
4255+ ( item ) => item !== null ,
4256+ ) ;
43614257 const usageLimitsItems = usageLimitsBanner === null ? [ ] : [ usageLimitsBanner ] ;
43624258 const projectCloneItems = projectCloneBannerItem === null ? [ ] : [ projectCloneBannerItem ] ;
43634259 if ( ! localCheckoutBranchMismatch || ! showBranchMismatchBanner || ! activeBranchMismatchKey ) {
@@ -4377,45 +4273,17 @@ export default function ChatView(props: ChatViewProps) {
43774273 ...projectCloneItems ,
43784274 ...systemComposerBannerItems ,
43794275 ...backgroundWorkItems ,
4380- {
4381- id : `branch-mismatch:${ activeBranchMismatchKey } ` ,
4382- variant : "info" ,
4383- compact : true ,
4384- icon : < GitBranchIcon /> ,
4385- title : (
4386- < span className = "flex min-w-0 items-baseline gap-1.5" >
4387- < span className = "shrink-0 font-normal text-muted-foreground" > Branch changed — was</ span >
4388- < Tooltip >
4389- < TooltipTrigger
4390- render = {
4391- < code className = "min-w-0 truncate font-medium text-foreground" >
4392- { localCheckoutBranchMismatch . threadBranch }
4393- </ code >
4394- }
4395- />
4396- < TooltipPopup side = "top" >
4397- This thread last ran on { localCheckoutBranchMismatch . threadBranch } . Sending will
4398- continue on { localCheckoutBranchMismatch . currentBranch } .
4399- </ TooltipPopup >
4400- </ Tooltip >
4401- </ span >
4402- ) ,
4403- actions : (
4404- < Button
4405- size = "xs"
4406- variant = "ghost"
4407- disabled = { ! canWriteSourceControl || isRestoringThreadBranch }
4408- onClick = { handleRestoreThreadBranchStable }
4409- >
4410- { isRestoringThreadBranch ? "Restoring..." : "Restore branch" }
4411- </ Button >
4412- ) ,
4413- dismissLabel : "Dismiss branch change notice" ,
4276+ branchMismatchBannerItem ( {
4277+ mismatchKey : activeBranchMismatchKey ,
4278+ mismatch : localCheckoutBranchMismatch ,
4279+ restoreDisabled : ! canWriteSourceControl || isRestoringThreadBranch ,
4280+ restoring : isRestoringThreadBranch ,
4281+ onRestore : handleRestoreThreadBranchStable ,
44144282 onDismiss : ( ) => {
44154283 dismissBranchMismatchForSession ( activeBranchMismatchKey ) ;
44164284 setBranchMismatchDismissTick ( ( tick ) => tick + 1 ) ;
44174285 } ,
4418- } ,
4286+ } ) ,
44194287 ] ;
44204288 } ) ( ) as ComposerBannerStackItem [ ] ;
44214289
0 commit comments