@@ -12,7 +12,7 @@ import {
1212 createStreamCollector ,
1313 assertStreamSuccess ,
1414 configureTestRetries ,
15- extractTextFromEvents ,
15+ waitFor ,
1616 modelString ,
1717 resolveOrpcClient ,
1818 createWorkspaceWithInit ,
@@ -26,6 +26,7 @@ import {
2626} from "../runtime/test-fixtures/ssh-fixture" ;
2727import type { RuntimeConfig } from "../../src/common/types/runtime" ;
2828import { HistoryService } from "../../src/node/services/historyService" ;
29+ import { PartialService } from "../../src/node/services/partialService" ;
2930import { createMuxMessage } from "../../src/common/types/message" ;
3031
3132// Skip all tests if TEST_INTEGRATION is not set
@@ -366,7 +367,21 @@ describeIntegration("Workspace fork", () => {
366367 ) ;
367368 expect ( deltaEvent ) . not . toBeNull ( ) ;
368369
369- const partialText = extractTextFromEvents ( sourceCollector . getDeltas ( ) ) . trim ( ) ;
370+ // Wait for partial.json to be written so the fork can commit in-flight output.
371+ const historyService = new HistoryService ( env . config ) ;
372+ const partialService = new PartialService ( env . config , historyService ) ;
373+ let partialText = "" ;
374+ const partialReady = await waitFor ( async ( ) => {
375+ const partial = await partialService . readPartial ( sourceWorkspaceId ) ;
376+ if ( ! partial ) return false ;
377+ partialText = ( partial . parts ?? [ ] )
378+ . filter ( ( part ) => part . type === "text" )
379+ . map ( ( part ) => ( part as { text : string } ) . text )
380+ . join ( " " )
381+ . trim ( ) ;
382+ return partialText . length > 0 ;
383+ } , getTimeout ( 15000 ) ) ;
384+ expect ( partialReady ) . toBe ( true ) ;
370385 expect ( partialText . length ) . toBeGreaterThan ( 0 ) ;
371386 const partialSnippet = partialText . length > 24 ? partialText . slice ( 0 , 24 ) : partialText ;
372387
@@ -380,7 +395,6 @@ describeIntegration("Workspace fork", () => {
380395 if ( ! forkResult . success ) return ;
381396 const forkedWorkspaceId = forkResult . metadata . id ;
382397
383- const historyService = new HistoryService ( env . config ) ;
384398 const forkedHistoryResult = await historyService . getHistory ( forkedWorkspaceId ) ;
385399 expect ( forkedHistoryResult . success ) . toBe ( true ) ;
386400 if ( ! forkedHistoryResult . success ) return ;
0 commit comments