@@ -3717,6 +3717,8 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
37173717
37183718 assert . equal ( response . environment . environmentId , testEnvironmentDescriptor . environmentId ) ;
37193719 assert . equal ( response . auth . policy , "desktop-managed-local" ) ;
3720+ assert . equal ( response . shellResumeCompletionMarker , true ) ;
3721+ assert . equal ( response . threadResumeCompletionMarker , true ) ;
37203722 } ) . pipe ( Effect . provide ( NodeHttpServer . layerTest ) ) ,
37213723 ) ;
37223724
@@ -5607,6 +5609,113 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
56075609 } ) . pipe ( Effect . provide ( NodeHttpServer . layerTest ) ) ,
56085610 ) ;
56095611
5612+ it . effect ( "marks an empty shell catch-up replay as synchronized when requested" , ( ) =>
5613+ Effect . gen ( function * ( ) {
5614+ yield * buildAppUnderTest ( {
5615+ layers : {
5616+ orchestrationEngine : {
5617+ readEvents : ( ) => Stream . empty ,
5618+ } ,
5619+ } ,
5620+ } ) ;
5621+
5622+ const wsUrl = yield * getWsServerUrl ( "/ws" ) ;
5623+ const firstItem = yield * Effect . scoped (
5624+ withWsRpcClient ( wsUrl , ( client ) =>
5625+ client [ ORCHESTRATION_WS_METHODS . subscribeShell ] ( {
5626+ afterSequence : 0 ,
5627+ requestCompletionMarker : true ,
5628+ } ) . pipe ( Stream . runHead ) ,
5629+ ) ,
5630+ ) ;
5631+
5632+ assert . deepEqual ( Option . getOrThrow ( firstItem ) , { kind : "synchronized" } ) ;
5633+ } ) . pipe ( Effect . provide ( NodeHttpServer . layerTest ) ) ,
5634+ ) ;
5635+
5636+ it . effect ( "marks a socket thread snapshot as synchronized when requested" , ( ) =>
5637+ Effect . gen ( function * ( ) {
5638+ const thread = makeDefaultOrchestrationReadModel ( ) . threads [ 0 ] ! ;
5639+ yield * buildAppUnderTest ( {
5640+ layers : {
5641+ projectionSnapshotQuery : {
5642+ getThreadDetailSnapshot : ( ) =>
5643+ Effect . succeed ( Option . some ( { snapshotSequence : 1 , thread } ) ) ,
5644+ } ,
5645+ } ,
5646+ } ) ;
5647+
5648+ const wsUrl = yield * getWsServerUrl ( "/ws" ) ;
5649+ const items = yield * Effect . scoped (
5650+ withWsRpcClient ( wsUrl , ( client ) =>
5651+ client [ ORCHESTRATION_WS_METHODS . subscribeThread ] ( {
5652+ threadId : defaultThreadId ,
5653+ requestCompletionMarker : true ,
5654+ } ) . pipe ( Stream . take ( 2 ) , Stream . runCollect ) ,
5655+ ) ,
5656+ ) ;
5657+
5658+ assert . equal ( items [ 0 ] ?. kind , "snapshot" ) ;
5659+ assert . deepEqual ( items [ 1 ] , { kind : "synchronized" } ) ;
5660+ } ) . pipe ( Effect . provide ( NodeHttpServer . layerTest ) ) ,
5661+ ) ;
5662+
5663+ it . effect ( "buffers shell events published while the fallback snapshot loads" , ( ) =>
5664+ Effect . gen ( function * ( ) {
5665+ const liveEvents = yield * PubSub . unbounded < OrchestrationEvent > ( ) ;
5666+ const deletedEvent = {
5667+ sequence : 2 ,
5668+ eventId : EventId . make ( "event-shell-thread-deleted" ) ,
5669+ aggregateKind : "thread" ,
5670+ aggregateId : defaultThreadId ,
5671+ occurredAt : "2026-01-01T00:00:01.000Z" ,
5672+ commandId : null ,
5673+ causationEventId : null ,
5674+ correlationId : null ,
5675+ metadata : { } ,
5676+ type : "thread.deleted" ,
5677+ payload : {
5678+ threadId : defaultThreadId ,
5679+ deletedAt : "2026-01-01T00:00:01.000Z" ,
5680+ } ,
5681+ } satisfies Extract < OrchestrationEvent , { type : "thread.deleted" } > ;
5682+
5683+ yield * buildAppUnderTest ( {
5684+ layers : {
5685+ orchestrationEngine : {
5686+ streamDomainEvents : Stream . fromPubSub ( liveEvents ) ,
5687+ } ,
5688+ projectionSnapshotQuery : {
5689+ getShellSnapshot : ( ) =>
5690+ Effect . gen ( function * ( ) {
5691+ yield * Effect . sleep ( "25 millis" ) ;
5692+ yield * PubSub . publish ( liveEvents , deletedEvent ) ;
5693+ return {
5694+ snapshotSequence : 1 ,
5695+ projects : [ ] ,
5696+ threads : [ makeDefaultOrchestrationThreadShell ( ) ] ,
5697+ updatedAt : "2026-01-01T00:00:00.000Z" ,
5698+ } ;
5699+ } ) ,
5700+ } ,
5701+ } ,
5702+ } ) ;
5703+
5704+ const wsUrl = yield * getWsServerUrl ( "/ws" ) ;
5705+ const items = yield * Effect . scoped (
5706+ withWsRpcClient ( wsUrl , ( client ) =>
5707+ client [ ORCHESTRATION_WS_METHODS . subscribeShell ] ( {
5708+ requestCompletionMarker : true ,
5709+ } ) . pipe ( Stream . take ( 3 ) , Stream . runCollect ) ,
5710+ ) ,
5711+ ) . pipe ( Effect . timeout ( "2 seconds" ) ) ;
5712+
5713+ assert . equal ( items [ 0 ] ?. kind , "snapshot" ) ;
5714+ assert . equal ( items [ 1 ] ?. kind , "thread-removed" ) ;
5715+ assert . deepEqual ( items [ 2 ] , { kind : "synchronized" } ) ;
5716+ } ) . pipe ( Effect . provide ( NodeHttpServer . layerTest ) , TestClock . withLive ) ,
5717+ ) ;
5718+
56105719 it . effect ( "buffers thread events published while the initial snapshot loads" , ( ) =>
56115720 Effect . gen ( function * ( ) {
56125721 const thread = makeDefaultOrchestrationReadModel ( ) . threads [ 0 ] ! ;
0 commit comments