Simplify Connect onboarding to sign-in only
- Remove device publishing flow from onboarding - Add per-account "Don't show this again" opt-out - Update mobile and web copy to T3 Connect
This commit is contained in:
1 parent
53ab016efd
commit
4f648f1e11
20 files changed
+300
-682
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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<A>(
|
||||
let errorTraceId: string | null = null;
|
||||
if (result._tag === "Failure") {
|
||||
const cause = Cause.squash(result.cause);
|
||||
error = cause instanceof Error ? cause.message : "Could not load T3 Cloud data.";
|
||||
error = cause instanceof Error ? cause.message : "Could not load T3 Connect data.";
|
||||
errorTraceId = findErrorTraceId(cause);
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user