1- import { vi } from "vite-plus/test" ;
21import { describe , expect , it } from "@effect/vitest" ;
32import {
4- AuthOrchestrationOperateScope ,
5- type AuthSessionState ,
63 CommandId ,
74 RuntimeRequestId ,
85 EnvironmentId ,
@@ -21,20 +18,13 @@ import * as Layer from "effect/Layer";
2118import * as Option from "effect/Option" ;
2219import * as Queue from "effect/Queue" ;
2320import * as SubscriptionRef from "effect/SubscriptionRef" ;
24- import { AsyncResult , Atom , AtomRegistry } from "effect/reactivity" ;
21+ import { Atom , AtomRegistry } from "effect/reactivity" ;
2522
2623import * as EnvironmentRegistry from "../connection/registry.ts" ;
2724import * as EnvironmentSupervisor from "../connection/supervisor.ts" ;
2825import type { RpcSession } from "../rpc/session.ts" ;
2926import { createThreadEnvironmentAtoms } from "./threadCommands.ts" ;
3027
31- vi . mock ( "./session.ts" , ( ) => ( {
32- createEnvironmentSessionAtoms : ( ) => ( { sessionStateAtom : sessions } ) ,
33- } ) ) ;
34- const sessions = Atom . family ( ( _id : EnvironmentId ) =>
35- Atom . make < AsyncResult . AsyncResult < AuthSessionState , string > > ( AsyncResult . initial ( ) ) ,
36- ) ;
37-
3828const ENVIRONMENT_ID = EnvironmentId . make ( "remote" ) ;
3929const THREAD_ID = ThreadId . make ( "thread" ) ;
4030const NOW = DateTime . makeUnsafe ( "2026-09-12T10:00:00.000Z" ) ;
@@ -135,34 +125,6 @@ const makeHarness = Effect.fn("TestThreadCommands.makeHarness")(function* () {
135125} ) ;
136126
137127describe ( "remote thread lifecycle commands" , ( ) => {
138- it . effect ( "offers background stop only while the destination grants thread operations" , ( ) =>
139- Effect . gen ( function * ( ) {
140- const h = yield * makeHarness ( ) ;
141- const permission = h . commands . interruptTurn . permissionAtom ( ENVIRONMENT_ID ) ;
142- expect ( h . registry . get ( permission ) ) . toBe ( false ) ;
143- const session : AuthSessionState = {
144- authenticated : true ,
145- auth : {
146- policy : "remote-reachable" ,
147- bootstrapMethods : [ ] ,
148- sessionMethods : [ ] ,
149- sessionCookieName : "test" ,
150- } ,
151- scopes : [ AuthOrchestrationOperateScope ] ,
152- permissions : [ AuthOrchestrationOperateScope ] ,
153- } ;
154- h . registry . set ( sessions ( ENVIRONMENT_ID ) , AsyncResult . success ( session ) ) ;
155- expect ( h . registry . get ( permission ) ) . toBe ( true ) ;
156- expect (
157- h . registry . get ( h . commands . interruptTurn . permissionAtom ( EnvironmentId . make ( "other" ) ) ) ,
158- ) . toBe ( false ) ;
159- h . registry . set (
160- sessions ( ENVIRONMENT_ID ) ,
161- AsyncResult . success ( { ...session , scopes : [ ] , permissions : [ ] } ) ,
162- ) ;
163- expect ( h . registry . get ( permission ) ) . toBe ( false ) ;
164- } ) ,
165- ) ;
166128 const actions = [
167129 [ "settle" , { } , { settledOverride : "settled" , pinnedAt : null , snoozedUntil : null } ] ,
168130 [ "unsettle" , { reason : "user" } , { settledOverride : "active" , settledAt : null } ] ,
0 commit comments