@@ -276,6 +276,55 @@ function makeThread(
276276}
277277
278278describe ( "buildThreadFeed" , ( ) => {
279+ it ( "folds question answers into tool history and only hides the matching async reply" , ( ) => {
280+ const createdAt = "2026-04-01T00:00:01.000Z" ;
281+ const activities = [
282+ makeActivity ( {
283+ id : EventId . make ( "question-request" ) ,
284+ kind : "user-input.requested" ,
285+ summary : "User input requested" ,
286+ createdAt,
287+ turnId : TurnId . make ( "question-turn" ) ,
288+ payload : {
289+ requestId : "question-1" ,
290+ questions : [ { id : "scope" , question : "Which scope?" } ] ,
291+ } ,
292+ } ) ,
293+ makeActivity ( {
294+ id : EventId . make ( "question-response" ) ,
295+ kind : "user-input.resolved" ,
296+ summary : "User input submitted" ,
297+ createdAt : "2026-04-01T00:00:02.000Z" ,
298+ turnId : TurnId . make ( "question-turn" ) ,
299+ payload : { requestId : "question-1" , answers : { scope : "Web" } } ,
300+ } ) ,
301+ ] ;
302+ const messages = [ "async-answer:question-1" , "real-user-message" , "async-answer:unloaded" ] . map (
303+ ( id ) => ( {
304+ id : MessageId . make ( id ) ,
305+ role : "user" as const ,
306+ text : "Web" ,
307+ turnId : TurnId . make ( "answer-turn" ) ,
308+ createdAt : "2026-04-01T00:00:03.000Z" ,
309+ updatedAt : "2026-04-01T00:00:03.000Z" ,
310+ streaming : false ,
311+ } ) ,
312+ ) ;
313+ const feed = buildThreadFeed ( { messages, activities } ) ;
314+ const rows = feed . flatMap ( ( entry ) => ( entry . type === "activity-group" ? entry . activities : [ ] ) ) ;
315+ expect ( rows ) . toHaveLength ( 1 ) ;
316+ expect ( rows [ 0 ] ?. workEntry ) . toMatchObject ( {
317+ tone : "tool" ,
318+ label : "User input submitted" ,
319+ questionAnswer : { questionTextById : { scope : "Which scope?" } , answers : { scope : "Web" } } ,
320+ } ) ;
321+ expect ( feed . flatMap ( ( entry ) => ( entry . type === "message" ? [ entry . message . id ] : [ ] ) ) ) . toEqual ( [
322+ "real-user-message" ,
323+ "async-answer:unloaded" ,
324+ ] ) ;
325+ expect ( buildThreadFeed ( { messages, activities : [ ] } ) ) . toHaveLength ( 3 ) ;
326+ } ) ;
327+
279328 it ( "reuses unchanged feed and presentation rows during an assistant text update" , ( ) => {
280329 const completedTurnId = TurnId . make ( "completed-turn" ) ;
281330 const activeTurnId = TurnId . make ( "active-turn" ) ;
0 commit comments