+
+
+ {step === "publish" ? (
+ <>
+
+
+ >
+ ) : (
+
+ )}
+
diff --git a/apps/web/src/connection/platform.ts b/apps/web/src/connection/platform.ts
index f74465048f..56d25fa142 100644
--- a/apps/web/src/connection/platform.ts
+++ b/apps/web/src/connection/platform.ts
@@ -182,7 +182,7 @@ const capabilitiesLayer = Layer.effectContext(
if (session === null) {
return yield* new ConnectionBlockedError({
reason: "authentication",
- detail: "Sign in to T3 Cloud to connect this environment.",
+ detail: "Sign in to T3 Connect to connect this environment.",
});
}
const token = yield* session.readClerkToken().pipe(
@@ -197,7 +197,7 @@ const capabilitiesLayer = Layer.effectContext(
if (token === null) {
return yield* new ConnectionBlockedError({
reason: "authentication",
- detail: "The T3 Cloud session is unavailable.",
+ detail: "The T3 Connect session is unavailable.",
});
}
return token;
diff --git a/packages/client-runtime/src/relay/discovery.test.ts b/packages/client-runtime/src/relay/discovery.test.ts
index 66c27b8678..8cb963000b 100644
--- a/packages/client-runtime/src/relay/discovery.test.ts
+++ b/packages/client-runtime/src/relay/discovery.test.ts
@@ -342,6 +342,55 @@ describe("RelayEnvironmentDiscovery", () => {
}),
);
+ it.effect("refreshes proactively when credentials change before any manual refresh", () =>
+ 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"),
+ );
+ }
+
+ // Let the scoped wakeup subscription start before emitting, mirroring
+ // a real sign-in which always happens long after service start.
+ yield* Effect.yieldNow;
+
+ // Sign-in activates the session and emits credentials-changed; the
+ // list must populate without any screen having asked for a refresh.
+ yield* harness.wake("credentials-changed");
+ const populated = yield* SubscriptionRef.changes(discovery.state).pipe(
+ Stream.filter(
+ (state) => state.environments.size === environments.length && !state.refreshing,
+ ),
+ Stream.runHead,
+ Effect.map(Option.getOrThrow),
+ );
+ expect(Option.isNone(populated.error)).toBe(true);
+ expect(yield* Ref.get(harness.listCalls)).toBe(1);
+ }).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();
+ yield* Effect.gen(function* () {
+ const discovery = yield* RelayEnvironmentDiscovery.RelayEnvironmentDiscovery;
+ yield* Ref.set(harness.clerkToken, null);
+ yield* discovery.refresh;
+
+ const state = yield* SubscriptionRef.get(discovery.state);
+ expect(state.environments.size).toBe(0);
+ expect(state.refreshing).toBe(false);
+ expect(Option.isNone(state.error)).toBe(true);
+ }).pipe(Effect.provide(harness.layer));
+ }),
+ );
+
it.effect("does not republish stale rows after sign-out invalidates an in-flight refresh", () =>
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 8cbadea1ca..9ef99e2fce 100644
--- a/packages/client-runtime/src/relay/discovery.ts
+++ b/packages/client-runtime/src/relay/discovery.ts
@@ -279,10 +279,15 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () {
if ((yield* Ref.get(accountGeneration)) !== generation) {
return;
}
+ // Signed out is the idle state, not a failure: the proactive
+ // refresh on credentials-changed also runs on sign-out and must
+ // settle back to a clean empty list.
+ const signedOut =
+ error._tag === "ConnectionBlockedError" && error.reason === "authentication";
yield* SubscriptionRef.update(state, (current) => ({
...current,
refreshing: false,
- error: Option.some(error),
+ error: signedOut ? Option.none() : Option.some(error),
}));
}),
),
@@ -311,11 +316,12 @@ export const make = Effect.fn("RelayEnvironmentDiscovery.make")(function* () {
yield* Ref.update(accountGeneration, (current) => current + 1);
yield* Ref.set(activeAccountId, Option.none());
yield* Ref.set(offlineReportFingerprints, new Map());
- const shouldRefresh = yield* Ref.get(hasRefreshed);
yield* SubscriptionRef.set(state, EMPTY_RELAY_ENVIRONMENT_DISCOVERY_STATE);
- if (shouldRefresh) {
- yield* refresh.pipe(Effect.forkScoped);
- }
+ // Refresh proactively — this wakeup fires when a session activates
+ // (sign-in or cold start), and the list should be populated before
+ // any screen asks for it. A signed-out refresh settles back to the
+ // clean empty state.
+ yield* refresh.pipe(Effect.forkScoped);
})
: Effect.void,
),
diff --git a/packages/client-runtime/src/relay/managedRelayState.ts b/packages/client-runtime/src/relay/managedRelayState.ts
index ec6a0710dd..1d12c90aae 100644
--- a/packages/client-runtime/src/relay/managedRelayState.ts
+++ b/packages/client-runtime/src/relay/managedRelayState.ts
@@ -123,7 +123,7 @@ export function createManagedRelaySession(input: ManagedRelaySessionInput): Mana
try: () => readCachedClerkToken(nowMillis),
catch: (cause) =>
new ManagedRelaySessionError({
- message: "Could not obtain the T3 Cloud session token.",
+ message: "Could not obtain the T3 Connect session token.",
cause,
}),
});
@@ -181,7 +181,7 @@ function readSessionClerkToken(
? Effect.succeed(token)
: Effect.fail(
new ManagedRelaySessionError({
- message: "The T3 Cloud session token is unavailable.",
+ message: "The T3 Connect session token is unavailable.",
}),
),
),
@@ -226,7 +226,7 @@ function requireClerkToken(
if (!session || session.accountId !== accountId) {
return Effect.fail(
new ManagedRelaySessionError({
- message: "Sign in to T3 Cloud before loading relay data.",
+ message: "Sign in to T3 Connect before loading relay data.",
}),
);
}
@@ -296,7 +296,7 @@ export function readManagedRelaySnapshotState