@@ -27,6 +27,7 @@ import {
2727 resolveWorkEntryToolPresentation ,
2828 summarizeToolGroup ,
2929 toolGroupSummaryKind ,
30+ workEntriesViewedImagePaths ,
3031 type ToolGroupSummaryKind ,
3132 type WorkLogPresentationEntry ,
3233 type WorkLogToolLifecycleStatus ,
@@ -224,6 +225,14 @@ type ThreadFeedEntryContent =
224225 readonly shimmer : boolean ;
225226 readonly thought ?: string ;
226227 }
228+ | {
229+ /** Images the agent opened in the tool group above, kept visible while the group is collapsed. */
230+ readonly type : "viewed-images" ;
231+ readonly id : string ;
232+ readonly createdAt : string ;
233+ readonly runId : RunId | null ;
234+ readonly paths : ReadonlyArray < string > ;
235+ }
227236 | {
228237 readonly type : "run-fold" ;
229238 readonly deferredWorkItemIds ?: ReadonlyArray < string > ;
@@ -1252,7 +1261,10 @@ const supersededReasoningGroups = new WeakMap<ThreadFeedActivityGroup, ThreadFee
12521261const trailingReasoningGroups = new WeakMap < ThreadFeedActivityGroup , ThreadFeedActivityGroup > ( ) ;
12531262
12541263function settleSupersededReasoning (
1255- entry : Exclude < ThreadFeedEntry , { readonly type : "run-fold" | "work-toggle" | "thinking" } > ,
1264+ entry : Exclude <
1265+ ThreadFeedEntry ,
1266+ { readonly type : "run-fold" | "work-toggle" | "thinking" | "viewed-images" }
1267+ > ,
12561268 tail : boolean ,
12571269) {
12581270 if ( entry . type !== "activity-group" ) return entry ;
@@ -1527,7 +1539,10 @@ export function deriveThreadFeedPresentation(
15271539 const lastEntryByRun = new Map < RunId , number > ( ) ;
15281540
15291541 const retainedFeed : Array <
1530- Exclude < ThreadFeedEntry , { readonly type : "run-fold" | "work-toggle" | "thinking" } >
1542+ Exclude <
1543+ ThreadFeedEntry ,
1544+ { readonly type : "run-fold" | "work-toggle" | "thinking" | "viewed-images" }
1545+ >
15311546 > = [ ] ;
15321547 const retainedFeedIndices : number [ ] = [ ] ;
15331548 const { toolCallVisibility, revealedMessageId } = display ;
@@ -1540,7 +1555,12 @@ export function deriveThreadFeedPresentation(
15401555 : null ;
15411556 for ( let index = start ; index < feed . length ; index += 1 ) {
15421557 let entry = feed [ index ] ! ;
1543- if ( entry . type === "run-fold" || entry . type === "work-toggle" || entry . type === "thinking" )
1558+ if (
1559+ entry . type === "run-fold" ||
1560+ entry . type === "work-toggle" ||
1561+ entry . type === "thinking" ||
1562+ entry . type === "viewed-images"
1563+ )
15441564 continue ;
15451565 const runId = feedEntryRunId ( entry ) ;
15461566 if ( runId !== null ) {
@@ -1819,7 +1839,10 @@ function thinkingRow(createdAt: string, runId: RunId | null, label: string | nul
18191839
18201840function appendPresentedFeedEntry (
18211841 result : ThreadFeedEntry [ ] ,
1822- entry : Exclude < ThreadFeedEntry , { readonly type : "run-fold" | "work-toggle" | "thinking" } > ,
1842+ entry : Exclude <
1843+ ThreadFeedEntry ,
1844+ { readonly type : "run-fold" | "work-toggle" | "thinking" | "viewed-images" }
1845+ > ,
18231846 expandedWorkGroupIds : ReadonlySet < string > ,
18241847 activeRunId : RunId | null ,
18251848 isWorking : boolean ,
@@ -1890,16 +1913,27 @@ function appendActivityGroupRows(
18901913 let groupableRun : ThreadFeedActivity [ ] = [ ] ;
18911914 const flushGroupableRun = ( isTrailingRun : boolean ) => {
18921915 if ( groupableRun . length === 0 ) return ;
1916+ const groupId = `work-group:${ groupAnchorIdByActivityId . get ( groupableRun [ 0 ] ! . id ) ?? groupableRun [ 0 ] ! . id } ` ;
18931917 appendToolGroupRows (
18941918 result ,
18951919 entry ,
18961920 groupableRun ,
1897- `work-group: ${ groupAnchorIdByActivityId . get ( groupableRun [ 0 ] ! . id ) ?? groupableRun [ 0 ] ! . id } ` ,
1921+ groupId ,
18981922 expandedWorkGroupIds ,
18991923 activeRunId ,
19001924 isWorking ,
19011925 activeTail && isTrailingRun ,
19021926 ) ;
1927+ const paths = workEntriesViewedImagePaths ( groupableRun . map ( ( activity ) => activity . workEntry ) ) ;
1928+ if ( paths . length > 0 ) {
1929+ result . push ( {
1930+ type : "viewed-images" ,
1931+ id : `${ groupId } :viewed-images` ,
1932+ createdAt : groupableRun [ 0 ] ! . createdAt ,
1933+ runId : groupableRun [ 0 ] ! . runId ,
1934+ paths,
1935+ } ) ;
1936+ }
19031937 groupableRun = [ ] ;
19041938 } ;
19051939 for ( const activity of activities ) {
0 commit comments