@@ -68,6 +68,8 @@ export const FLOATING_WORKING_CONTROL_COVERAGE = CONTROL_OVERLAY_OFFSET + CONTRO
6868export function FloatingWorkingControl ( props : {
6969 readonly colorScheme : "light" | "dark" ;
7070 readonly status : FloatingWorkingStatus | null ;
71+ /** Stop for background work that outlived its turn, beside the label naming it. */
72+ readonly backgroundStop : { readonly stopping : boolean ; readonly onPress : ( ) => void } | null ;
7173 readonly devicePreview : { readonly count : number ; readonly onPress : ( ) => void } | null ;
7274 readonly browserPreview : { readonly count : number ; readonly onPress : ( ) => void } | null ;
7375 readonly showScrollToEnd : boolean ;
@@ -83,6 +85,9 @@ export function FloatingWorkingControl(props: {
8385 const [ overlayWidth , setOverlayWidth ] = useState ( windowWidth ) ;
8486 const [ queueWidth , setQueueWidth ] = useState ( 0 ) ;
8587 const [ agentsWidth , setAgentsWidth ] = useState ( 0 ) ;
88+ const [ stopWidth , setStopWidth ] = useState ( 0 ) ;
89+ const backgroundStop = props . status ?. kind === "background" ? props . backgroundStop : null ;
90+ const hasStop = backgroundStop !== null ;
8691 const hasQueue = props . queuedCount > 0 ;
8792 const hasPreview = props . devicePreview !== null || props . browserPreview !== null ;
8893 const [ previewWidth , setPreviewWidth ] = useState ( 0 ) ;
@@ -95,6 +100,7 @@ export function FloatingWorkingControl(props: {
95100 Math . min ( overlayWidth , windowWidth ) -
96101 CONTROL_HEIGHT -
97102 32 -
103+ ( hasStop ? stopWidth : 0 ) -
98104 ( hasQueue ? queueWidth : 0 ) -
99105 ( hasAgents ? agentsWidth : 0 ) -
100106 ( hasPreview ? previewWidth : 0 ) ,
@@ -160,9 +166,9 @@ export function FloatingWorkingControl(props: {
160166 hasAgents ||
161167 hasQueue ||
162168 ( props . devicePreview !== null && props . browserPreview !== null ) ;
163- // The queue, agents, and reconnect labels have separate tap targets.
169+ // The stop, queue, agents, and reconnect labels have separate tap targets.
164170 const statusInteractive = props . status ?. kind === "connection" ;
165- const capsuleInteractive = statusInteractive || hasQueue || hasAgents || hasPreview ;
171+ const capsuleInteractive = statusInteractive || hasStop || hasQueue || hasAgents || hasPreview ;
166172 // The host stays centered on the capsule, but its measurement constraint
167173 // comes from the overlay, independent of the capsule's current width.
168174 const statusContent =
@@ -193,6 +199,21 @@ export function FloatingWorkingControl(props: {
193199 const capsuleContent = (
194200 < View className = "flex-row items-center" >
195201 { statusContent }
202+ { backgroundStop !== null ? (
203+ < Pressable
204+ accessibilityRole = "button"
205+ accessibilityLabel = { backgroundStop . stopping ? "Stopping" : "Stop background work" }
206+ disabled = { backgroundStop . stopping }
207+ onPress = { backgroundStop . onPress }
208+ onLayout = { ( event ) => setStopWidth ( event . nativeEvent . layout . width ) }
209+ className = "h-11 flex-row items-center gap-1.5 px-3 active:opacity-70"
210+ >
211+ < View className = "mr-1 h-4 w-px bg-border" />
212+ < Text className = "font-t3-medium text-xs text-danger-foreground" numberOfLines = { 1 } >
213+ { backgroundStop . stopping ? "Stopping…" : "Stop" }
214+ </ Text >
215+ </ Pressable >
216+ ) : null }
196217 { hasPreview ? (
197218 < View
198219 className = "h-11 flex-row items-center"
0 commit comments