@@ -2532,6 +2532,54 @@ describe("CloudTaskEngine", () => {
25322532 expect ( statusFetchCount ) . toBeLessThanOrEqual ( 2 ) ;
25332533 } ) ;
25342534
2535+ it ( "loads archived logs when a terminal run has no persisted session logs" , async ( ) => {
2536+ const updates : unknown [ ] = [ ] ;
2537+ service . on ( CloudTaskEvent . Update , ( payload ) => updates . push ( payload ) ) ;
2538+ const archivedEntry = {
2539+ type : "notification" ,
2540+ timestamp : "2026-01-01T00:00:00Z" ,
2541+ } ;
2542+
2543+ mockNetFetch . mockImplementation ( ( input : string | Request ) => {
2544+ const url = typeof input === "string" ? input : input . url ;
2545+ if ( url . includes ( "/session_logs/" ) ) {
2546+ return Promise . resolve (
2547+ createJsonResponse ( [ ] , 200 , { "X-Has-More" : "false" } ) ,
2548+ ) ;
2549+ }
2550+ if ( url === "https://logs.example.com/run-1.jsonl" ) {
2551+ return Promise . resolve (
2552+ new Response ( `${ JSON . stringify ( archivedEntry ) } \n` , { status : 200 } ) ,
2553+ ) ;
2554+ }
2555+ return Promise . resolve (
2556+ createJsonResponse ( {
2557+ id : "run-1" ,
2558+ status : "completed" ,
2559+ log_url : "https://logs.example.com/run-1.jsonl" ,
2560+ updated_at : "2026-01-01T00:00:00Z" ,
2561+ } ) ,
2562+ ) ;
2563+ } ) ;
2564+
2565+ service . watch ( {
2566+ taskId : "task-1" ,
2567+ runId : "run-1" ,
2568+ apiHost : "https://app.example.com" ,
2569+ teamId : 2 ,
2570+ } ) ;
2571+
2572+ await waitFor ( ( ) => updates . length === 1 ) ;
2573+ expect ( updates [ 0 ] ) . toEqual (
2574+ expect . objectContaining ( {
2575+ kind : "snapshot" ,
2576+ newEntries : [ archivedEntry ] ,
2577+ totalEntryCount : 1 ,
2578+ status : "completed" ,
2579+ } ) ,
2580+ ) ;
2581+ } ) ;
2582+
25352583 const guardedFetchStatusExpectations = [
25362584 [
25372585 401 ,
0 commit comments