@@ -2368,6 +2368,123 @@ describe("deriveMessagesTimelineRows", () => {
23682368 ] ) ;
23692369 } ) ;
23702370
2371+ it ( "keeps answered questions in their own row outside tool groups and turn folds" , ( ) => {
2372+ const threadId = ThreadId . make ( "answered-question-thread" ) ;
2373+ const runId = RunId . make ( "answered-question-run" ) ;
2374+ const requestId = RuntimeRequestId . make ( "scope-question" ) ;
2375+ const at = ( second : number ) =>
2376+ DateTime . makeUnsafe ( new Date ( Date . UTC ( 2026 , 9 , 17 , 12 , 0 , second ) ) . toISOString ( ) ) ;
2377+ const base = ( id : string , ordinal : number , second : number ) => ( {
2378+ id : TurnItemId . make ( id ) ,
2379+ threadId,
2380+ runId,
2381+ nodeId : null ,
2382+ providerThreadId : null ,
2383+ providerTurnId : null ,
2384+ nativeItemRef : null ,
2385+ parentItemId : null ,
2386+ ordinal,
2387+ status : "completed" as const ,
2388+ title : null ,
2389+ startedAt : at ( second ) ,
2390+ completedAt : at ( second ) ,
2391+ updatedAt : at ( second ) ,
2392+ } ) ;
2393+ const command = ( id : string , ordinal : number , second : number ) => ( {
2394+ ...base ( id , ordinal , second ) ,
2395+ type : "command_execution" as const ,
2396+ input : `cat ${ id } ` ,
2397+ } ) ;
2398+ const items = ( settled : boolean ) =>
2399+ [
2400+ {
2401+ ...base ( "prompt" , 0 , 0 ) ,
2402+ type : "user_message" as const ,
2403+ messageId : MessageId . make ( "prompt" ) ,
2404+ text : "Pick a repository" ,
2405+ attachments : [ ] ,
2406+ inputIntent : "turn_start" as const ,
2407+ createdBy : "user" as const ,
2408+ creationSource : "web" as const ,
2409+ } ,
2410+ command ( "before" , 1 , 1 ) ,
2411+ {
2412+ ...base ( "question" , 2 , 2 ) ,
2413+ type : "user_input_request" as const ,
2414+ requestId,
2415+ questions : [ ] ,
2416+ questionAnswer : {
2417+ requestId,
2418+ questionTextById : { scope : "Which repository?" } ,
2419+ answers : { scope : "The private one" } ,
2420+ attachmentsByQuestionId : { } ,
2421+ } ,
2422+ } ,
2423+ command ( "after" , 3 , 3 ) ,
2424+ settled
2425+ ? {
2426+ ...base ( "answer" , 4 , 5 ) ,
2427+ type : "assistant_message" as const ,
2428+ messageId : MessageId . make ( "answer" ) ,
2429+ text : "Done" ,
2430+ streaming : false ,
2431+ }
2432+ : { ...command ( "running" , 4 , 4 ) , status : "running" as const , completedAt : null } ,
2433+ ] . map ( ( item , position ) => ( {
2434+ position,
2435+ visibility : "local" as const ,
2436+ sourceThreadId : threadId ,
2437+ sourceItemId : item . id ,
2438+ item,
2439+ } ) ) ;
2440+ const rows = ( settled : boolean , expandedRunIds ?: ReadonlySet < RunId > ) =>
2441+ deriveMessagesTimelineRows ( {
2442+ timelineEntries : deriveTimelineEntriesFromVisibleTurnItems ( {
2443+ visibleTurnItems : items ( settled ) ,
2444+ optimisticMessages : [ ] ,
2445+ } ) ,
2446+ latestRun : {
2447+ runId,
2448+ status : settled ? "completed" : "running" ,
2449+ startedAt : DateTime . formatIso ( at ( 0 ) ) ,
2450+ completedAt : settled ? DateTime . formatIso ( at ( 5 ) ) : null ,
2451+ } ,
2452+ runningRunId : settled ? null : runId ,
2453+ isWorking : ! settled ,
2454+ activeTurnStartedAt : settled ? null : DateTime . formatIso ( at ( 0 ) ) ,
2455+ ...( expandedRunIds === undefined ? { } : { expandedRunIds } ) ,
2456+ turnDiffSummaries : [ ] ,
2457+ supportsConversationRollback : false ,
2458+ } ) ;
2459+ const shape = ( timeline : ReadonlyArray < MessagesTimelineRow > ) =>
2460+ timeline . map ( ( row ) =>
2461+ row . kind === "turn-fold"
2462+ ? "fold"
2463+ : row . kind === "message"
2464+ ? `${ row . message . role } :${ row . message . id } `
2465+ : row . kind === "work" || row . kind === "work-live"
2466+ ? `${ row . kind } :${ row . groupedEntries . map ( ( entry ) => entry . id ) . join ( " + " ) } `
2467+ : row . kind ,
2468+ ) ;
2469+
2470+ expect ( shape ( rows ( true ) ) ) . toEqual ( [ "user:prompt" , "fold" , "work:question" , "assistant:answer" ] ) ;
2471+ expect ( shape ( rows ( true , new Set ( [ runId ] ) ) ) ) . toEqual ( [
2472+ "user:prompt" ,
2473+ "fold" ,
2474+ "work:before" ,
2475+ "work:question" ,
2476+ "work:after" ,
2477+ "assistant:answer" ,
2478+ ] ) ;
2479+ expect ( shape ( rows ( false ) ) ) . toEqual ( [
2480+ "user:prompt" ,
2481+ "working" ,
2482+ "work:before" ,
2483+ "work:question" ,
2484+ "work-live:after + running" ,
2485+ ] ) ;
2486+ } ) ;
2487+
23712488 it ( "keeps imported V1 turns folded once the thread's first V2 run starts" , ( ) => {
23722489 const at = ( second : number ) => `2026-01-01T00:00:${ String ( second ) . padStart ( 2 , "0" ) } Z` ;
23732490 const message = (
0 commit comments