From f2cee4a82b664790aa0a8f819167e12a3b244264 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 2 Nov 2026 23:51:14 +0000 Subject: [PATCH 1/7] test(client-runtime): reproduce #29725, foreground does not re-list relay environments These tests reproduce #29725: after T3 Connect discovery has listed the account once, an application-active (web/desktop) or application-active-long (mobile) wakeup does not list the account again, so a device registered later never appears until the user signs out and back in. Co-Authored-By: Claude Opus 5.5 --- .../src/relay/discovery.test.ts | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/packages/client-runtime/src/relay/discovery.test.ts b/packages/client-runtime/src/relay/discovery.test.ts index 9332652df39b5..ec75e11622a84 100644 --- a/packages/client-runtime/src/relay/discovery.test.ts +++ b/packages/client-runtime/src/relay/discovery.test.ts @@ -69,7 +69,7 @@ const makeHarness = Effect.fn("RelayDiscoveryTest.makeHarness")(function* () { const sessionIdentity = { accountId: "account-1" }; const wakeups = yield* SubscriptionRef.make<{ readonly sequence: number; - readonly reason: "application-active" | "credentials-changed"; + readonly reason: ConnectionWakeups.ConnectionWakeup; }>({ sequence: 0, reason: "application-active", @@ -175,7 +175,7 @@ const makeHarness = Effect.fn("RelayDiscoveryTest.makeHarness")(function* () { networkStatus, secondListCall, statusRequests, - wake: (reason: "application-active" | "credentials-changed") => + wake: (reason: ConnectionWakeups.ConnectionWakeup) => SubscriptionRef.update(wakeups, (event) => ({ sequence: event.sequence + 1, reason, @@ -473,6 +473,47 @@ describe("RelayEnvironmentDiscovery", () => { }), ); + it.effect.each(["application-active", "application-active-long"] as const)( + "lists the account again when the app returns to the foreground (%s)", + (reason) => + Effect.gen(function* () { + const harness = yield* makeHarness(); + yield* Ref.set(harness.listedEnvironments, [environments[0]!]); + yield* Effect.gen(function* () { + const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; + const requests = yield* Ref.get(harness.statusRequests); + for (const environment of environments) { + yield* Deferred.succeed( + requests.get(environment.environmentId)!, + status(environment, "online"), + ); + } + // Let the scoped connectivity and wakeup subscriptions start before signing in. + yield* Effect.yieldNow; + yield* harness.wake("credentials-changed"); + const signedIn = yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.filter((state) => state.listed && !state.refreshing), + Stream.runHead, + Effect.map(Option.getOrThrow), + ); + expect([...signedIn.environments.keys()]).toEqual([environments[0]!.environmentId]); + + yield* Ref.set(harness.listedEnvironments, environments); + yield* harness.wake(reason); + const relisted = yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.filter( + (state) => state.environments.size === environments.length && !state.refreshing, + ), + Stream.runHead, + Effect.map(Option.getOrThrow), + ); + expect([...relisted.environments.keys()]).toEqual( + environments.map((environment) => environment.environmentId), + ); + }).pipe(Effect.provide(harness.layer), Effect.scoped); + }), + ); + it.effect("settles to a clean empty state when refreshed while signed out", () => Effect.gen(function* () { const harness = yield* makeHarness(); From a07d67b6b181660e67a7866dc681bc8fa06e16a6 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 2 Nov 2026 23:57:02 +0000 Subject: [PATCH 2/7] fix(client-runtime): list the T3 Connect account again when the app returns to the foreground A server newly registered on the account never appeared on a signed-in client until sign-out, because discovery re-listed only on credentials changes, connectivity recovery and explicit refreshes. After discovery has run once, an application-active (web/desktop) or application-active-long (mobile) wakeup now re-lists the account, skipping when a refresh is already in flight. The mobile probe wakeup is left alone. A re-list keeps the listed rows until the new list lands; sign-out, account switch and listing failures still clear them. Fixes pingdotgg/t3code#29725 Co-Authored-By: Claude Opus 5.5 --- .../client-runtime/src/connection/wakeups.ts | 5 + .../src/relay/discovery.test.ts | 41 ++++ .../client-runtime/src/relay/discovery.ts | 198 +++++++++--------- 3 files changed, 149 insertions(+), 95 deletions(-) diff --git a/packages/client-runtime/src/connection/wakeups.ts b/packages/client-runtime/src/connection/wakeups.ts index c407c1b3a7dd9..8b2266ac3c272 100644 --- a/packages/client-runtime/src/connection/wakeups.ts +++ b/packages/client-runtime/src/connection/wakeups.ts @@ -25,6 +25,11 @@ export function shouldResubscribeAfterWakeup(reason: ConnectionWakeup): boolean return isApplicationActiveWakeup(reason); } +// A brief app switch (the mobile probe) does not justify listing the whole account again. +export function shouldRelistAccountAfterWakeup(reason: ConnectionWakeup): boolean { + return reason === "application-active" || reason === "application-active-long"; +} + export class ConnectionWakeups extends Context.Service< ConnectionWakeups, { diff --git a/packages/client-runtime/src/relay/discovery.test.ts b/packages/client-runtime/src/relay/discovery.test.ts index ec75e11622a84..859e2fa632887 100644 --- a/packages/client-runtime/src/relay/discovery.test.ts +++ b/packages/client-runtime/src/relay/discovery.test.ts @@ -514,6 +514,47 @@ describe("RelayEnvironmentDiscovery", () => { }), ); + it.effect("keeps listed rows visible while the foreground re-list runs", () => + Effect.gen(function* () { + const harness = yield* makeHarness(); + yield* Ref.set(harness.listedEnvironments, [environments[0]!]); + yield* Effect.gen(function* () { + const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; + const requests = yield* Ref.get(harness.statusRequests); + for (const environment of environments) { + yield* Deferred.succeed( + requests.get(environment.environmentId)!, + status(environment, "online"), + ); + } + yield* Effect.yieldNow; + yield* harness.wake("credentials-changed"); + yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.filter((state) => state.listed && !state.refreshing), + Stream.runHead, + ); + + yield* Ref.set(harness.listedEnvironments, environments); + const observed = yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.takeUntil( + (state) => state.environments.size === environments.length && !state.refreshing, + ), + Stream.runCollect, + Effect.forkChild, + ); + yield* harness.wake("application-active"); + const states = yield* Fiber.join(observed); + + const inFlight = states.filter((state) => state.refreshing); + expect(inFlight.length).toBeGreaterThan(0); + for (const state of inFlight) { + expect(state.listed).toBe(true); + expect(state.environments.has(environments[0]!.environmentId)).toBe(true); + } + }).pipe(Effect.provide(harness.layer), Effect.scoped); + }), + ); + it.effect("settles to a clean empty state when refreshed while signed out", () => Effect.gen(function* () { const harness = yield* makeHarness(); diff --git a/packages/client-runtime/src/relay/discovery.ts b/packages/client-runtime/src/relay/discovery.ts index ce5e708829d63..04924c7f7766f 100644 --- a/packages/client-runtime/src/relay/discovery.ts +++ b/packages/client-runtime/src/relay/discovery.ts @@ -215,112 +215,114 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { })); }); - const refresh = refreshLock.withPermits(1)( - Effect.gen(function* () { - yield* Ref.set(hasRefreshed, true); - if ((yield* connectivity.status) === "offline") { - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - refreshing: false, - offline: true, - })); + const listAccount = Effect.gen(function* () { + yield* Ref.set(hasRefreshed, true); + if ((yield* connectivity.status) === "offline") { + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + refreshing: false, + offline: true, + })); + return; + } + + let generation = yield* Ref.get(accountGeneration); + yield* Ref.set(refreshGeneration, generation); + // Rows stay listed while the account is re-listed; every path that cannot list clears them. + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + refreshing: true, + offline: false, + error: Option.none(), + })); + + // Sign-out triggers credentials-changed refreshes and must settle to an empty list. + // Only session-level missing credentials are benign; relay-side auth failures must surface. + const tokenResult = yield* Effect.result(session.clerkToken); + if (tokenResult._tag === "Failure") { + const failure = tokenResult.failure; + if (failure._tag === "ConnectionBlockedError" && failure.reason === "authentication") { + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } + yield* SubscriptionRef.set(state, EMPTY_RELAY_ENVIRONMENT_DISCOVERY_STATE); return; } - - let generation = yield* Ref.get(accountGeneration); + return yield* failure; + } + const clerkToken = tokenResult.success; + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } + const accountId = relayAccountId(clerkToken); + const previousAccountId = yield* Ref.get(activeAccountId); + if ( + Option.isSome(previousAccountId) && + (!Option.isSome(accountId) || previousAccountId.value !== accountId.value) + ) { + generation = yield* Ref.updateAndGet(accountGeneration, (current) => current + 1); yield* Ref.set(refreshGeneration, generation); yield* SubscriptionRef.set(state, { - environments: new Map(), - listed: false, + ...EMPTY_RELAY_ENVIRONMENT_DISCOVERY_STATE, refreshing: true, - offline: false, + }); + } + yield* Ref.set(activeAccountId, accountId); + + const environments = yield* relay + .listEnvironments({ clerkToken }) + .pipe(Effect.mapError(mapManagedRelayError)); + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } + const next = new Map(); + for (const environment of environments) { + next.set(environment.environmentId, { + environment, + availability: "checking", + status: Option.none(), error: Option.none(), }); + } + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + environments: next, + listed: true, + })); - // Sign-out triggers credentials-changed refreshes and must settle to an empty list. - // Only session-level missing credentials are benign; relay-side auth failures must surface. - const tokenResult = yield* Effect.result(session.clerkToken); - if (tokenResult._tag === "Failure") { - const failure = tokenResult.failure; - if (failure._tag === "ConnectionBlockedError" && failure.reason === "authentication") { - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - refreshing: false, - })); + yield* Effect.forEach( + environments, + (environment) => refreshStatus(generation, clerkToken, environment), + { + concurrency: "unbounded", + discard: true, + }, + ); + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + refreshing: false, + })); + }).pipe( + Effect.catch((error) => + Effect.gen(function* () { + const generation = yield* Ref.get(refreshGeneration); + if ((yield* Ref.get(accountGeneration)) !== generation) { return; } - return yield* failure; - } - const clerkToken = tokenResult.success; - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - const accountId = relayAccountId(clerkToken); - const previousAccountId = yield* Ref.get(activeAccountId); - if ( - Option.isSome(previousAccountId) && - (!Option.isSome(accountId) || previousAccountId.value !== accountId.value) - ) { - generation = yield* Ref.updateAndGet(accountGeneration, (current) => current + 1); - yield* Ref.set(refreshGeneration, generation); - } - yield* Ref.set(activeAccountId, accountId); - - const environments = yield* relay - .listEnvironments({ clerkToken }) - .pipe(Effect.mapError(mapManagedRelayError)); - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - const next = new Map(); - for (const environment of environments) { - next.set(environment.environmentId, { - environment, - availability: "checking", - status: Option.none(), - error: Option.none(), - }); - } - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - environments: next, - listed: true, - })); - - yield* Effect.forEach( - environments, - (environment) => refreshStatus(generation, clerkToken, environment), - { - concurrency: "unbounded", - discard: true, - }, - ); - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - refreshing: false, - })); - }).pipe( - Effect.catch((error) => - Effect.gen(function* () { - const generation = yield* Ref.get(refreshGeneration); - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - refreshing: false, - error: Option.some(error), - })); - }), - ), + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + environments: new Map(), + listed: false, + refreshing: false, + error: Option.some(error), + })); + }), ), ); + const refresh = refreshLock.withPermits(1)(listAccount); yield* connectivity.changes.pipe( Stream.changes, @@ -347,7 +349,13 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { yield* SubscriptionRef.set(state, EMPTY_RELAY_ENVIRONMENT_DISCOVERY_STATE); yield* refresh.pipe(Effect.forkScoped); }) - : Effect.void, + : ConnectionWakeups.shouldRelistAccountAfterWakeup(reason) + ? Effect.gen(function* () { + if (!(yield* Ref.get(hasRefreshed))) return; + // A refresh already in flight answers this wakeup too. + yield* refreshLock.withPermitsIfAvailable(1)(listAccount).pipe(Effect.forkScoped); + }) + : Effect.void, ), Effect.forkScoped, ); From 8b92f2f8835a98ffe83ed3ff4e196c4ede950567 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 3 Nov 2026 00:00:02 +0000 Subject: [PATCH 3/7] fix(client-runtime): a re-listed T3 Connect row keeps its last status until the new lookup answers Co-Authored-By: Claude Opus 5.5 --- .../src/relay/discovery.test.ts | 4 +- .../client-runtime/src/relay/discovery.ts | 44 +++++++++++++------ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/packages/client-runtime/src/relay/discovery.test.ts b/packages/client-runtime/src/relay/discovery.test.ts index 859e2fa632887..6a170029c18d5 100644 --- a/packages/client-runtime/src/relay/discovery.test.ts +++ b/packages/client-runtime/src/relay/discovery.test.ts @@ -549,7 +549,9 @@ describe("RelayEnvironmentDiscovery", () => { expect(inFlight.length).toBeGreaterThan(0); for (const state of inFlight) { expect(state.listed).toBe(true); - expect(state.environments.has(environments[0]!.environmentId)).toBe(true); + expect(state.environments.get(environments[0]!.environmentId)?.availability).toBe( + "online", + ); } }).pipe(Effect.provide(harness.layer), Effect.scoped); }), diff --git a/packages/client-runtime/src/relay/discovery.ts b/packages/client-runtime/src/relay/discovery.ts index 04924c7f7766f..b4f27440453c6 100644 --- a/packages/client-runtime/src/relay/discovery.ts +++ b/packages/client-runtime/src/relay/discovery.ts @@ -105,6 +105,17 @@ function validateStatus( return Effect.succeed(status); } +function sameEndpoint( + left: RelayClientEnvironmentRecord, + right: RelayClientEnvironmentRecord, +): boolean { + return ( + left.endpoint.httpBaseUrl === right.endpoint.httpBaseUrl && + left.endpoint.wsBaseUrl === right.endpoint.wsBaseUrl && + left.endpoint.providerKind === right.endpoint.providerKind + ); +} + function relayAccountId(clerkToken: string): Option.Option { try { return Option.fromNullishOr(decodeRelayJwt(clerkToken).sub).pipe( @@ -275,20 +286,25 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { if ((yield* Ref.get(accountGeneration)) !== generation) { return; } - const next = new Map(); - for (const environment of environments) { - next.set(environment.environmentId, { - environment, - availability: "checking", - status: Option.none(), - error: Option.none(), - }); - } - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - environments: next, - listed: true, - })); + yield* SubscriptionRef.update(state, (current) => { + const next = new Map(); + for (const environment of environments) { + const previous = current.environments.get(environment.environmentId); + // A re-listed row keeps its last status until the new lookup answers. + next.set( + environment.environmentId, + previous !== undefined && sameEndpoint(previous.environment, environment) + ? { ...previous, environment } + : { + environment, + availability: "checking", + status: Option.none(), + error: Option.none(), + }, + ); + } + return { ...current, environments: next, listed: true }; + }); yield* Effect.forEach( environments, From 6105063585f0d718be25bfb8bd95cb98911da1e6 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 3 Nov 2026 00:19:51 +0000 Subject: [PATCH 4/7] fix(client-runtime): foregrounding re-lists T3 Connect only when registrations changed Returning to the foreground re-ran the full refresh, which modified refresh to keep rows during the run. That meant a failed re-list wiped good rows, kept rows held stale statuses, and a wakeup was dropped while an older refresh held the lock. Restore main's refresh. On application-active and application-active-long, a forked check lists the account once and refreshes only when the set of environment ids changed. If the current list is not settled, it queues a refresh behind the lock instead. A failed check changes nothing. Co-Authored-By: Claude Opus 5.5 --- .../src/relay/discovery.test.ts | 102 ++++++-- .../client-runtime/src/relay/discovery.ts | 238 +++++++++--------- 2 files changed, 204 insertions(+), 136 deletions(-) diff --git a/packages/client-runtime/src/relay/discovery.test.ts b/packages/client-runtime/src/relay/discovery.test.ts index 6a170029c18d5..a082fb2826b51 100644 --- a/packages/client-runtime/src/relay/discovery.test.ts +++ b/packages/client-runtime/src/relay/discovery.test.ts @@ -61,6 +61,7 @@ function status( const makeHarness = Effect.fn("RelayDiscoveryTest.makeHarness")(function* () { const networkStatus = yield* SubscriptionRef.make("online"); const listCalls = yield* Ref.make(0); + const statusCalls = yield* Ref.make(0); const listedEnvironments = yield* Ref.make>(environments); const listFailure = yield* Ref.make(null); @@ -107,7 +108,8 @@ const makeHarness = Effect.fn("RelayDiscoveryTest.makeHarness")(function* () { return yield* Ref.get(listedEnvironments); }), getEnvironmentStatus: ({ environmentId }) => - Ref.get(statusRequests).pipe( + Ref.update(statusCalls, (current) => current + 1).pipe( + Effect.andThen(Ref.get(statusRequests)), Effect.flatMap((requests) => Deferred.await(requests.get(environmentId)!)), ), listDevices: () => Effect.die("unused"), @@ -174,6 +176,7 @@ const makeHarness = Effect.fn("RelayDiscoveryTest.makeHarness")(function* () { clerkToken, networkStatus, secondListCall, + statusCalls, statusRequests, wake: (reason: ConnectionWakeups.ConnectionWakeup) => SubscriptionRef.update(wakeups, (event) => ({ @@ -514,12 +517,23 @@ describe("RelayEnvironmentDiscovery", () => { }), ); - it.effect("keeps listed rows visible while the foreground re-list runs", () => + it.effect("lists a registration that lands while an earlier refresh checks statuses", () => Effect.gen(function* () { const harness = yield* makeHarness(); yield* Ref.set(harness.listedEnvironments, [environments[0]!]); yield* Effect.gen(function* () { const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; + yield* Effect.yieldNow; + const refreshFiber = yield* Effect.forkChild(discovery.refresh); + yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.filter((state) => state.listed), + Stream.runHead, + ); + + yield* Ref.set(harness.listedEnvironments, environments); + yield* harness.wake("application-active"); + // Let the wakeup reach discovery while the first refresh still holds the lock. + yield* Effect.yieldNow; const requests = yield* Ref.get(harness.statusRequests); for (const environment of environments) { yield* Deferred.succeed( @@ -527,32 +541,78 @@ describe("RelayEnvironmentDiscovery", () => { status(environment, "online"), ); } - yield* Effect.yieldNow; - yield* harness.wake("credentials-changed"); - yield* SubscriptionRef.changes(discovery.state).pipe( - Stream.filter((state) => state.listed && !state.refreshing), - Stream.runHead, - ); + yield* Fiber.join(refreshFiber); - yield* Ref.set(harness.listedEnvironments, environments); - const observed = yield* SubscriptionRef.changes(discovery.state).pipe( - Stream.takeUntil( + const relisted = yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.filter( (state) => state.environments.size === environments.length && !state.refreshing, ), - Stream.runCollect, - Effect.forkChild, + Stream.runHead, + Effect.map(Option.getOrThrow), + ); + expect([...relisted.environments.keys()]).toEqual( + environments.map((environment) => environment.environmentId), + ); + }).pipe(Effect.provide(harness.layer), Effect.scoped); + }), + ); + + it.effect("keeps listed rows when the foreground check cannot list the account", () => + Effect.gen(function* () { + const harness = yield* makeHarness(); + yield* Effect.gen(function* () { + const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; + const requests = yield* Ref.get(harness.statusRequests); + for (const environment of environments) { + yield* Deferred.succeed( + requests.get(environment.environmentId)!, + status(environment, "online"), + ); + } + yield* Effect.yieldNow; + yield* discovery.refresh; + const settled = yield* SubscriptionRef.get(discovery.state); + + yield* Ref.set( + harness.listFailure, + new ManagedRelay.ManagedRelayRequestFailedError({ + action: "list relay-managed environments", + cause: new Error("Relay request failed."), + }), ); yield* harness.wake("application-active"); - const states = yield* Fiber.join(observed); - - const inFlight = states.filter((state) => state.refreshing); - expect(inFlight.length).toBeGreaterThan(0); - for (const state of inFlight) { - expect(state.listed).toBe(true); - expect(state.environments.get(environments[0]!.environmentId)?.availability).toBe( - "online", + yield* Deferred.await(harness.secondListCall); + + const after = yield* SubscriptionRef.get(discovery.state); + expect(after).toBe(settled); + expect(after.environments.size).toBe(environments.length); + expect(Option.isNone(after.error)).toBe(true); + }).pipe(Effect.provide(harness.layer), Effect.scoped); + }), + ); + + it.effect("leaves an unchanged account list untouched when the app returns", () => + Effect.gen(function* () { + const harness = yield* makeHarness(); + yield* Effect.gen(function* () { + const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; + const requests = yield* Ref.get(harness.statusRequests); + for (const environment of environments) { + yield* Deferred.succeed( + requests.get(environment.environmentId)!, + status(environment, "online"), ); } + yield* Effect.yieldNow; + yield* discovery.refresh; + const settled = yield* SubscriptionRef.get(discovery.state); + + yield* harness.wake("application-active"); + yield* Deferred.await(harness.secondListCall); + + expect(yield* SubscriptionRef.get(discovery.state)).toBe(settled); + expect(yield* Ref.get(harness.listCalls)).toBe(2); + expect(yield* Ref.get(harness.statusCalls)).toBe(environments.length); }).pipe(Effect.provide(harness.layer), Effect.scoped); }), ); diff --git a/packages/client-runtime/src/relay/discovery.ts b/packages/client-runtime/src/relay/discovery.ts index b4f27440453c6..7f91ebc05011f 100644 --- a/packages/client-runtime/src/relay/discovery.ts +++ b/packages/client-runtime/src/relay/discovery.ts @@ -105,17 +105,6 @@ function validateStatus( return Effect.succeed(status); } -function sameEndpoint( - left: RelayClientEnvironmentRecord, - right: RelayClientEnvironmentRecord, -): boolean { - return ( - left.endpoint.httpBaseUrl === right.endpoint.httpBaseUrl && - left.endpoint.wsBaseUrl === right.endpoint.wsBaseUrl && - left.endpoint.providerKind === right.endpoint.providerKind - ); -} - function relayAccountId(clerkToken: string): Option.Option { try { return Option.fromNullishOr(decodeRelayJwt(clerkToken).sub).pipe( @@ -226,119 +215,142 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { })); }); - const listAccount = Effect.gen(function* () { - yield* Ref.set(hasRefreshed, true); - if ((yield* connectivity.status) === "offline") { - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - refreshing: false, - offline: true, - })); - return; - } - - let generation = yield* Ref.get(accountGeneration); - yield* Ref.set(refreshGeneration, generation); - // Rows stay listed while the account is re-listed; every path that cannot list clears them. - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - refreshing: true, - offline: false, - error: Option.none(), - })); - - // Sign-out triggers credentials-changed refreshes and must settle to an empty list. - // Only session-level missing credentials are benign; relay-side auth failures must surface. - const tokenResult = yield* Effect.result(session.clerkToken); - if (tokenResult._tag === "Failure") { - const failure = tokenResult.failure; - if (failure._tag === "ConnectionBlockedError" && failure.reason === "authentication") { - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - yield* SubscriptionRef.set(state, EMPTY_RELAY_ENVIRONMENT_DISCOVERY_STATE); + const refresh = refreshLock.withPermits(1)( + Effect.gen(function* () { + yield* Ref.set(hasRefreshed, true); + if ((yield* connectivity.status) === "offline") { + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + refreshing: false, + offline: true, + })); return; } - return yield* failure; - } - const clerkToken = tokenResult.success; - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - const accountId = relayAccountId(clerkToken); - const previousAccountId = yield* Ref.get(activeAccountId); - if ( - Option.isSome(previousAccountId) && - (!Option.isSome(accountId) || previousAccountId.value !== accountId.value) - ) { - generation = yield* Ref.updateAndGet(accountGeneration, (current) => current + 1); + + let generation = yield* Ref.get(accountGeneration); yield* Ref.set(refreshGeneration, generation); yield* SubscriptionRef.set(state, { - ...EMPTY_RELAY_ENVIRONMENT_DISCOVERY_STATE, + environments: new Map(), + listed: false, refreshing: true, + offline: false, + error: Option.none(), }); - } - yield* Ref.set(activeAccountId, accountId); - const environments = yield* relay - .listEnvironments({ clerkToken }) - .pipe(Effect.mapError(mapManagedRelayError)); - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - yield* SubscriptionRef.update(state, (current) => { + // Sign-out triggers credentials-changed refreshes and must settle to an empty list. + // Only session-level missing credentials are benign; relay-side auth failures must surface. + const tokenResult = yield* Effect.result(session.clerkToken); + if (tokenResult._tag === "Failure") { + const failure = tokenResult.failure; + if (failure._tag === "ConnectionBlockedError" && failure.reason === "authentication") { + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + refreshing: false, + })); + return; + } + return yield* failure; + } + const clerkToken = tokenResult.success; + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } + const accountId = relayAccountId(clerkToken); + const previousAccountId = yield* Ref.get(activeAccountId); + if ( + Option.isSome(previousAccountId) && + (!Option.isSome(accountId) || previousAccountId.value !== accountId.value) + ) { + generation = yield* Ref.updateAndGet(accountGeneration, (current) => current + 1); + yield* Ref.set(refreshGeneration, generation); + } + yield* Ref.set(activeAccountId, accountId); + + const environments = yield* relay + .listEnvironments({ clerkToken }) + .pipe(Effect.mapError(mapManagedRelayError)); + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } const next = new Map(); for (const environment of environments) { - const previous = current.environments.get(environment.environmentId); - // A re-listed row keeps its last status until the new lookup answers. - next.set( - environment.environmentId, - previous !== undefined && sameEndpoint(previous.environment, environment) - ? { ...previous, environment } - : { - environment, - availability: "checking", - status: Option.none(), - error: Option.none(), - }, - ); + next.set(environment.environmentId, { + environment, + availability: "checking", + status: Option.none(), + error: Option.none(), + }); } - return { ...current, environments: next, listed: true }; - }); + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + environments: next, + listed: true, + })); - yield* Effect.forEach( - environments, - (environment) => refreshStatus(generation, clerkToken, environment), - { - concurrency: "unbounded", - discard: true, - }, - ); - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - refreshing: false, - })); - }).pipe( + yield* Effect.forEach( + environments, + (environment) => refreshStatus(generation, clerkToken, environment), + { + concurrency: "unbounded", + discard: true, + }, + ); + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + refreshing: false, + })); + }).pipe( + Effect.catch((error) => + Effect.gen(function* () { + const generation = yield* Ref.get(refreshGeneration); + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } + yield* SubscriptionRef.update(state, (current) => ({ + ...current, + refreshing: false, + error: Option.some(error), + })); + }), + ), + ), + ); + + // Refreshes only when the account's registrations changed, so foregrounding keeps unchanged rows. + const checkRegistrations = Effect.fn("RelayEnvironmentDiscovery.checkRegistrations")( + function* () { + if (!(yield* Ref.get(hasRefreshed)) || (yield* connectivity.status) === "offline") { + return; + } + const current = yield* SubscriptionRef.get(state); + if (!current.listed || current.refreshing || Option.isSome(current.error)) { + return yield* refresh; + } + const generation = yield* Ref.get(accountGeneration); + const clerkToken = yield* session.clerkToken; + const listed = yield* relay.listEnvironments({ clerkToken }); + if ((yield* Ref.get(accountGeneration)) !== generation) { + return; + } + const known = (yield* SubscriptionRef.get(state)).environments; + if ( + listed.length === known.size && + listed.every((environment) => known.has(environment.environmentId)) + ) { + return; + } + yield* refresh; + }, Effect.catch((error) => - Effect.gen(function* () { - const generation = yield* Ref.get(refreshGeneration); - if ((yield* Ref.get(accountGeneration)) !== generation) { - return; - } - yield* SubscriptionRef.update(state, (current) => ({ - ...current, - environments: new Map(), - listed: false, - refreshing: false, - error: Option.some(error), - })); - }), + Effect.logDebug("Relay foreground registration check failed", { error }), ), ); - const refresh = refreshLock.withPermits(1)(listAccount); yield* connectivity.changes.pipe( Stream.changes, @@ -366,11 +378,7 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { yield* refresh.pipe(Effect.forkScoped); }) : ConnectionWakeups.shouldRelistAccountAfterWakeup(reason) - ? Effect.gen(function* () { - if (!(yield* Ref.get(hasRefreshed))) return; - // A refresh already in flight answers this wakeup too. - yield* refreshLock.withPermitsIfAvailable(1)(listAccount).pipe(Effect.forkScoped); - }) + ? checkRegistrations().pipe(Effect.forkScoped) : Effect.void, ), Effect.forkScoped, From 3c431a15a8a23b8dce8a0d4c8147c3f7ab201bc0 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 3 Nov 2026 00:37:41 +0000 Subject: [PATCH 5/7] fix(client-runtime): refocusing a visible window re-checks T3 Connect registrations A desktop or browser window left visible beside another app never fires visibilitychange when focused again, so it never re-listed the account. The web platform now emits an application-focused wakeup on window focus while visible. Only relay discovery acts on it; the connection supervisor filters it out so focus cannot arm a running probe's silent-socket check, and it neither resets retry backoff nor resubscribes shell or threads. Foreground checks are coalesced: a wakeup is a no-op while one is already running, including the refresh it waits on. Signed-out clients skip the check, so returning to the app no longer republishes discovery state. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/connection/platform.ts | 18 ++++++ .../src/connection/supervisor.ts | 1 + .../client-runtime/src/connection/wakeups.ts | 12 +++- .../src/relay/discovery.test.ts | 60 ++++++++++++++++++- .../client-runtime/src/relay/discovery.ts | 9 ++- 5 files changed, 97 insertions(+), 3 deletions(-) diff --git a/apps/web/src/connection/platform.ts b/apps/web/src/connection/platform.ts index e60ed172e9260..08506318ac369 100644 --- a/apps/web/src/connection/platform.ts +++ b/apps/web/src/connection/platform.ts @@ -142,6 +142,24 @@ const layerWakeups = Wakeups.layer({ }), ).pipe(Effect.asVoid), ), + // A window left visible beside another app never fires visibilitychange when refocused. + Stream.callback<"application-focused">((queue) => + Effect.acquireRelease( + Effect.sync(() => { + const listener = () => { + if (document.visibilityState === "visible") { + Queue.offerUnsafe(queue, "application-focused"); + } + }; + window.addEventListener("focus", listener); + return listener; + }), + (listener) => + Effect.sync(() => { + window.removeEventListener("focus", listener); + }), + ).pipe(Effect.asVoid), + ), managedRelayAccountChanges(appAtomRegistry).pipe( Stream.map(() => "credentials-changed" as const), ), diff --git a/packages/client-runtime/src/connection/supervisor.ts b/packages/client-runtime/src/connection/supervisor.ts index 3c969f0206243..51e450b12d5dd 100644 --- a/packages/client-runtime/src/connection/supervisor.ts +++ b/packages/client-runtime/src/connection/supervisor.ts @@ -1184,6 +1184,7 @@ export const make = Effect.fn("EnvironmentSupervisor.make")(function* ( Effect.forkScoped, ); yield* wakeups.changes.pipe( + Stream.filter(ConnectionWakeups.reachesConnectionSupervisor), Stream.runForEach((reason) => // A long suspension can hide a network change the platform never reported. (reason === "network-changed" || reason === "application-active-long" diff --git a/packages/client-runtime/src/connection/wakeups.ts b/packages/client-runtime/src/connection/wakeups.ts index 8b2266ac3c272..746160681ee9d 100644 --- a/packages/client-runtime/src/connection/wakeups.ts +++ b/packages/client-runtime/src/connection/wakeups.ts @@ -6,6 +6,7 @@ export type ConnectionWakeup = | "application-active" | "application-active-probe" | "application-active-long" + | "application-focused" | "credentials-changed" | "network-changed"; @@ -27,7 +28,16 @@ export function shouldResubscribeAfterWakeup(reason: ConnectionWakeup): boolean // A brief app switch (the mobile probe) does not justify listing the whole account again. export function shouldRelistAccountAfterWakeup(reason: ConnectionWakeup): boolean { - return reason === "application-active" || reason === "application-active-long"; + return ( + reason === "application-active" || + reason === "application-active-long" || + reason === "application-focused" + ); +} + +// Focus fires on every window switch; any wakeup would arm a running probe's silent-socket check. +export function reachesConnectionSupervisor(reason: ConnectionWakeup): boolean { + return reason !== "application-focused"; } export class ConnectionWakeups extends Context.Service< diff --git a/packages/client-runtime/src/relay/discovery.test.ts b/packages/client-runtime/src/relay/discovery.test.ts index a082fb2826b51..b1a78c157c5f0 100644 --- a/packages/client-runtime/src/relay/discovery.test.ts +++ b/packages/client-runtime/src/relay/discovery.test.ts @@ -476,7 +476,7 @@ describe("RelayEnvironmentDiscovery", () => { }), ); - it.effect.each(["application-active", "application-active-long"] as const)( + it.effect.each(["application-active", "application-active-long", "application-focused"] as const)( "lists the account again when the app returns to the foreground (%s)", (reason) => Effect.gen(function* () { @@ -557,6 +557,64 @@ describe("RelayEnvironmentDiscovery", () => { }), ); + it.effect("coalesces foreground checks that arrive during an in-flight refresh", () => + Effect.gen(function* () { + const harness = yield* makeHarness(); + yield* Effect.gen(function* () { + const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; + yield* Effect.yieldNow; + const refreshFiber = yield* Effect.forkChild(discovery.refresh); + yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.filter((state) => state.listed), + Stream.runHead, + ); + + for (const reason of [ + "application-active", + "application-focused", + "application-active", + "application-focused", + "application-active-long", + ] as const) { + yield* harness.wake(reason); + yield* Effect.yieldNow; + } + // Waits on the lock behind every refresh the wakeups queued. + const lastRefresh = yield* Effect.forkChild(discovery.refresh); + yield* Effect.yieldNow; + const requests = yield* Ref.get(harness.statusRequests); + for (const environment of environments) { + yield* Deferred.succeed( + requests.get(environment.environmentId)!, + status(environment, "online"), + ); + } + yield* Fiber.join(refreshFiber); + yield* Fiber.join(lastRefresh); + + expect(yield* Ref.get(harness.listCalls)).toBe(3); + }).pipe(Effect.provide(harness.layer), Effect.scoped); + }), + ); + + it.effect("leaves a signed-out state untouched when the app returns", () => + Effect.gen(function* () { + const harness = yield* makeHarness(); + yield* Effect.gen(function* () { + const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; + yield* Effect.yieldNow; + yield* Ref.set(harness.clerkToken, null); + yield* discovery.refresh; + const signedOut = yield* SubscriptionRef.get(discovery.state); + + yield* harness.wake("application-active"); + yield* Effect.yieldNow; + + expect(yield* SubscriptionRef.get(discovery.state)).toBe(signedOut); + }).pipe(Effect.provide(harness.layer), Effect.scoped); + }), + ); + it.effect("keeps listed rows when the foreground check cannot list the account", () => Effect.gen(function* () { const harness = yield* makeHarness(); diff --git a/packages/client-runtime/src/relay/discovery.ts b/packages/client-runtime/src/relay/discovery.ts index 7f91ebc05011f..6b068069730d0 100644 --- a/packages/client-runtime/src/relay/discovery.ts +++ b/packages/client-runtime/src/relay/discovery.ts @@ -123,6 +123,7 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { const wakeups = yield* ConnectionWakeups.ConnectionWakeups; const state = yield* SubscriptionRef.make(EMPTY_RELAY_ENVIRONMENT_DISCOVERY_STATE); const refreshLock = yield* Semaphore.make(1); + const foregroundCheckLock = yield* Semaphore.make(1); const hasRefreshed = yield* Ref.make(false); const accountGeneration = yield* Ref.make(0); const activeAccountId = yield* Ref.make>(Option.none()); @@ -325,7 +326,11 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { // Refreshes only when the account's registrations changed, so foregrounding keeps unchanged rows. const checkRegistrations = Effect.fn("RelayEnvironmentDiscovery.checkRegistrations")( function* () { - if (!(yield* Ref.get(hasRefreshed)) || (yield* connectivity.status) === "offline") { + if ( + !(yield* Ref.get(hasRefreshed)) || + (yield* connectivity.status) === "offline" || + Option.isNone(yield* session.identity) + ) { return; } const current = yield* SubscriptionRef.get(state); @@ -350,6 +355,8 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { Effect.catch((error) => Effect.logDebug("Relay foreground registration check failed", { error }), ), + // A check that waits on an in-flight refresh lists the account again once it finishes. + foregroundCheckLock.withPermitsIfAvailable(1), ); yield* connectivity.changes.pipe( From bd5ae2ff3eb4161329e619fcd1f8260bc4af349e Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 3 Nov 2026 00:52:47 +0000 Subject: [PATCH 6/7] fix(client-runtime): a wakeup during a running T3 Connect check runs one more check Co-Authored-By: Claude Opus 5.5 --- .../src/relay/discovery.test.ts | 49 ++++++++++++++++++- .../client-runtime/src/relay/discovery.ts | 17 +++++-- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/packages/client-runtime/src/relay/discovery.test.ts b/packages/client-runtime/src/relay/discovery.test.ts index b1a78c157c5f0..f46b0659e5163 100644 --- a/packages/client-runtime/src/relay/discovery.test.ts +++ b/packages/client-runtime/src/relay/discovery.test.ts @@ -592,7 +592,54 @@ describe("RelayEnvironmentDiscovery", () => { yield* Fiber.join(refreshFiber); yield* Fiber.join(lastRefresh); - expect(yield* Ref.get(harness.listCalls)).toBe(3); + // The first refresh, one queued refresh, one trailing check's listing, and the last refresh. + expect(yield* Ref.get(harness.listCalls)).toBe(4); + }).pipe(Effect.provide(harness.layer), Effect.scoped); + }), + ); + + it.effect("lists a registration that lands while a foreground check is refreshing", () => + Effect.gen(function* () { + const harness = yield* makeHarness(); + yield* Ref.set(harness.listedEnvironments, []); + yield* Effect.gen(function* () { + const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; + yield* Effect.yieldNow; + yield* harness.wake("credentials-changed"); + yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.filter((state) => state.listed && !state.refreshing), + Stream.runHead, + ); + + yield* Ref.set(harness.listedEnvironments, [environments[0]!]); + yield* harness.wake("application-active"); + yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.filter((state) => state.environments.has(environments[0]!.environmentId)), + Stream.runHead, + ); + + // The check's refresh now waits on the first status while another device registers. + yield* Ref.set(harness.listedEnvironments, environments); + yield* harness.wake("application-focused"); + yield* Effect.yieldNow; + const requests = yield* Ref.get(harness.statusRequests); + for (const environment of environments) { + yield* Deferred.succeed( + requests.get(environment.environmentId)!, + status(environment, "online"), + ); + } + + const relisted = yield* SubscriptionRef.changes(discovery.state).pipe( + Stream.filter( + (state) => state.environments.size === environments.length && !state.refreshing, + ), + Stream.runHead, + Effect.map(Option.getOrThrow), + ); + expect([...relisted.environments.keys()]).toEqual( + environments.map((environment) => environment.environmentId), + ); }).pipe(Effect.provide(harness.layer), Effect.scoped); }), ); diff --git a/packages/client-runtime/src/relay/discovery.ts b/packages/client-runtime/src/relay/discovery.ts index 6b068069730d0..bb829ac0193a3 100644 --- a/packages/client-runtime/src/relay/discovery.ts +++ b/packages/client-runtime/src/relay/discovery.ts @@ -124,6 +124,7 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { const state = yield* SubscriptionRef.make(EMPTY_RELAY_ENVIRONMENT_DISCOVERY_STATE); const refreshLock = yield* Semaphore.make(1); const foregroundCheckLock = yield* Semaphore.make(1); + const registrationCheckRequested = yield* Ref.make(false); const hasRefreshed = yield* Ref.make(false); const accountGeneration = yield* Ref.make(0); const activeAccountId = yield* Ref.make>(Option.none()); @@ -355,8 +356,18 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { Effect.catch((error) => Effect.logDebug("Relay foreground registration check failed", { error }), ), - // A check that waits on an in-flight refresh lists the account again once it finishes. - foregroundCheckLock.withPermitsIfAvailable(1), + ); + // A wakeup during a running check is answered by one more check once that one finishes. + const requestRegistrationCheck = Ref.set(registrationCheckRequested, true).pipe( + Effect.andThen( + foregroundCheckLock.withPermitsIfAvailable(1)( + Effect.gen(function* () { + while (yield* Ref.getAndSet(registrationCheckRequested, false)) { + yield* checkRegistrations(); + } + }), + ), + ), ); yield* connectivity.changes.pipe( @@ -385,7 +396,7 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () { yield* refresh.pipe(Effect.forkScoped); }) : ConnectionWakeups.shouldRelistAccountAfterWakeup(reason) - ? checkRegistrations().pipe(Effect.forkScoped) + ? requestRegistrationCheck.pipe(Effect.forkScoped) : Effect.void, ), Effect.forkScoped, From bb3f9df1209bcf9c9765b70b53a13c27c4e82f6d Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 10 Nov 2026 23:38:28 +0000 Subject: [PATCH 7/7] test(client-runtime): drop foreground discovery tests that overlap or cannot fail AI-assisted; verified with the tests and tools listed above. --- .../src/relay/discovery.test.ts | 64 ------------------- 1 file changed, 64 deletions(-) diff --git a/packages/client-runtime/src/relay/discovery.test.ts b/packages/client-runtime/src/relay/discovery.test.ts index f46b0659e5163..79e9731d61c88 100644 --- a/packages/client-runtime/src/relay/discovery.test.ts +++ b/packages/client-runtime/src/relay/discovery.test.ts @@ -598,70 +598,6 @@ describe("RelayEnvironmentDiscovery", () => { }), ); - it.effect("lists a registration that lands while a foreground check is refreshing", () => - Effect.gen(function* () { - const harness = yield* makeHarness(); - yield* Ref.set(harness.listedEnvironments, []); - yield* Effect.gen(function* () { - const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; - yield* Effect.yieldNow; - yield* harness.wake("credentials-changed"); - yield* SubscriptionRef.changes(discovery.state).pipe( - Stream.filter((state) => state.listed && !state.refreshing), - Stream.runHead, - ); - - yield* Ref.set(harness.listedEnvironments, [environments[0]!]); - yield* harness.wake("application-active"); - yield* SubscriptionRef.changes(discovery.state).pipe( - Stream.filter((state) => state.environments.has(environments[0]!.environmentId)), - Stream.runHead, - ); - - // The check's refresh now waits on the first status while another device registers. - yield* Ref.set(harness.listedEnvironments, environments); - yield* harness.wake("application-focused"); - yield* Effect.yieldNow; - const requests = yield* Ref.get(harness.statusRequests); - for (const environment of environments) { - yield* Deferred.succeed( - requests.get(environment.environmentId)!, - status(environment, "online"), - ); - } - - const relisted = yield* SubscriptionRef.changes(discovery.state).pipe( - Stream.filter( - (state) => state.environments.size === environments.length && !state.refreshing, - ), - Stream.runHead, - Effect.map(Option.getOrThrow), - ); - expect([...relisted.environments.keys()]).toEqual( - environments.map((environment) => environment.environmentId), - ); - }).pipe(Effect.provide(harness.layer), Effect.scoped); - }), - ); - - it.effect("leaves a signed-out state untouched when the app returns", () => - Effect.gen(function* () { - const harness = yield* makeHarness(); - yield* Effect.gen(function* () { - const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery; - yield* Effect.yieldNow; - yield* Ref.set(harness.clerkToken, null); - yield* discovery.refresh; - const signedOut = yield* SubscriptionRef.get(discovery.state); - - yield* harness.wake("application-active"); - yield* Effect.yieldNow; - - expect(yield* SubscriptionRef.get(discovery.state)).toBe(signedOut); - }).pipe(Effect.provide(harness.layer), Effect.scoped); - }), - ); - it.effect("keeps listed rows when the foreground check cannot list the account", () => Effect.gen(function* () { const harness = yield* makeHarness();