@@ -1842,3 +1842,81 @@ describe("streamed feed updates", () => {
18421842 expect ( showsDelegation ( steps [ 3 ] ! ) ) . toBe ( false ) ;
18431843 } ) ;
18441844} ) ;
1845+
1846+ it . each ( [ false , true ] ) (
1847+ "caps live approval headers while preserving the prompt (grouped: %s)" ,
1848+ ( grouped ) => {
1849+ const at = "2026-06-20T00:00:02.000Z" ;
1850+ const prompt = `python3 - <<'PY'\n${ "print('approval')\n" . repeat ( 400 ) } PY` ;
1851+ const approval : OrchestrationV2TurnItem = {
1852+ ...base ( "long-approval" , at , 2 ) ,
1853+ type : "approval_request" ,
1854+ status : "waiting" ,
1855+ completedAt : null ,
1856+ requestId : RuntimeRequestId . make ( "long-approval" ) ,
1857+ requestKind : "command" ,
1858+ prompt,
1859+ } ;
1860+ const presented = deriveThreadFeedPresentation (
1861+ buildThreadFeed ( [
1862+ projected ( userMessage ( ) , 0 ) ,
1863+ ...( grouped ? [ projected ( command ( ) , 1 ) ] : [ ] ) ,
1864+ projected ( approval , 2 ) ,
1865+ ] ) ,
1866+ { runId, status : "running" , startedAt : at , completedAt : null } ,
1867+ new Set ( ) ,
1868+ new Set ( ) ,
1869+ at ,
1870+ ) ;
1871+ const header = presented . find ( ( row ) =>
1872+ grouped ? row . type === "work-toggle" : row . type === "activity-group" ,
1873+ ) ;
1874+ const label =
1875+ header ?. type === "work-toggle"
1876+ ? header . summary
1877+ : header ?. type === "activity-group"
1878+ ? header . activities [ 0 ] ?. groupStandIn ?. label
1879+ : undefined ;
1880+ expect ( label ) . toBeDefined ( ) ;
1881+ expect ( label ! . length ) . toBeLessThanOrEqual ( 203 ) ;
1882+ expect ( label ) . toMatch ( / ^ p y t h o n 3 - < < ' P Y ' p r i n t / ) ;
1883+ expect ( label ) . not . toContain ( "\n" ) ;
1884+ const feed = buildThreadFeed ( [ projected ( approval , 0 ) ] ) ;
1885+ const activity = feed . flatMap ( ( row ) =>
1886+ row . type === "activity-group" ? row . activities : [ ] ,
1887+ ) [ 0 ] ! ;
1888+ expect ( activity . detail ) . toBe ( prompt ) ;
1889+ expect ( JSON . parse ( activity . getFullDetail ( ) ! ) . item ) . toMatchObject ( { prompt } ) ;
1890+ expect ( activity . getCopyText ( ) ) . toContain ( prompt ) ;
1891+ } ,
1892+ ) ;
1893+
1894+ it ( "caps live thought previews while preserving reasoning detail" , ( ) => {
1895+ const at = "2026-06-20T00:00:02.000Z" ;
1896+ const text = "Considering the pending approval\n" . repeat ( 100 ) ;
1897+ const thought : OrchestrationV2TurnItem = {
1898+ ...base ( "long-thought" , at , 1 ) ,
1899+ type : "reasoning" ,
1900+ status : "running" ,
1901+ completedAt : null ,
1902+ text,
1903+ streaming : true ,
1904+ } ;
1905+ const feed = buildThreadFeed ( [ projected ( userMessage ( ) , 0 ) , projected ( thought , 1 ) ] ) ;
1906+ const rows = deriveThreadFeedPresentation (
1907+ feed ,
1908+ { runId, status : "running" , startedAt : at , completedAt : null } ,
1909+ new Set ( ) ,
1910+ new Set ( ) ,
1911+ at ,
1912+ ) ;
1913+ const header = rows . find ( ( row ) => row . type === "work-toggle" ) ;
1914+ expect ( header ) . toMatchObject ( { summary : "Thinking" , live : true } ) ;
1915+ expect ( header ?. thought ) . toMatch ( / ^ C o n s i d e r i n g t h e p e n d i n g a p p r o v a l / ) ;
1916+ expect ( header ?. thought ) . not . toContain ( "\n" ) ;
1917+ expect ( header ! . thought ! . length ) . toBeLessThanOrEqual ( 203 ) ;
1918+ const activity = feed . flatMap ( ( row ) => ( row . type === "activity-group" ? row . activities : [ ] ) ) [ 0 ] ! ;
1919+ expect ( activity . detail ) . toBe ( text ) ;
1920+ expect ( JSON . parse ( activity . getFullDetail ( ) ! ) . item ) . toMatchObject ( { text } ) ;
1921+ expect ( activity . getCopyText ( ) ) . toContain ( text ) ;
1922+ } ) ;
0 commit comments