@@ -18,6 +18,7 @@ import {
1818 pinOrderKeyBetween ,
1919 resolveProjectStatusIndicator ,
2020 resolveSidebarSweepKeys ,
21+ resolveSidebarRowStatus ,
2122 resolveSidebarThreadStatus ,
2223 resolveThreadStatusPill ,
2324 resolveWorkingStartedAt ,
@@ -348,6 +349,55 @@ describe("resolveSidebarThreadStatus", () => {
348349 } ) ;
349350} ) ;
350351
352+ describe ( "resolveSidebarRowStatus" , ( ) => {
353+ const failedRuntime = {
354+ status : "failed" as const ,
355+ activeRunId : null ,
356+ providerInstanceId : ProviderInstanceId . make ( "codex" ) ,
357+ providerName : "Codex" ,
358+ lastError : "Provider turn failed." ,
359+ updatedAt : "2026-03-09T10:05:00.000Z" ,
360+ } ;
361+ const failed = {
362+ hasActionableProposedPlan : false ,
363+ hasPendingApprovals : false ,
364+ hasPendingUserInput : false ,
365+ interactionMode : "default" as const ,
366+ runtime : failedRuntime ,
367+ latestRun : { ...makeLatestRun ( ) , status : "failed" as const } ,
368+ } ;
369+
370+ it ( "clears a failure once opened, without showing Done, and shows the next failure" , ( ) => {
371+ expect ( resolveSidebarRowStatus ( { ...failed , lastVisitedAt : undefined } ) ) . toBe ( "failed" ) ;
372+
373+ const opened = { ...failed , lastVisitedAt : "2026-03-09T10:06:00.000Z" } ;
374+ expect ( resolveSidebarRowStatus ( opened ) ) . toBe ( "ready" ) ;
375+ expect ( hasUnseenCompletion ( opened ) ) . toBe ( false ) ;
376+
377+ const failedAgain = {
378+ ...opened ,
379+ latestRun : { ...opened . latestRun , completedAt : "2026-03-09T10:10:00.000Z" } ,
380+ } ;
381+ expect ( resolveSidebarRowStatus ( failedAgain ) ) . toBe ( "failed" ) ;
382+ } ) ;
383+
384+ it ( "dates a failure without a completed run by the runtime update" , ( ) => {
385+ const visitedAfter = "2026-03-09T10:06:00.000Z" ;
386+ const visitedBefore = "2026-03-09T10:00:00.000Z" ;
387+ const noCompletedAt = {
388+ ...failed ,
389+ latestRun : { ...failed . latestRun , completedAt : null } ,
390+ } ;
391+ expect ( resolveSidebarRowStatus ( { ...noCompletedAt , lastVisitedAt : visitedAfter } ) ) . toBe (
392+ "ready" ,
393+ ) ;
394+
395+ const noRun = { ...failed , latestRun : null } ;
396+ expect ( resolveSidebarRowStatus ( { ...noRun , lastVisitedAt : visitedBefore } ) ) . toBe ( "failed" ) ;
397+ expect ( resolveSidebarRowStatus ( { ...noRun , lastVisitedAt : visitedAfter } ) ) . toBe ( "ready" ) ;
398+ } ) ;
399+ } ) ;
400+
351401describe ( "searchSidebarThreads" , ( ) => {
352402 const searchThread = ( id : string , title : string , latestUserMessageAt : string ) => ( {
353403 environmentId : localEnvironmentId ,
@@ -1732,6 +1782,12 @@ describe("resolveSidebarFolderDot", () => {
17321782 expect ( resolveSidebarFolderDot ( [ idle , working ] ) ) . toBe ( "working" ) ;
17331783 expect ( resolveSidebarFolderDot ( [ working , unread ] ) ) . toBe ( "unread" ) ;
17341784 expect ( resolveSidebarFolderDot ( [ unread , limited ] ) ) . toBe ( "attention" ) ;
1785+ // A failure the user already opened clears, like its row.
1786+ const failed = { ...idle , runtime : { ...runtime , status : "failed" as const } } ;
1787+ expect ( resolveSidebarFolderDot ( [ failed ] ) ) . toBeNull ( ) ;
1788+ expect (
1789+ resolveSidebarFolderDot ( [ { ...failed , lastVisitedAt : "2026-03-09T09:00:00.000Z" } ] ) ,
1790+ ) . toBe ( "failed" ) ;
17351791 } ) ;
17361792} ) ;
17371793
0 commit comments