1- import { HStack , Image , Link , Spacer , Text , VStack } from "@expo/ui/swift-ui" ;
1+ import { Divider , HStack , Image , Link , Spacer , Text , VStack } from "@expo/ui/swift-ui" ;
22import {
33 fixedSize ,
44 font ,
@@ -27,6 +27,7 @@ export interface AgentActivityWidgetProps {
2727 | "deepLink"
2828 >
2929 > ;
30+ readonly supplementalActivities ?: AgentActivityWidgetProps [ "activities" ] ;
3031 readonly baseUrl ?: string ;
3132 readonly freshUntil ?: number ;
3233 readonly updatedAt ?: string ;
@@ -39,7 +40,21 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
3940 "widget" ;
4041 const now = Math . max ( environment . date ?. getTime ( ) ?? 0 , Date . now ( ) ) ;
4142 const expired = ( props . freshUntil ?? Infinity ) <= now ;
42- const rows = ( props . activities ?? [ ] ) . map ( ( row ) =>
43+ const large = environment . widgetFamily === "systemLarge" ;
44+ const activityRows = [ ...( props . activities ?? [ ] ) ] ;
45+ if ( large && props . source === "snapshot" ) {
46+ for ( const row of props . supplementalActivities ?? [ ] ) {
47+ if (
48+ ! activityRows . some (
49+ ( existing ) =>
50+ existing . environmentId === row . environmentId && existing . threadId === row . threadId ,
51+ )
52+ ) {
53+ activityRows . push ( row ) ;
54+ }
55+ }
56+ }
57+ const rows = activityRows . map ( ( row ) =>
4358 expired && row . phase !== "completed" && row . phase !== "failed"
4459 ? { ...row , phase : "stale" as const , status : "Out of date" }
4560 : row ,
@@ -48,8 +63,7 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
4863 const activeCount = props . activeCount ?? 0 ;
4964 const accessory = environment . widgetFamily === "accessoryRectangular" ;
5065 const small = environment . widgetFamily === "systemSmall" ;
51- const large = environment . widgetFamily === "systemLarge" ;
52- const roomier = ! small && ! accessory ;
66+ const listLayout = ! small && ! accessory ;
5367 const textSize = environment . dynamicTypeSize ?? "large" ;
5468 const accessibility = textSize . startsWith ( "accessibility" ) ;
5569 const enlarged = textSize === "xxxLarge" ;
@@ -60,12 +74,16 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
6074 ? 3
6175 : textSize === "xLarge" || textSize === "xxLarge"
6276 ? 4
63- : 5
64- : accessibility || enlarged
77+ : 7
78+ : accessibility
6579 ? 1
66- : 2 ;
80+ : enlarged
81+ ? 3
82+ : textSize === "xLarge" || textSize === "xxLarge"
83+ ? 4
84+ : 5 ;
6785 const hero = rows [ 0 ] ;
68- const showRows = roomier && rows . length > 0 ;
86+ const showRows = listLayout && rows . length > 0 ;
6987 const monochrome =
7088 environment . widgetRenderingMode !== "fullColor" || environment . isLuminanceReduced ;
7189 const statusColor = ( row : AgentActivityWidgetProps [ "activities" ] [ number ] ) => {
@@ -102,7 +120,7 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
102120 const text = (
103121 < Text
104122 modifiers = { [
105- font ( roomier ? { textStyle : "caption2" } : { size : 11 , weight : "medium" } ) ,
123+ font ( listLayout ? { textStyle : "caption2" } : { size : 11 , weight : "medium" } ) ,
106124 foregroundStyle ( color ) ,
107125 lineLimit ( 1 ) ,
108126 ...( horizontal ? [ layoutPriority ( 1 ) ] : [ ] ) ,
@@ -126,33 +144,41 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
126144 return (
127145 < VStack
128146 alignment = "leading"
129- spacing = { accessory ? 5 : showRows ? 8 : 10 }
147+ spacing = { accessory ? 5 : showRows ? ( large ? 8 : 4 ) : 10 }
130148 modifiers = { [
131149 frame ( { maxWidth : Infinity , maxHeight : Infinity , alignment : "topLeading" } ) ,
132150 ...( props . baseUrl ? [ widgetURL ( `${ props . baseUrl } ${ hero ?. deepLink . slice ( 1 ) ?? "" } ` ) ] : [ ] ) ,
133151 ] }
134152 >
135153 { showRows ? (
136- rows . slice ( 0 , rowLimit ) . map ( ( row ) => {
154+ rows . slice ( 0 , rowLimit ) . flatMap ( ( row , index ) => {
137155 const content = (
138- < HStack key = { `${ row . environmentId } :${ row . threadId } ` } spacing = { 10 } alignment = "center" >
156+ < HStack
157+ key = { `${ row . environmentId } :${ row . threadId } ` }
158+ spacing = { 10 }
159+ alignment = "center"
160+ modifiers = { large ? [ ] : [ frame ( { maxHeight : Infinity } ) ] }
161+ >
139162 { ! accessibility ? (
140163 < Image
141164 systemName = { statusSymbols [ row . phase ] }
142- modifiers = { [ font ( { textStyle : "body" } ) , foregroundStyle ( statusColor ( row ) ) ] }
165+ modifiers = { [
166+ font ( { textStyle : large ? "body" : "subheadline" } ) ,
167+ foregroundStyle ( statusColor ( row ) ) ,
168+ ] }
143169 />
144170 ) : null }
145171 < VStack alignment = "leading" spacing = { 3 } >
146172 < Text
147173 modifiers = { [
148174 font ( { textStyle : "subheadline" , weight : "semibold" } ) ,
149175 foregroundStyle ( "primary" ) ,
150- lineLimit ( large && ! accessibility ? 2 : 1 ) ,
176+ lineLimit ( large && rows . length <= 5 && ! accessibility ? 2 : 1 ) ,
151177 ] }
152178 >
153179 { row . threadTitle }
154180 </ Text >
155- { ! accessibility || large ? (
181+ { large ? (
156182 < Text
157183 modifiers = { [
158184 font ( { textStyle : "caption2" } ) ,
@@ -168,7 +194,7 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
168194 { renderStatus ( row , true ) }
169195 </ HStack >
170196 ) ;
171- return props . baseUrl ? (
197+ const linked = props . baseUrl ? (
172198 < Link
173199 key = { `${ row . environmentId } :${ row . threadId } ` }
174200 destination = { `${ props . baseUrl } ${ row . deepLink . slice ( 1 ) } ` }
@@ -178,6 +204,9 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
178204 ) : (
179205 content
180206 ) ;
207+ return large && index > 0 && index === ( props . activities ?. length ?? 0 )
208+ ? [ < Divider key = "activity-sections" /> , linked ]
209+ : [ linked ] ;
181210 } )
182211 ) : hero ? (
183212 < VStack alignment = "leading" spacing = { accessory ? 3 : 8 } >
@@ -206,11 +235,11 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
206235 < Text
207236 modifiers = { [
208237 font (
209- roomier
238+ listLayout
210239 ? { textStyle : "headline" }
211240 : { size : accessory ? 13 : 17 , weight : "semibold" } ,
212241 ) ,
213- lineLimit ( accessory || ( roomier && ! large ) ? 1 : 2 ) ,
242+ lineLimit ( accessory || ( listLayout && ! large ) ? 1 : 2 ) ,
214243 ] }
215244 >
216245 { props . source === "loading"
@@ -223,10 +252,10 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
223252 ? "Ready when you are"
224253 : "Open T3 Code" }
225254 </ Text >
226- { ! ( roomier && accessibility && ! large ) ? (
255+ { ! ( listLayout && accessibility && ! large ) ? (
227256 < Text
228257 modifiers = { [
229- font ( roomier ? { textStyle : "caption2" } : { size : 12 } ) ,
258+ font ( listLayout ? { textStyle : "caption2" } : { size : 12 } ) ,
230259 foregroundStyle ( "secondary" ) ,
231260 lineLimit ( accessory ? 1 : 3 ) ,
232261 ] }
@@ -236,12 +265,12 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
236265 ) : null }
237266 </ VStack >
238267 ) }
239- { ! accessory ? < Spacer minLength = { 0 } /> : null }
268+ { ! accessory && ! ( showRows && ! large ) ? < Spacer minLength = { 0 } /> : null }
240269 < HStack >
241270 < Spacer minLength = { 0 } />
242271 < Text
243272 modifiers = { [
244- font ( roomier ? { textStyle : "caption2" } : { size : 11 , weight : "medium" } ) ,
273+ font ( listLayout ? { textStyle : "caption2" } : { size : 11 , weight : "medium" } ) ,
245274 foregroundStyle ( "secondary" ) ,
246275 lineLimit ( 1 ) ,
247276 fixedSize ( { horizontal : false , vertical : true } ) ,
@@ -250,7 +279,7 @@ function AgentActivityWidget(props: AgentActivityWidgetProps, environment: Widge
250279 >
251280 { outOfDate
252281 ? "Out of date"
253- : activeCount > 0
282+ : activeCount > 0 || ( large && ( props . supplementalActivities ?. length ?? 0 ) > 0 )
254283 ? `${ activeCount } active`
255284 : rows . some ( ( row ) => row . phase === "failed" )
256285 ? "Failed"
0 commit comments