@@ -67,6 +67,8 @@ export const FLOATING_WORKING_CONTROL_COVERAGE = CONTROL_OVERLAY_OFFSET + CONTRO
6767export function FloatingWorkingControl ( props : {
6868 readonly colorScheme : "light" | "dark" ;
6969 readonly status : FloatingWorkingStatus | null ;
70+ /** Stop for background work that outlived its turn, beside the label naming it. */
71+ readonly backgroundStop : { readonly stopping : boolean ; readonly onPress : ( ) => void } | null ;
7072 readonly devicePreview : { readonly count : number ; readonly onPress : ( ) => void } | null ;
7173 readonly browserPreview : { readonly count : number ; readonly onPress : ( ) => void } | null ;
7274 readonly showScrollToEnd : boolean ;
@@ -82,6 +84,9 @@ export function FloatingWorkingControl(props: {
8284 const [ overlayWidth , setOverlayWidth ] = useState ( windowWidth ) ;
8385 const [ queueWidth , setQueueWidth ] = useState ( 0 ) ;
8486 const [ agentsWidth , setAgentsWidth ] = useState ( 0 ) ;
87+ const [ stopWidth , setStopWidth ] = useState ( 0 ) ;
88+ const backgroundStop = props . status ?. kind === "background" ? props . backgroundStop : null ;
89+ const hasStop = backgroundStop !== null ;
8590 const hasQueue = props . queuedCount > 0 ;
8691 const hasPreview = props . devicePreview !== null || props . browserPreview !== null ;
8792 const [ previewWidth , setPreviewWidth ] = useState ( 0 ) ;
@@ -94,6 +99,7 @@ export function FloatingWorkingControl(props: {
9499 Math . min ( overlayWidth , windowWidth ) -
95100 CONTROL_HEIGHT -
96101 32 -
102+ ( hasStop ? stopWidth : 0 ) -
97103 ( hasQueue ? queueWidth : 0 ) -
98104 ( hasAgents ? agentsWidth : 0 ) -
99105 ( hasPreview ? previewWidth : 0 ) ,
@@ -159,9 +165,9 @@ export function FloatingWorkingControl(props: {
159165 hasAgents ||
160166 hasQueue ||
161167 ( props . devicePreview !== null && props . browserPreview !== null ) ;
162- // The queue, agents, and reconnect labels have separate tap targets.
168+ // The stop, queue, agents, and reconnect labels have separate tap targets.
163169 const statusInteractive = props . status ?. kind === "connection" ;
164- const capsuleInteractive = statusInteractive || hasQueue || hasAgents || hasPreview ;
170+ const capsuleInteractive = statusInteractive || hasStop || hasQueue || hasAgents || hasPreview ;
165171 // The host stays centered on the capsule, but its measurement constraint
166172 // comes from the overlay, independent of the capsule's current width.
167173 const statusContent =
@@ -192,6 +198,21 @@ export function FloatingWorkingControl(props: {
192198 const capsuleContent = (
193199 < View className = "flex-row items-center" >
194200 { statusContent }
201+ { backgroundStop !== null ? (
202+ < Pressable
203+ accessibilityRole = "button"
204+ accessibilityLabel = { backgroundStop . stopping ? "Stopping" : "Stop background work" }
205+ disabled = { backgroundStop . stopping }
206+ onPress = { backgroundStop . onPress }
207+ onLayout = { ( event ) => setStopWidth ( event . nativeEvent . layout . width ) }
208+ className = "h-11 flex-row items-center gap-1.5 px-3 active:opacity-70"
209+ >
210+ < View className = "mr-1 h-4 w-px bg-border" />
211+ < Text className = "font-t3-medium text-xs text-danger-foreground" numberOfLines = { 1 } >
212+ { backgroundStop . stopping ? "Stopping…" : "Stop" }
213+ </ Text >
214+ </ Pressable >
215+ ) : null }
195216 { hasPreview ? (
196217 < View
197218 className = "h-11 flex-row items-center"
0 commit comments