@@ -411,7 +411,6 @@ it.effect("serves no render for an item outside the shared thread", () =>
411411 } ) . pipe ( Effect . provide ( layerTest ) ) ,
412412) ;
413413
414- /** A message from the owner, which opens a run for the command below. */
415414const ownerRun = Effect . gen ( function * ( ) {
416415 const orchestrator = yield * Orchestrator . OrchestratorV2 ;
417416 yield * orchestrator . dispatch ( {
@@ -430,12 +429,17 @@ const ownerRun = Effect.gen(function* () {
430429 return runs [ 0 ] ! . id ;
431430} ) ;
432431
433- const writeCommand = (
432+ const writeItem = (
434433 id : string ,
435- fields : Pick <
436- Extract < OrchestrationV2TurnItem , { type : "command_execution" } > ,
437- "status" | "output"
438- > ,
434+ fields :
435+ | Pick <
436+ Extract < OrchestrationV2TurnItem , { type : "command_execution" } > ,
437+ "type" | "status" | "input" | "output"
438+ >
439+ | Pick <
440+ Extract < OrchestrationV2TurnItem , { type : "file_change" } > ,
441+ "type" | "status" | "fileName" | "diffStr" | "oldStr" | "newStr"
442+ > ,
439443) =>
440444 Effect . gen ( function * ( ) {
441445 const runId = yield * ownerRun ;
@@ -464,8 +468,6 @@ const writeCommand = (
464468 startedAt : now ,
465469 completedAt : fields . status === "running" ? null : now ,
466470 updatedAt : now ,
467- type : "command_execution" ,
468- input : "ls /work/src" ,
469471 ...fields ,
470472 } ,
471473 } ,
@@ -474,17 +476,40 @@ const writeCommand = (
474476 return TurnItemId . make ( id ) ;
475477 } ) ;
476478
477- it . effect ( "gives the guest a command's detail and output, as the owner's row loads them " , ( ) =>
479+ it . effect ( "gives the guest a command's detail and output, but no file diffs " , ( ) =>
478480 Effect . gen ( function * ( ) {
479481 const { guestShares, credential } = yield * shareThread ;
480482 const { token : session } = yield * guestShares . redeem ( { credential, name : "Sam" } ) ;
481- const command = yield * writeCommand ( "item:command" , {
483+ const command = yield * writeItem ( "item:command" , {
484+ type : "command_execution" ,
482485 status : "completed" ,
486+ input : "ls /work/src" ,
483487 output : "/work/src/auth.ts\n" ,
484488 } ) ;
485489
486490 const detail = ( yield * guestShares . item ( session , command ) ) . item ;
487491 assert . deepInclude ( detail , { input : "ls /work/src" , output : "/work/src/auth.ts\n" } ) ;
492+ const edit = yield * writeItem ( "item:edit" , {
493+ type : "file_change" ,
494+ status : "completed" ,
495+ fileName : "src/auth.ts" ,
496+ diffStr : "-const token = 1;\n+const token = 2;\n" ,
497+ } ) ;
498+ const write = yield * writeItem ( "item:write" , {
499+ type : "file_change" ,
500+ status : "completed" ,
501+ fileName : "src/config.ts" ,
502+ oldStr : "" ,
503+ newStr : "export const key = 1;\n" ,
504+ } ) ;
505+ for ( const [ id , fileName ] of [
506+ [ edit , "src/auth.ts" ] ,
507+ [ write , "src/config.ts" ] ,
508+ ] as const ) {
509+ const change = ( yield * guestShares . item ( session , id ) ) . item ;
510+ assert . deepInclude ( change , { type : "file_change" , fileName } ) ;
511+ assert . doesNotHaveAnyKeys ( change , [ "diffStr" , "oldStr" , "newStr" ] ) ;
512+ }
488513 const frames = Array . from (
489514 yield * Stream . runCollect ( yield * guestShares . commandOutput ( session , command ) ) ,
490515 ) ;
@@ -508,7 +533,11 @@ it.effect("ends a running command's output once the owner stops sharing", () =>
508533 Effect . gen ( function * ( ) {
509534 const { orchestrator, guestShares, credential } = yield * shareThread ;
510535 const { token : session } = yield * guestShares . redeem ( { credential, name : "Sam" } ) ;
511- const command = yield * writeCommand ( "item:running" , { status : "running" } ) ;
536+ const command = yield * writeItem ( "item:running" , {
537+ type : "command_execution" ,
538+ status : "running" ,
539+ input : "ls /work/src" ,
540+ } ) ;
512541 const collecting = yield * Stream . runCollect (
513542 yield * guestShares . commandOutput ( session , command ) ,
514543 ) . pipe ( Effect . forkChild ) ;
0 commit comments