55 CheckpointScopeId ,
66 NodeId ,
77 PlanId ,
8+ ProviderDriverKind ,
89 ProviderInstanceId ,
910 ProviderThreadId ,
1011 RunAttemptId ,
@@ -31,6 +32,7 @@ import {
3132 derivePhase ,
3233 findLatestProposedPlan ,
3334 isLatestRunSettled ,
35+ selectComposerTasksPlan ,
3436 selectHandoffImageResources ,
3537 selectMessageImageResources ,
3638 createMessageAttachmentPreviewProjector ,
@@ -972,6 +974,141 @@ describe("V2 session presentation", () => {
972974 } ) ;
973975} ) ;
974976
977+ describe ( "composer tasks drawer" , ( ) => {
978+ const projection = makeThreadProjectionFixture ( ) ;
979+ const now = projection . updatedAt ;
980+
981+ function providerThread ( id : string , driver : string ) {
982+ return {
983+ id : ProviderThreadId . make ( id ) ,
984+ driver : ProviderDriverKind . make ( driver ) ,
985+ providerInstanceId : ProviderInstanceId . make ( driver ) ,
986+ providerSessionId : null ,
987+ appThreadId : projection . thread . id ,
988+ ownerNodeId : null ,
989+ nativeThreadRef : null ,
990+ nativeConversationHeadRef : null ,
991+ status : "idle" as const ,
992+ firstRunOrdinal : null ,
993+ lastRunOrdinal : null ,
994+ handoffIds : [ ] ,
995+ forkedFrom : null ,
996+ createdAt : now ,
997+ updatedAt : now ,
998+ } ;
999+ }
1000+
1001+ function run ( id : string , ordinal : number , providerThreadId : string | null ) {
1002+ return {
1003+ id : RunId . make ( id ) ,
1004+ threadId : projection . thread . id ,
1005+ ordinal,
1006+ providerInstanceId : projection . thread . providerInstanceId ,
1007+ modelSelection : projection . thread . modelSelection ,
1008+ providerThreadId : providerThreadId === null ? null : ProviderThreadId . make ( providerThreadId ) ,
1009+ userMessageId : MessageId . make ( `message-${ id } ` ) ,
1010+ rootNodeId : null ,
1011+ activeAttemptId : null ,
1012+ status : "completed" as const ,
1013+ requestedAt : now ,
1014+ startedAt : now ,
1015+ completedAt : now ,
1016+ checkpointId : null ,
1017+ contextHandoffId : null ,
1018+ } ;
1019+ }
1020+
1021+ function plan ( runId : string , statuses : ReadonlyArray < "pending" | "inProgress" | "completed" > ) {
1022+ return {
1023+ createdAt : "2026-06-20T00:00:00.000Z" ,
1024+ runId : RunId . make ( runId ) ,
1025+ steps : statuses . map ( ( status , index ) => ( { step : `Step ${ index } ` , status } ) ) ,
1026+ } ;
1027+ }
1028+
1029+ const threads = [ providerThread ( "claude" , "claudeAgent" ) , providerThread ( "codex" , "codex" ) ] ;
1030+ const openList = plan ( "claude-1" , [ "completed" , "inProgress" , "pending" ] ) ;
1031+
1032+ it ( "shows the running turn's own list for every provider" , ( ) => {
1033+ const codexPlan = plan ( "codex-1" , [ "completed" , "completed" ] ) ;
1034+ const withRuns = {
1035+ ...projection ,
1036+ runs : [ run ( "codex-1" , 1 , "codex" ) ] ,
1037+ providerThreads : threads ,
1038+ } ;
1039+ expect ( selectComposerTasksPlan ( withRuns , codexPlan , RunId . make ( "codex-1" ) , false ) ) . toBe (
1040+ codexPlan ,
1041+ ) ;
1042+ } ) ;
1043+
1044+ it ( "keeps a Claude list with open steps after its run settles and during later Claude runs" , ( ) => {
1045+ const settled = {
1046+ ...projection ,
1047+ runs : [ run ( "claude-1" , 1 , "claude" ) ] ,
1048+ providerThreads : threads ,
1049+ } ;
1050+ expect ( selectComposerTasksPlan ( settled , openList , RunId . make ( "claude-1" ) , true ) ) . toBe ( openList ) ;
1051+
1052+ const laterRun = {
1053+ ...settled ,
1054+ runs : [ ...settled . runs , run ( "claude-2" , 2 , "claude" ) ] ,
1055+ } ;
1056+ expect ( selectComposerTasksPlan ( laterRun , openList , RunId . make ( "claude-2" ) , false ) ) . toBe (
1057+ openList ,
1058+ ) ;
1059+ } ) ;
1060+
1061+ it ( "hides a settled Claude list once every step is completed" , ( ) => {
1062+ const settled = {
1063+ ...projection ,
1064+ runs : [ run ( "claude-1" , 1 , "claude" ) ] ,
1065+ providerThreads : threads ,
1066+ } ;
1067+ const done = plan ( "claude-1" , [ "completed" , "completed" ] ) ;
1068+ expect ( selectComposerTasksPlan ( settled , done , RunId . make ( "claude-1" ) , true ) ) . toBeNull ( ) ;
1069+ } ) ;
1070+
1071+ it ( "keeps today's behavior for other providers once their run settles" , ( ) => {
1072+ const codexPlan = plan ( "codex-1" , [ "completed" , "pending" ] ) ;
1073+ const withRuns = {
1074+ ...projection ,
1075+ runs : [ run ( "codex-1" , 1 , "codex" ) , run ( "codex-2" , 2 , "codex" ) ] ,
1076+ providerThreads : threads ,
1077+ } ;
1078+ expect ( selectComposerTasksPlan ( withRuns , codexPlan , RunId . make ( "codex-1" ) , true ) ) . toBeNull ( ) ;
1079+ expect ( selectComposerTasksPlan ( withRuns , codexPlan , RunId . make ( "codex-2" ) , false ) ) . toBeNull ( ) ;
1080+ } ) ;
1081+
1082+ it ( "hides a Claude list once a later run moves to another provider thread" , ( ) => {
1083+ const switched = {
1084+ ...projection ,
1085+ runs : [ run ( "claude-1" , 1 , "claude" ) , run ( "codex-2" , 2 , "codex" ) ] ,
1086+ providerThreads : threads ,
1087+ } ;
1088+ expect ( selectComposerTasksPlan ( switched , openList , RunId . make ( "codex-2" ) , false ) ) . toBeNull ( ) ;
1089+
1090+ const freshClaudeSession = {
1091+ ...switched ,
1092+ providerThreads : [ ...threads , providerThread ( "claude-fresh" , "claudeAgent" ) ] ,
1093+ runs : [ run ( "claude-1" , 1 , "claude" ) , run ( "claude-3" , 3 , "claude-fresh" ) ] ,
1094+ } ;
1095+ expect (
1096+ selectComposerTasksPlan ( freshClaudeSession , openList , RunId . make ( "claude-3" ) , true ) ,
1097+ ) . toBeNull ( ) ;
1098+ } ) ;
1099+
1100+ it ( "keeps the Claude list while a newer run has not reached a provider thread yet" , ( ) => {
1101+ const queued = {
1102+ ...projection ,
1103+ runs : [ run ( "claude-1" , 1 , "claude" ) , run ( "pending-2" , 2 , null ) ] ,
1104+ providerThreads : threads ,
1105+ } ;
1106+ expect ( selectComposerTasksPlan ( queued , openList , RunId . make ( "pending-2" ) , false ) ) . toBe (
1107+ openList ,
1108+ ) ;
1109+ } ) ;
1110+ } ) ;
1111+
9751112describe ( "native provider presentation in the v2 timeline" , ( ) => {
9761113 const timestamp = DateTime . makeUnsafe ( "2026-09-04T12:00:00.000Z" ) ;
9771114 const base = {
0 commit comments