@@ -1154,10 +1154,30 @@ describe("buildThreadListV2ListItems", () => {
11541154 now : NOW ,
11551155 } ) ;
11561156
1157- it ( "splices queued tasks between the active block and the settled tail " , ( ) => {
1157+ it ( "leads the list with unsent drafts and queued tasks, preserving section dividers " , ( ) => {
11581158 const items = buildThreadListV2ListItems ( {
11591159 items : layout . items ,
1160- pendingTasks : [ makePendingTask ( "queued-1" ) , makePendingTask ( "queued-2" ) ] ,
1160+ pendingTasks : [
1161+ {
1162+ kind : "draft" ,
1163+ key : "draft-task:new-task:unsent" ,
1164+ environmentId,
1165+ projectId : ProjectId . make ( "project-1" ) ,
1166+ projectTitle : undefined ,
1167+ projectCwd : undefined ,
1168+ branch : null ,
1169+ title : "unsent" ,
1170+ createdAt : NOW ,
1171+ draftKey : "new-task:unsent" ,
1172+ draft : {
1173+ text : "unsent" ,
1174+ attachments : [ ] ,
1175+ project : { environmentId, projectId : ProjectId . make ( "project-1" ) , createdAt : NOW } ,
1176+ } ,
1177+ } ,
1178+ makePendingTask ( "queued-1" ) ,
1179+ makePendingTask ( "queued-2" ) ,
1180+ ] ,
11611181 settledCount : layout . settledCount ,
11621182 settledShelfHeaderIndex : layout . settledShelfHeaderIndex ,
11631183 } ) ;
@@ -1172,13 +1192,18 @@ describe("buildThreadListV2ListItems", () => {
11721192 ? "snoozed-shelf"
11731193 : "settled-shelf" ,
11741194 ) ,
1175- ) . toEqual ( [ "active " , "queued-1" , "queued-2" , "settled-shelf" , "settled" ] ) ;
1195+ ) . toEqual ( [ "unsent " , "queued-1" , "queued-2" , "active ", "settled-shelf" , "settled" ] ) ;
11761196 expect (
1177- items . filter ( ( item ) => item . type === "v2-pending" && item . showPendingDivider ) ,
1178- ) . toHaveLength ( 1 ) ;
1197+ items . flatMap ( ( item ) => ( item . type === "v2-pending" ? [ item . showPendingDivider ] : [ ] ) ) ,
1198+ ) . toEqual ( [ true , false , false ] ) ;
1199+ expect (
1200+ items . map ( ( item ) =>
1201+ item . type === "v2-thread" || item . type === "v2-pending" ? item . showTrailingDivider : null ,
1202+ ) ,
1203+ ) . toEqual ( [ true , true , true , false , null , false ] ) ;
11791204 } ) ;
11801205
1181- it ( "ends the list with queued tasks when nothing has settled yet" , ( ) => {
1206+ it ( "puts queued tasks above active rows when nothing has settled yet" , ( ) => {
11821207 const activeOnly = buildThreadListV2Items ( {
11831208 threads : [ makeThread ( { id : ThreadId . make ( "active" ) , title : "active" } ) ] ,
11841209 environmentId : null ,
@@ -1190,7 +1215,7 @@ describe("buildThreadListV2ListItems", () => {
11901215 pendingTasks : [ makePendingTask ( "queued-1" ) ] ,
11911216 } ) ;
11921217
1193- expect ( items . map ( ( item ) => item . type ) ) . toEqual ( [ "v2-thread " , "v2-pending " ] ) ;
1218+ expect ( items . map ( ( item ) => item . type ) ) . toEqual ( [ "v2-pending " , "v2-thread " ] ) ;
11941219 } ) ;
11951220
11961221 it ( "keeps the settled shelf between active and settled rows when nothing is queued" , ( ) => {
@@ -1208,7 +1233,7 @@ describe("buildThreadListV2ListItems", () => {
12081233 ] ) ;
12091234 } ) ;
12101235
1211- it ( "places queued tasks before a collapsed snoozed shelf" , ( ) => {
1236+ it ( "places queued tasks above active rows and a collapsed snoozed shelf" , ( ) => {
12121237 const snoozedLayout = buildThreadListV2Items ( {
12131238 threads : [
12141239 makeThread ( { id : ThreadId . make ( "active" ) , title : "active" } ) ,
@@ -1240,8 +1265,8 @@ describe("buildThreadListV2ListItems", () => {
12401265 } ) ;
12411266
12421267 expect ( items . map ( ( item ) => item . type ) ) . toEqual ( [
1243- "v2-thread" ,
12441268 "v2-pending" ,
1269+ "v2-thread" ,
12451270 "v2-snoozed-shelf" ,
12461271 "v2-settled-shelf" ,
12471272 "v2-thread" ,
@@ -2132,7 +2157,7 @@ describe("buildThreadListV2ListItems trailing dividers", () => {
21322157 const dividers = items . map ( ( item ) =>
21332158 item . type === "v2-thread" || item . type === "v2-pending" ? item . showTrailingDivider : "n/a" ,
21342159 ) ;
2135- expect ( dividers ) . toEqual ( [ true , false , true , false ] ) ;
2160+ expect ( dividers ) . toEqual ( [ true , true , true , false ] ) ;
21362161 } ) ;
21372162} ) ;
21382163
@@ -2370,8 +2395,8 @@ describe("Working section beta", () => {
23702395 : item . type ,
23712396 ) ,
23722397 ) . toEqual ( [
2373- "active" ,
23742398 "queued" ,
2399+ "active" ,
23752400 "v2-working-shelf" ,
23762401 "working" ,
23772402 "v2-snoozed-shelf" ,
0 commit comments