@@ -68,12 +68,6 @@ function makeThread(
6868}
6969
7070const NOW = "2026-06-02T00:00:00.000Z" ;
71- const linkedPullRequest = {
72- projectId : ProjectId . make ( "project-1" ) ,
73- repository : "pingdotgg/t3code" ,
74- number : 42 ,
75- url : "https://github.com/pingdotgg/t3code/pull/42" ,
76- } ;
7771
7872describe ( "resolveThreadListV2SnoozeMenuSelection" , ( ) => {
7973 it ( "accepts a displayed evening preset while its wake time is still future" , ( ) => {
@@ -309,19 +303,6 @@ describe("sortThreadsForListV2", () => {
309303 ] ) ;
310304 expect ( sorted . map ( ( thread ) => thread . id ) ) . toEqual ( [ "newest" , "middle" , "oldest" ] ) ;
311305 } ) ;
312-
313- it ( "surfaces an un-settled thread at the top via its re-entry stamp" , ( ) => {
314- const sorted = sortThreadsForListV2 ( [
315- {
316- id : "old-unsettled" ,
317- createdAt : "2026-06-01T08:00:00.000Z" ,
318- unsettledAt : "2026-06-01T13:00:00.000Z" ,
319- } ,
320- { id : "newest" , createdAt : "2026-06-01T12:00:00.000Z" } ,
321- { id : "middle" , createdAt : "2026-06-01T10:00:00.000Z" } ,
322- ] ) ;
323- expect ( sorted . map ( ( thread ) => thread . id ) ) . toEqual ( [ "old-unsettled" , "newest" , "middle" ] ) ;
324- } ) ;
325306} ) ;
326307
327308describe ( "getThreadListV2OrderedSection" , ( ) => {
@@ -374,23 +355,66 @@ describe("getThreadListV2OrderedSection", () => {
374355} ) ;
375356
376357describe ( "buildThreadListV2Items" , ( ) => {
377- it ( "places a persisted settled thread in the settled shelf" , ( ) => {
378- const thread = makeThread ( {
379- id : ThreadId . make ( "linked-merged" ) ,
380- title : "Linked merged pull request" ,
381- linkedPullRequest,
382- settledOverride : "settled" ,
383- settledAt : NOW ,
384- } ) ;
358+ it ( "excludes subagent child threads from top-level rows and counts" , ( ) => {
359+ const rootThreadId = ThreadId . make ( "root" ) ;
360+ const activeChildId = ThreadId . make ( "active-child" ) ;
361+ const forkId = ThreadId . make ( "fork" ) ;
362+ const settledChildId = ThreadId . make ( "settled-child" ) ;
363+ const snoozedChildId = ThreadId . make ( "snoozed-child" ) ;
385364 const layout = buildThreadListV2Items ( {
386- threads : [ thread ] ,
365+ threads : [
366+ makeThread ( { id : rootThreadId , title : "Root" } ) ,
367+ makeThread ( {
368+ id : forkId ,
369+ title : "Fork" ,
370+ lineage : {
371+ rootThreadId,
372+ parentThreadId : rootThreadId ,
373+ relationshipToParent : "fork" ,
374+ } ,
375+ } ) ,
376+ makeThread ( {
377+ id : activeChildId ,
378+ title : "Active child" ,
379+ lineage : {
380+ rootThreadId,
381+ parentThreadId : rootThreadId ,
382+ relationshipToParent : "subagent" ,
383+ } ,
384+ } ) ,
385+ makeThread ( {
386+ id : settledChildId ,
387+ title : "Settled child" ,
388+ lineage : {
389+ rootThreadId,
390+ parentThreadId : rootThreadId ,
391+ relationshipToParent : "subagent" ,
392+ } ,
393+ settledOverride : "settled" ,
394+ settledAt : "2026-06-01T12:00:00.000Z" ,
395+ } ) ,
396+ makeThread ( {
397+ id : snoozedChildId ,
398+ title : "Snoozed child" ,
399+ lineage : {
400+ rootThreadId,
401+ parentThreadId : rootThreadId ,
402+ relationshipToParent : "subagent" ,
403+ } ,
404+ snoozedUntil : "2026-06-03T09:00:00.000Z" ,
405+ snoozedAt : "2026-06-01T12:00:00.000Z" ,
406+ } ) ,
407+ ] ,
387408 environmentId : null ,
388409 searchQuery : "" ,
389410 now : NOW ,
411+ settledLimit : 0 ,
390412 } ) ;
391413
392- expect ( layout . settledCount ) . toBe ( 1 ) ;
393- expect ( layout . items [ 0 ] ?. variant ) . toBe ( "slim" ) ;
414+ expect ( layout . items . map ( ( item ) => item . thread . id ) ) . toEqual ( [ forkId , rootThreadId ] ) ;
415+ expect ( layout . hiddenSettledCount ) . toBe ( 0 ) ;
416+ expect ( layout . snoozedCount ) . toBe ( 0 ) ;
417+ expect ( layout . nextSnoozeWakeAt ) . toBeNull ( ) ;
394418 } ) ;
395419
396420 it ( "hides snoozed threads and counts them — visibility parity with web" , ( ) => {
@@ -422,14 +446,15 @@ describe("buildThreadListV2Items", () => {
422446 expect ( layout . snoozedCount ) . toBe ( 1 ) ;
423447 } ) ;
424448
425- it ( "places settled pinned threads in the settled shelf " , ( ) => {
449+ it ( "renders pinned threads first and exempts them from auto-settle — parity with web " , ( ) => {
426450 const layout = buildThreadListV2Items ( {
427451 threads : [
428452 makeThread ( { id : ThreadId . make ( "active" ) , title : "Active" } ) ,
429453 makeThread ( {
430454 id : ThreadId . make ( "pinned-settled" ) ,
431455 title : "Pinned while settled" ,
432456 pinnedAt : "2026-06-01T12:00:00.000Z" ,
457+ // Stale settled state (the decider clears it on pin): the pin wins.
433458 settledOverride : "settled" ,
434459 settledAt : "2026-06-01T12:00:00.000Z" ,
435460 } ) ,
@@ -439,29 +464,8 @@ describe("buildThreadListV2Items", () => {
439464 now : NOW ,
440465 } ) ;
441466
442- expect ( layout . items . map ( ( item ) => item . thread . id ) ) . toEqual ( [ "active" , "pinned-settled" ] ) ;
443- expect ( layout . items . map ( ( item ) => item . pinned ) ) . toEqual ( [ false , false ] ) ;
444- expect ( layout . settledCount ) . toBe ( 1 ) ;
445- } ) ;
446-
447- it ( "keeps active pinned threads in the pinned block" , ( ) => {
448- const pinned = makeThread ( {
449- id : ThreadId . make ( "pinned" ) ,
450- title : "Pinned thread" ,
451- pinnedAt : "2026-06-01T12:00:00.000Z" ,
452- } ) ;
453- const layout = buildThreadListV2Items ( {
454- threads : [ pinned ] ,
455- environmentId : null ,
456- searchQuery : "" ,
457- now : NOW ,
458- } ) ;
459-
460- expect ( layout . items [ 0 ] ) . toMatchObject ( {
461- thread : { id : "pinned" } ,
462- variant : "card" ,
463- pinned : true ,
464- } ) ;
467+ expect ( layout . items . map ( ( item ) => item . thread . id ) ) . toEqual ( [ "pinned-settled" , "active" ] ) ;
468+ expect ( layout . items . map ( ( item ) => item . pinned ) ) . toEqual ( [ true , false ] ) ;
465469 expect ( layout . settledCount ) . toBe ( 0 ) ;
466470 } ) ;
467471
0 commit comments