fix(web): onboarding Continue no longer locks on computers that won't connect (#16887)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
87c366b120
commit
db46c42744
6 files changed
+100
-17
No files matched your search
@@ -64,7 +64,7 @@ vi.mock("../../state/environments", () => {
|
||||
environmentId,
|
||||
label: environmentId,
|
||||
connection: { phase: "connected" },
|
||||
entry: { target: { _tag: "DirectConnectionTarget" } },
|
||||
entry: { enabled: true, target: { _tag: "DirectConnectionTarget" } },
|
||||
});
|
||||
const primary = environment("primary");
|
||||
return {
|
||||
|
||||
@@ -151,6 +151,7 @@ const primaryEnvironment = {
|
||||
label: "This computer",
|
||||
connection: { phase: "connected" },
|
||||
entry: {
|
||||
enabled: true,
|
||||
target: new PrimaryConnectionTarget({
|
||||
environmentId: primaryId,
|
||||
label: "This computer",
|
||||
@@ -164,6 +165,7 @@ const remoteEnvironment = {
|
||||
label: "Paired computer",
|
||||
connection: { phase: "connected" },
|
||||
entry: {
|
||||
enabled: true,
|
||||
target: new BearerConnectionTarget({
|
||||
environmentId: remoteId,
|
||||
label: "Paired computer",
|
||||
|
||||
@@ -38,6 +38,7 @@ vi.mock("../../state/environments", () => {
|
||||
environmentId: "test-env",
|
||||
label: "Computer",
|
||||
connection: { phase: "connected" },
|
||||
entry: { enabled: true },
|
||||
};
|
||||
return {
|
||||
useEnvironments: () => ({ environments: [environment] }),
|
||||
|
||||
@@ -58,7 +58,10 @@ import { newProjectId, randomUUID } from "../../lib/utils";
|
||||
import { agentSessionImport } from "../../state/agentSessions";
|
||||
import { readProjects, useProjects } from "../../state/entities";
|
||||
import { useEnvironments, usePrimaryEnvironment } from "../../state/environments";
|
||||
import { isOnboardingRelayEnvironment } from "../../onboarding/targetEnvironment.logic";
|
||||
import {
|
||||
isOnboardingRelayEnvironment,
|
||||
resolveOnboardingSetup,
|
||||
} from "../../onboarding/targetEnvironment.logic";
|
||||
import { useProjectScans } from "../../onboarding/useProjectScans";
|
||||
import { projectEnvironment } from "../../state/projects";
|
||||
import { serverEnvironment } from "../../state/server";
|
||||
@@ -78,6 +81,7 @@ import { readCodexSetupMode } from "../settings/CodexSetupSection.logic";
|
||||
import { buildProviderInstanceUpdatePatch } from "../settings/SettingsPanels.logic";
|
||||
import { TerminalViewport } from "../ThreadTerminalDrawer";
|
||||
import { CloudEnvironmentConnectRows } from "../cloud/CloudEnvironmentConnectList";
|
||||
import { presentSavedCloudEnvironmentConnection } from "../cloud/cloudEnvironmentConnectionPresentation";
|
||||
import { ProviderInstanceIcon } from "../chat/ProviderInstanceIcon";
|
||||
import { T3Wordmark } from "../T3Wordmark";
|
||||
import { Alert, AlertDescription } from "../ui/alert";
|
||||
@@ -141,11 +145,14 @@ export function WelcomeWizard({
|
||||
for (const environment of newComputers) {
|
||||
autoSelectedComputers.current.add(environment.environmentId);
|
||||
}
|
||||
// A computer the user switched off stays unselected until they pick it.
|
||||
const enabledComputers = newComputers.filter((environment) => environment.entry.enabled);
|
||||
if (enabledComputers.length === 0) return;
|
||||
setSelection(
|
||||
(current) =>
|
||||
new Set([
|
||||
...(current ?? []),
|
||||
...newComputers.map((environment) => environment.environmentId),
|
||||
...enabledComputers.map((environment) => environment.environmentId),
|
||||
]),
|
||||
);
|
||||
}, [environments]);
|
||||
@@ -262,11 +269,7 @@ export function WelcomeWizard({
|
||||
})
|
||||
}
|
||||
onContinue={() =>
|
||||
startSetup(
|
||||
environments
|
||||
.filter((environment) => selectedIds.has(environment.environmentId))
|
||||
.map((environment) => environment.environmentId),
|
||||
)
|
||||
startSetup(resolveOnboardingSetup(environments, selectedIds).environmentIds)
|
||||
}
|
||||
onPaired={(environmentId) => {
|
||||
setSelection(new Set([...selectedIds, environmentId]));
|
||||
@@ -315,14 +318,10 @@ function ConnectionStep({
|
||||
);
|
||||
const [pairingOpen, setPairingOpen] = useState(expandPairingInitially);
|
||||
const [isPairing, setIsPairing] = useState(false);
|
||||
const ready =
|
||||
selectedIds.size > 0 &&
|
||||
[...selectedIds].every((id) =>
|
||||
environments.some(
|
||||
(environment) =>
|
||||
environment.environmentId === id && environment.connection.phase === "connected",
|
||||
),
|
||||
);
|
||||
const { ready, skippedIds } = resolveOnboardingSetup(environments, selectedIds);
|
||||
const skippedLabels = environments
|
||||
.filter((environment) => skippedIds.includes(environment.environmentId))
|
||||
.map((environment) => environment.label);
|
||||
const continueRef = useRef<HTMLButtonElement>(null);
|
||||
useEffect(() => {
|
||||
if (
|
||||
@@ -365,7 +364,7 @@ function ConnectionStep({
|
||||
{environment.label}
|
||||
</span>
|
||||
<span className="shrink-0 text-xs text-muted-foreground">
|
||||
{environment.connection.phase === "connected" ? "Connected" : "Connecting…"}
|
||||
{presentSavedCloudEnvironmentConnection(environment.connection).buttonLabel}
|
||||
</span>
|
||||
</span>
|
||||
{environment.displayUrl ? (
|
||||
@@ -421,6 +420,12 @@ function ConnectionStep({
|
||||
</Collapsible>
|
||||
</div>
|
||||
</div>
|
||||
{skippedLabels.length > 0 ? (
|
||||
<p className="mt-4 text-xs text-muted-foreground">
|
||||
Not connected, so setup skips {skippedLabels.join(", ")}. You can set{" "}
|
||||
{skippedLabels.length === 1 ? "it" : "them"} up later from Settings.
|
||||
</p>
|
||||
) : null}
|
||||
<div className="mt-6 flex flex-col-reverse gap-4 sm:flex-row sm:items-center sm:justify-between sm:gap-6">
|
||||
<p className="min-w-0 text-xs leading-relaxed text-muted-foreground">
|
||||
T3 Code collects anonymous usage data to help us improve it. To read more about how your
|
||||
|
||||
@@ -9,6 +9,7 @@ import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
isOnboardingRelayEnvironment,
|
||||
resolveOnboardingSetup,
|
||||
resolveOnboardingTargetEnvironment,
|
||||
} from "./targetEnvironment.logic";
|
||||
|
||||
@@ -209,3 +210,49 @@ describe("isOnboardingRelayEnvironment", () => {
|
||||
).toEqual([olderRelay]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveOnboardingSetup", () => {
|
||||
const computer = (id: string, phase: string) => ({
|
||||
environmentId: EnvironmentId.make(id),
|
||||
connection: { phase },
|
||||
});
|
||||
const local = computer("local", "connected");
|
||||
|
||||
it("skips selected computers that will not connect on their own", () => {
|
||||
const environments = [
|
||||
local,
|
||||
computer("switched-off", "available"),
|
||||
computer("offline", "offline"),
|
||||
computer("failing", "reconnecting"),
|
||||
computer("old-client", "unsupported"),
|
||||
];
|
||||
expect(
|
||||
resolveOnboardingSetup(
|
||||
environments,
|
||||
new Set(environments.map((environment) => environment.environmentId)),
|
||||
),
|
||||
).toEqual({
|
||||
ready: true,
|
||||
environmentIds: [local.environmentId],
|
||||
skippedIds: environments.slice(1).map((environment) => environment.environmentId),
|
||||
});
|
||||
});
|
||||
|
||||
it("waits for a first connection attempt to settle", () => {
|
||||
const connecting = computer("new", "connecting");
|
||||
expect(
|
||||
resolveOnboardingSetup(
|
||||
[local, connecting],
|
||||
new Set([local.environmentId, connecting.environmentId]),
|
||||
).ready,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("is not ready without a connected selection", () => {
|
||||
expect(resolveOnboardingSetup([local], new Set()).ready).toBe(false);
|
||||
expect(
|
||||
resolveOnboardingSetup([computer("off", "available")], new Set([EnvironmentId.make("off")]))
|
||||
.ready,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -47,3 +47,31 @@ export function resolveOnboardingTargetEnvironment<TEnvironment extends Onboardi
|
||||
|
||||
return mode === "local" ? null : (connectedRelayEnvironments[0] ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The computers the wizard sets up from the user's selection. Continue waits
|
||||
* only on a first connection attempt, which settles on its own. Selected
|
||||
* computers that are switched off, offline, failing, or unsupported are skipped
|
||||
* so they can never lock the user out of onboarding.
|
||||
*/
|
||||
export function resolveOnboardingSetup(
|
||||
environments: ReadonlyArray<Pick<OnboardingEnvironment, "environmentId" | "connection">>,
|
||||
selectedIds: ReadonlySet<EnvironmentId>,
|
||||
): {
|
||||
readonly ready: boolean;
|
||||
readonly environmentIds: ReadonlyArray<EnvironmentId>;
|
||||
readonly skippedIds: ReadonlyArray<EnvironmentId>;
|
||||
} {
|
||||
const selected = environments.filter((environment) => selectedIds.has(environment.environmentId));
|
||||
const idsInPhase = (keep: (phase: string) => boolean) =>
|
||||
selected
|
||||
.filter((environment) => keep(environment.connection.phase))
|
||||
.map((environment) => environment.environmentId);
|
||||
const environmentIds = idsInPhase((phase) => phase === "connected");
|
||||
const settling = selected.some((environment) => environment.connection.phase === "connecting");
|
||||
return {
|
||||
ready: environmentIds.length > 0 && !settling,
|
||||
environmentIds,
|
||||
skippedIds: idsInPhase((phase) => phase !== "connected" && phase !== "connecting"),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user