@@ -10,6 +10,7 @@ import {
1010 Wakeups ,
1111} from "@t3tools/client-runtime/connection" ;
1212import { managedRelayAccountChanges , managedRelaySessionAtom } from "@t3tools/client-runtime/relay" ;
13+ import * as Clock from "effect/Clock" ;
1314import * as Context from "effect/Context" ;
1415import * as Effect from "effect/Effect" ;
1516import * as Layer from "effect/Layer" ;
@@ -120,8 +121,9 @@ const layerWakeups = Wakeups.layer({
120121 [
121122 Stream . callback < "application-active-probe" | "application-active-long" > ( ( queue ) =>
122123 Effect . acquireRelease (
123- Effect . sync ( ( ) => {
124- let backgroundedAtMs = AppState . currentState === "background" ? Date . now ( ) : null ;
124+ Effect . gen ( function * ( ) {
125+ const nowMs = yield * Clock . currentTimeMillis ;
126+ let backgroundedAtMs = AppState . currentState === "background" ? nowMs : null ;
125127 return AppState . addEventListener ( "change" , ( state ) => {
126128 if ( state === "background" ) {
127129 backgroundedAtMs = Date . now ( ) ;
@@ -187,7 +189,7 @@ const layerCapabilities = Layer.effectContext(
187189 Context . add (
188190 ClientCapabilities . PrimaryEnvironmentAuth ,
189191 ClientCapabilities . PrimaryEnvironmentAuth . of ( {
190- bearerToken : Effect . succeed ( Option . none ( ) ) ,
192+ bearerToken : Effect . succeedNone ,
191193 } ) ,
192194 ) ,
193195 // The relay device id already persists in secure storage; analytics only sends its hash.
@@ -205,7 +207,7 @@ const layerCapabilities = Layer.effectContext(
205207 detail : `Could not load the mobile device identity: ${ String ( cause ) } ` ,
206208 } ) ,
207209 ) ,
208- Effect . map ( Option . some ) ,
210+ Effect . asSome ,
209211 ) ,
210212 } ) ,
211213 ) ,
@@ -218,21 +220,25 @@ const layerCapabilities = Layer.effectContext(
218220 Context . add (
219221 ClientCapabilities . SshEnvironmentGateway ,
220222 ClientCapabilities . SshEnvironmentGateway . of ( {
221- provision : ( ) =>
223+ provision : Effect . fn ( "ClientCapabilities.SshEnvironmentGateway.provision" ) ( ( ) =>
222224 Effect . fail (
223225 new ConnectionBlockedError ( {
224226 reason : "unsupported" ,
225227 detail : "SSH environments are only available in the desktop app." ,
226228 } ) ,
227229 ) ,
228- prepare : ( ) =>
230+ ) ,
231+ prepare : Effect . fn ( "ClientCapabilities.SshEnvironmentGateway.prepare" ) ( ( ) =>
229232 Effect . fail (
230233 new ConnectionBlockedError ( {
231234 reason : "unsupported" ,
232235 detail : "SSH environments are only available in the desktop app." ,
233236 } ) ,
234237 ) ,
235- disconnect : ( ) => Effect . void ,
238+ ) ,
239+ disconnect : Effect . fn ( "ClientCapabilities.SshEnvironmentGateway.disconnect" ) (
240+ ( ) => Effect . void ,
241+ ) ,
236242 } ) ,
237243 ) ,
238244 ) ;
@@ -252,22 +258,16 @@ const layerProvidedCapabilities = layerCapabilities.pipe(Layer.provide(Runtime.l
252258const layerEnvironmentOwnedDataCleanup = Layer . succeed (
253259 Persistence . EnvironmentOwnedDataCleanup ,
254260 Persistence . EnvironmentOwnedDataCleanup . of ( {
255- clear : ( environmentId ) =>
261+ clear : Effect . fn ( "Persistence.EnvironmentOwnedDataCleanup.clear" ) ( ( environmentId ) =>
256262 Effect . all (
257263 [
258264 Effect . promise ( ( ) => clearThreadOutboxEnvironment ( environmentId ) ) ,
259265 Effect . promise ( ( ) => clearComposerDraftsEnvironment ( environmentId ) ) ,
260266 Effect . sync ( ( ) => clearThreadComposerErrorsForEnvironment ( environmentId ) ) ,
261267 ] ,
262268 { concurrency : "unbounded" , discard : true } ,
263- ) . pipe (
264- Effect . catch ( ( cause ) =>
265- Effect . logWarning ( "Could not clear mobile environment-owned data." , {
266- environmentId,
267- cause,
268- } ) ,
269- ) ,
270269 ) ,
270+ ) ,
271271 } ) ,
272272) ;
273273
0 commit comments