@@ -161,20 +161,22 @@ describe("buildThreadFeed", () => {
161161 return ;
162162 }
163163
164- expect ( group . activities ) . toEqual ( [
165- {
166- id : "tool-completed" ,
167- createdAt : "2026-04-01T00:00:02.000Z" ,
168- turnId : "turn-1" ,
169- summary : "Run tests" ,
170- detail : "bun run test" ,
171- fullDetail : "/bin/zsh -lc 'bun run test'" ,
172- copyText : "Run tests\nbun run test\n/bin/zsh -lc 'bun run test'" ,
173- icon : "command" ,
174- toolLike : true ,
175- status : "success" ,
176- } ,
177- ] ) ;
164+ expect ( group . activities ) . toHaveLength ( 1 ) ;
165+ expect ( group . activities [ 0 ] ) . toMatchObject ( {
166+ id : "tool-completed" ,
167+ createdAt : "2026-04-01T00:00:02.000Z" ,
168+ turnId : "turn-1" ,
169+ summary : "Run tests" ,
170+ detail : "bun run test" ,
171+ canExpand : true ,
172+ icon : "command" ,
173+ toolLike : true ,
174+ status : "success" ,
175+ } ) ;
176+ expect ( group . activities [ 0 ] ?. getFullDetail ( ) ) . toBe ( "/bin/zsh -lc 'bun run test'" ) ;
177+ expect ( group . activities [ 0 ] ?. getCopyText ( ) ) . toBe (
178+ "Run tests\nbun run test\n/bin/zsh -lc 'bun run test'" ,
179+ ) ;
178180 } ) ;
179181
180182 it ( "keeps MCP inputs available to expanded mobile work rows" , ( ) => {
@@ -223,8 +225,55 @@ describe("buildThreadFeed", () => {
223225 }
224226
225227 expect ( group . activities [ 0 ] ?. icon ) . toBe ( "wrench" ) ;
226- expect ( group . activities [ 0 ] ?. fullDetail ) . toContain ( '"query": "work log"' ) ;
227- expect ( group . activities [ 0 ] ?. fullDetail ) . toContain ( "repository.search" ) ;
228+ expect ( group . activities [ 0 ] ?. getFullDetail ( ) ) . toContain ( '"query": "work log"' ) ;
229+ expect ( group . activities [ 0 ] ?. getFullDetail ( ) ) . toContain ( "repository.search" ) ;
230+ } ) ;
231+
232+ it ( "defers large tool output expansion until a work row is opened or copied" , ( ) => {
233+ let serializedToolOutputs = 0 ;
234+ const activities = Array . from ( { length : 5_000 } , ( _ , index ) =>
235+ makeActivity ( {
236+ id : EventId . make ( `large-tool-${ index } ` ) ,
237+ kind : "tool.completed" ,
238+ tone : "tool" ,
239+ summary : `Tool ${ index } ` ,
240+ createdAt : new Date ( Date . UTC ( 2026 , 3 , 1 , 0 , 0 , index ) ) . toISOString ( ) ,
241+ payload : {
242+ title : `Tool ${ index } ` ,
243+ itemType : "mcp_tool_call" ,
244+ status : "completed" ,
245+ data : {
246+ item : {
247+ toJSON : ( ) => {
248+ serializedToolOutputs += 1 ;
249+ return { output : "x" . repeat ( 32_768 ) } ;
250+ } ,
251+ } ,
252+ } ,
253+ } ,
254+ } ) ,
255+ ) ;
256+ const thread = makeThread ( {
257+ id : ThreadId . make ( "thread-large-tools" ) ,
258+ projectId : ProjectId . make ( "project-1" ) ,
259+ title : "Large tools" ,
260+ activities,
261+ } ) ;
262+
263+ const feed = buildThreadFeed ( thread ) ;
264+ expect ( serializedToolOutputs ) . toBe ( 0 ) ;
265+
266+ const group = feed [ 0 ] ;
267+ expect ( group ) . toMatchObject ( { type : "activity-group" } ) ;
268+ if ( ! group || group . type !== "activity-group" ) {
269+ return ;
270+ }
271+
272+ expect ( group . activities ) . toHaveLength ( 5_000 ) ;
273+ expect ( group . activities [ 0 ] ?. getFullDetail ( ) ) . toContain ( '"output"' ) ;
274+ expect ( serializedToolOutputs ) . toBe ( 1 ) ;
275+ expect ( group . activities [ 0 ] ?. getCopyText ( ) ) . toContain ( '"output"' ) ;
276+ expect ( serializedToolOutputs ) . toBe ( 1 ) ;
228277 } ) ;
229278
230279 it ( "folds settled turn work while leaving the terminal answer visible" , ( ) => {
@@ -439,8 +488,9 @@ describe("buildThreadFeed", () => {
439488 turnId : null ,
440489 summary : `Tool ${ id } ` ,
441490 detail : null ,
442- fullDetail : null ,
443- copyText : id ,
491+ canExpand : false ,
492+ getFullDetail : ( ) => null ,
493+ getCopyText : ( ) => id ,
444494 icon : "command" ,
445495 toolLike : true ,
446496 status,
0 commit comments