@@ -530,6 +530,58 @@ it.effect("gives the guest a command's detail and output, but no file diffs", ()
530530 } ) . pipe ( Effect . provide ( layerTest ) ) ,
531531) ;
532532
533+ it . effect ( "gives a fork's guest the commands the fork shows from its source thread" , ( ) =>
534+ Effect . gen ( function * ( ) {
535+ const { orchestrator, guestShares } = yield * shareThread ;
536+ const command = yield * writeItem ( "item:command" , {
537+ type : "command_execution" ,
538+ status : "completed" ,
539+ input : "ls /work/src" ,
540+ output : "/work/src/auth.ts\n" ,
541+ } ) ;
542+ const eventSink = yield * EventSink . EventSinkV2 ;
543+ const now = yield * DateTime . now ;
544+ const run = ( yield * orchestrator . getThreadRecords ( threadId , [ "runs" ] ) ) . runs [ 0 ] ! ;
545+ yield * eventSink . write ( {
546+ events : [
547+ {
548+ id : EventId . make ( "event:run-done" ) ,
549+ type : "run.updated" ,
550+ threadId,
551+ runId : run . id ,
552+ providerInstanceId : instanceId ,
553+ occurredAt : now ,
554+ payload : { ...run , status : "completed" , completedAt : now } ,
555+ } ,
556+ ] ,
557+ } ) ;
558+ const forkId = ThreadId . make ( "thread:guest-share-fork" ) ;
559+ yield * orchestrator . dispatch ( {
560+ type : "thread.fork" ,
561+ commandId : CommandId . make ( "fork" ) ,
562+ sourceThreadId : threadId ,
563+ targetThreadId : forkId ,
564+ sourcePoint : { type : "run" , runId : run . id } ,
565+ createdBy : "user" ,
566+ creationSource : "web" ,
567+ } ) ;
568+ const { url } = yield * guestShares . create ( { threadId : forkId } ) ;
569+ const { token : session } = yield * guestShares . redeem ( {
570+ credential : url . slice ( url . indexOf ( "#" ) + 1 ) ,
571+ name : "Sam" ,
572+ } ) ;
573+
574+ const detail = ( yield * guestShares . item ( session , command ) ) . item ;
575+ assert . deepInclude ( detail , { input : "ls /work/src" , output : "/work/src/auth.ts\n" } ) ;
576+ const frames = Array . from (
577+ yield * Stream . runCollect ( yield * guestShares . commandOutput ( session , command ) ) ,
578+ ) ;
579+ assert . deepEqual ( frames , [
580+ { kind : "replace" , text : "/work/src/auth.ts\n" , truncated : false , running : false } ,
581+ ] ) ;
582+ } ) . pipe ( Effect . provide ( layerTest ) ) ,
583+ ) ;
584+
533585it . effect ( "pages the guest back through turns older than the stream's snapshot" , ( ) =>
534586 Effect . gen ( function * ( ) {
535587 const { guestShares, credential } = yield * shareThread ;
0 commit comments