1+ import { presentThreadShell } from "@t3tools/client-runtime/state/models" ;
2+ import * as DateTime from "effect/DateTime" ;
13import { deriveActiveWorkStartedAt } from "../session-logic.ts" ;
24import { afterEach , beforeEach , describe , expect , it , vi } from "vite-plus/test" ;
35import { defaultAnimateLayoutChanges , type AnimateLayoutChanges } from "@dnd-kit/sortable" ;
@@ -1254,7 +1256,7 @@ describe("resolveThreadStatusPill", () => {
12541256 resolveThreadStatusPill ( {
12551257 thread : {
12561258 ...baseThread ,
1257- pendingBackgroundTasks : [ { taskId : "bg-1" , description : "sleep 20 " , kind : "command " } ] ,
1259+ pendingBackgroundTasks : [ { taskId : "bg-1" , description : "Watch build " , kind : "monitor " } ] ,
12581260 runtime : {
12591261 ...baseThread . runtime ,
12601262 status : "idle" ,
@@ -2053,6 +2055,39 @@ describe("navigation after parking a thread", () => {
20532055 ) ;
20542056} ) ;
20552057
2058+ describe ( "unseen completion with background work" , ( ) => {
2059+ it . each ( [
2060+ { kind : "command" , status : "ready" , topStatus : "done" , receded : false , pill : "Completed" } ,
2061+ { kind : "monitor" , status : "waiting" , topStatus : "waiting" , receded : true , pill : "Waiting" } ,
2062+ ] as const ) ( "presents a completed thread with a $kind roster" , ( expected ) => {
2063+ const thread = presentThreadShell ( localEnvironmentId , {
2064+ ...makeThreadFixture ( ) . source ,
2065+ latestRunId : RunId . make ( "run-background-completion" ) ,
2066+ status : "completed" ,
2067+ latestRunCompletedAt : DateTime . makeUnsafe ( "2026-06-20T01:00:00.000Z" ) ,
2068+ lastVisitedAt : DateTime . makeUnsafe ( "2026-06-20T00:59:00.000Z" ) ,
2069+ pendingBackgroundTasks : [ { taskId : "background-work" , kind : expected . kind } ] ,
2070+ } ) ;
2071+ const status = resolveSidebarThreadStatus ( thread ) ;
2072+ const isUnread = hasUnseenCompletion ( thread ) ;
2073+
2074+ expect ( isUnread ) . toBe ( true ) ;
2075+ expect ( status ) . toBe ( expected . status ) ;
2076+ expect ( resolveSidebarV2TopStatus ( { status, isUnread, isWoke : false } ) ) . toBe ( expected . topStatus ) ;
2077+ expect (
2078+ shouldRecedeSidebarThread ( {
2079+ status,
2080+ isUnread,
2081+ isWoke : false ,
2082+ isActive : false ,
2083+ isSelected : false ,
2084+ } ) ,
2085+ ) . toBe ( expected . receded ) ;
2086+ expect ( isSidebarThreadWorking ( thread ) ) . toBe ( expected . receded ) ;
2087+ expect ( resolveThreadStatusPill ( { thread } ) ) . toMatchObject ( { label : expected . pill } ) ;
2088+ } ) ;
2089+ } ) ;
2090+
20562091describe ( "Working shelf (beta)" , ( ) => {
20572092 const runtime = {
20582093 status : "running" as const ,
@@ -2062,7 +2097,7 @@ describe("Working shelf (beta)", () => {
20622097 lastError : null ,
20632098 updatedAt : "2026-03-09T10:00:00.000Z" ,
20642099 } ;
2065- const backgroundTask = { taskId : "bg-1" , description : "sleep 20 " , kind : "command " as const } ;
2100+ const backgroundTask = { taskId : "bg-1" , description : "Watch build " , kind : "monitor " as const } ;
20662101 const idle = {
20672102 hasActionableProposedPlan : false ,
20682103 hasPendingApprovals : false ,
0 commit comments