@@ -15,6 +15,7 @@ import * as Stream from "effect/Stream";
1515import { HttpClient , HttpClientResponse } from "effect/unstable/http" ;
1616import { ServerSettingsService } from "../serverSettings.ts" ;
1717import * as DeviceHost from "./DeviceHost.ts" ;
18+ import { NodeRuntimeUnavailableError } from "@t3tools/shared/nodeRuntime" ;
1819
1920import { type DeviceService , makeWithHosts , stateStream } from "./DeviceService.ts" ;
2021
@@ -61,6 +62,7 @@ const fixture = Effect.fn("fixture")(function* (
6162 onBoot : Effect . Effect < void > = Effect . void ,
6263 bootError ?: string ,
6364 failListAfterShutdown = false ,
65+ runtimeFailure ?: NodeRuntimeUnavailableError ,
6466) {
6567 const settings = yield * Ref . make ( DEFAULT_SERVER_SETTINGS ) ;
6668 const starts : string [ ] = [ ] ;
@@ -88,12 +90,14 @@ const fixture = Effect.fn("fixture")(function* (
8890 platformAvailability : ( platform ) => Effect . succeed ( { platform, available : true } ) ,
8991 ensureReady : ( onPhase ) =>
9092 Effect . gen ( function * ( ) {
93+ if ( runtimeFailure ) return yield * runtimeFailure ;
9194 starts . push ( "start" ) ;
9295 yield * onPhase ( "starting" ) ;
9396 return ready ;
9497 } ) ,
9598 ensureAgentReady : ( onPhase ) =>
9699 Effect . gen ( function * ( ) {
100+ if ( runtimeFailure ) return yield * runtimeFailure ;
97101 agentStarts . push ( "start" ) ;
98102 yield * onPhase ( "starting" ) ;
99103 return {
@@ -188,6 +192,43 @@ const fixture = Effect.fn("fixture")(function* (
188192} ) ;
189193
190194describe ( "device setup consent" , ( ) => {
195+ it . effect (
196+ "preserves missing-runtime guidance and causes through manual and agent readiness" ,
197+ ( ) =>
198+ Effect . gen ( function * ( ) {
199+ const underlying = new Error ( "private lookup diagnostics" ) ;
200+ const runtimeFailure = new NodeRuntimeUnavailableError ( {
201+ feature : "Local device support" ,
202+ cause : underlying ,
203+ } ) ;
204+ const { service, settings, requests } = yield * fixture (
205+ Effect . void ,
206+ undefined ,
207+ false ,
208+ runtimeFailure ,
209+ ) ;
210+ yield * Ref . update ( settings , ( current ) => ( {
211+ ...current ,
212+ enableDeviceSupport : true ,
213+ enableAgentDeviceAccess : true ,
214+ } ) ) ;
215+ for ( const readiness of [ service . readiness ( ) , service . agentReadinessIfSupported ( ) ] ) {
216+ const error = yield * readiness . pipe ( Effect . flip ) ;
217+ expect ( error ) . toMatchObject ( {
218+ _tag : "DeviceHostUnavailableError" ,
219+ reason : expect . stringContaining ( "Install Node.js" ) ,
220+ cause : runtimeFailure ,
221+ } ) ;
222+ expect ( error . message ) . not . toContain ( underlying . message ) ;
223+ }
224+ expect ( ( yield * service . state ) . hostStatuses [ LOCAL_DEVICE_HOST_ID ] ) . toMatchObject ( {
225+ status : "failed" ,
226+ detail : expect . stringContaining ( "Install Node.js" ) ,
227+ } ) ;
228+ expect ( requests ) . toEqual ( [ ] ) ;
229+ } ) . pipe ( Effect . scoped ) ,
230+ ) ;
231+
191232 it . effect ( "listing and provider startup do not start helpers before consent" , ( ) =>
192233 Effect . gen ( function * ( ) {
193234 const { service, starts, requests } = yield * fixture ( ) ;
0 commit comments