The best way to control Claude Code, Codex and more from any computer or phone
perf(web): welcome wizard keeps its auto-selected computers in lazy state (#20469)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 18:46 UTC
8f309bce656b315aacc93ba54ed6f3933124da0e
2 files changed
+79
-81
apps/web/reactCompiledFiles.ts
+1
@@ -44,4 +44,5 @@ export const REACT_COMPILED_FILES = [
44
"apps/web/src/components/desktop/SnapShotCoordinator.tsx",
45
"apps/web/src/components/BranchToolbar.tsx",
46
"apps/web/src/components/DiffPanel.tsx",
47
+ "apps/web/src/components/onboarding/WelcomeWizard.tsx",
48
] as const;
apps/web/src/components/onboarding/WelcomeWizard.tsx
+78
-81
@@ -32,7 +32,7 @@ import {
32
MonitorIcon,
33
TerminalIcon,
34
} from "lucide-react";
35
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
35
+import { useEffect, useRef, useState } from "react";
36
37
import { TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "../../appearanceFonts";
38
import { useLocalStorage } from "../../hooks/useLocalStorage";
@@ -120,7 +120,9 @@ export function WelcomeWizard({
120
const [step, setStep] = useState<WizardStep>(resumeEnvironmentId ? "agents" : "connection");
121
const { environments } = useEnvironments();
122
const [selection, setSelection] = useState<ReadonlySet<EnvironmentId> | null>(null);
123
- const autoSelectedComputers = useRef(new Set<EnvironmentId>());
123
+ // One registry for the wizard's lifetime, shared with the connect list, so a computer is
124
+ // auto-selected once even after the user unchecks it.
125
+ const [autoSelectedComputers] = useState(() => new Set<EnvironmentId>());
126
const [setupIds, setSetupIds] = useState<readonly EnvironmentId[]>(
127
resumeEnvironmentId ? [resumeEnvironmentId] : [],
128
);
@@ -130,14 +132,15 @@ export function WelcomeWizard({
132
const primaryEnvironment = usePrimaryEnvironment();
133
useEffect(() => {
134
const newComputers = environments.filter(
133
- (environment) => !autoSelectedComputers.current.has(environment.environmentId),
135
+ (environment) => !autoSelectedComputers.has(environment.environmentId),
136
);
137
if (newComputers.length === 0) return;
138
for (const environment of newComputers) {
137
- autoSelectedComputers.current.add(environment.environmentId);
139
+ autoSelectedComputers.add(environment.environmentId);
140
}
141
const enabledComputers = newComputers.filter((environment) => environment.entry.enabled);
142
if (enabledComputers.length === 0) return;
143
+ // oxlint-disable-next-line react/set-state-in-effect -- The registry marks each computer once, and only after commit; render must not mutate it.
144
setSelection(
145
(current) =>
146
new Set([
@@ -145,7 +148,7 @@ export function WelcomeWizard({
148
...enabledComputers.map((environment) => environment.environmentId),
149
]),
150
);
148
- }, [environments]);
151
+ }, [autoSelectedComputers, environments]);
152
const selectedIds =
153
selection ?? new Set(primaryEnvironment ? [primaryEnvironment.environmentId] : []);
154
const scans = useProjectScans(step === "import" ? setupIds : NO_ENVIRONMENTS);
@@ -159,59 +162,60 @@ export function WelcomeWizard({
162
setStep("agents");
163
};
164
const stageIndex = step === "agents" ? 1 : step === "import" ? 2 : 0;
162
- const finish = useCallback(
163
- (projectRef?: ScopedProjectRef, importWarning?: string, importedThreadCount = 0) => {
164
- if (finishingPromiseRef.current !== null) return finishingPromiseRef.current;
165
- if (completionErrorToastIdRef.current !== null) {
166
- toastManager.close(completionErrorToastIdRef.current);
167
- completionErrorToastIdRef.current = null;
168
- }
165
+ const finish = (
166
+ projectRef?: ScopedProjectRef,
167
+ importWarning?: string,
168
+ importedThreadCount = 0,
169
+ ) => {
170
+ if (finishingPromiseRef.current !== null) return finishingPromiseRef.current;
171
+ if (completionErrorToastIdRef.current !== null) {
172
+ toastManager.close(completionErrorToastIdRef.current);
173
+ completionErrorToastIdRef.current = null;
174
+ }
175
170
- const completion = completeOnboarding()
171
- .then(async () => {
172
- if (completionErrorToastIdRef.current !== null) {
173
- toastManager.close(completionErrorToastIdRef.current);
174
- completionErrorToastIdRef.current = null;
175
- }
176
- await onDone(projectRef);
177
- if (importWarning) {
178
- toastManager.add({
179
- type: "warning",
180
- title: "Some history was not imported",
181
- description: importWarning,
182
- timeout: 0,
183
- });
184
- } else if (importedThreadCount > 0) {
185
- toastManager.add({
186
- type: "success",
187
- title: `Imported ${importedThreadCount} ${importedThreadCount === 1 ? "thread" : "threads"}`,
188
- });
189
- }
190
- return true;
191
- })
192
- .catch(() => {
193
- const errorToast = {
194
- type: "error",
195
- title: "Could not finish setup",
196
- description: "Your settings could not be saved. Try again.",
197
- } as const;
198
- if (completionErrorToastIdRef.current === null) {
199
- completionErrorToastIdRef.current = toastManager.add(errorToast);
200
- } else {
201
- toastManager.update(completionErrorToastIdRef.current, errorToast);
202
- }
203
- return false;
204
- })
205
- .finally(() => {
206
- if (finishingPromiseRef.current === completion) {
207
- finishingPromiseRef.current = null;
208
- }
209
- });
210
- finishingPromiseRef.current = completion;
211
- return completion;
212
- },
213
- [completeOnboarding, onDone],
214
- );
176
+ const completion = completeOnboarding()
177
+ .then(async () => {
178
+ if (completionErrorToastIdRef.current !== null) {
179
+ toastManager.close(completionErrorToastIdRef.current);
180
+ completionErrorToastIdRef.current = null;
181
+ }
182
+ await onDone(projectRef);
183
+ if (importWarning) {
184
+ toastManager.add({
185
+ type: "warning",
186
+ title: "Some history was not imported",
187
+ description: importWarning,
188
+ timeout: 0,
189
+ });
190
+ } else if (importedThreadCount > 0) {
191
+ toastManager.add({
192
+ type: "success",
193
+ title: `Imported ${importedThreadCount} ${importedThreadCount === 1 ? "thread" : "threads"}`,
194
+ });
195
+ }
196
+ return true;
197
+ })
198
+ .catch(() => {
199
+ const errorToast = {
200
+ type: "error",
201
+ title: "Could not finish setup",
202
+ description: "Your settings could not be saved. Try again.",
203
+ } as const;
204
+ if (completionErrorToastIdRef.current === null) {
205
+ completionErrorToastIdRef.current = toastManager.add(errorToast);
206
+ } else {
207
+ toastManager.update(completionErrorToastIdRef.current, errorToast);
208
+ }
209
+ return false;
210
+ })
211
+ .finally(() => {
212
+ if (finishingPromiseRef.current === completion) {
213
+ finishingPromiseRef.current = null;
214
+ }
215
+ });
216
+ finishingPromiseRef.current = completion;
217
+ return completion;
218
+ };
219
220
return (
221
<Dialog open disablePointerDismissal onOpenChange={(_, event) => event.cancel()}>
@@ -248,7 +252,7 @@ export function WelcomeWizard({
252
<ConnectionStep
253
expandPairingInitially={!localAvailable && !hasCloudPublicConfig()}
254
selectedIds={selectedIds}
251
- autoSelectedComputers={autoSelectedComputers.current}
255
+ autoSelectedComputers={autoSelectedComputers}
256
onSelectionChange={setSelection}
257
onToggleEnvironment={(environmentId, checked) =>
258
setSelection((current) => {
@@ -461,7 +465,7 @@ function ConnectAccountOption({
465
const { openAuthPrompt } = useT3ConnectAuthPrompt();
466
const [expanded, setExpanded] = useState(true);
467
const [discoveryReady, setDiscoveryReady] = useState(false);
464
- const onDiscoveryReady = useCallback(() => setDiscoveryReady(true), []);
468
+ const onDiscoveryReady = () => setDiscoveryReady(true);
469
470
return (
471
<div className="rounded-lg border border-border bg-background">
@@ -709,7 +713,7 @@ function ConnectedAgentsStep({
713
void refreshProviders({ environmentId, input: {} });
714
}, [environmentId, refreshProviders]);
715
712
- const byDriver = useMemo(() => selectOnboardingProvidersByDriver(providers), [providers]);
716
+ const byDriver = selectOnboardingProvidersByDriver(providers);
717
718
const primaryAgents = PRIMARY_AGENT_DRIVERS.flatMap((driver) => {
719
const instances =
@@ -1013,10 +1017,7 @@ function AgentInstallTerminal({
1017
const setupGenerationRef = useRef(0);
1018
const activeSetupGenerationRef = useRef<number | null>(null);
1019
const [terminalId] = useState(() => `onboarding-${driver}-${randomUUID()}`);
1016
- const threadRef = useMemo(
1017
- () => scopeThreadRef(environmentId, AGENT_ONBOARDING_THREAD_ID),
1018
- [environmentId],
1019
- );
1020
+ const threadRef = scopeThreadRef(environmentId, AGENT_ONBOARDING_THREAD_ID);
1021
const [setupAttempt, setSetupAttempt] = useState(0);
1022
const [setupState, setSetupState] = useState<
1023
"preparing" | "ready" | "openFailed" | "writeFailed"
@@ -1030,6 +1031,7 @@ function AgentInstallTerminal({
1031
const generation = setupGenerationRef.current + 1;
1032
setupGenerationRef.current = generation;
1033
activeSetupGenerationRef.current = generation;
1034
+ // oxlint-disable-next-line react/set-state-in-effect -- A retry or a new command reopens the terminal, which shows as preparing until the open settles.
1035
setSetupState("preparing");
1036
1037
setupQueueRef.current = setupQueueRef.current.then(async () => {
@@ -1087,6 +1089,7 @@ function AgentInstallTerminal({
1089
environmentId,
1090
openTerminal,
1091
providerInstanceId,
1092
+ // oxlint-disable-next-line react/exhaustive-effect-dependencies -- Retry bumps setupAttempt to open the terminal again.
1093
setupAttempt,
1094
terminalId,
1095
writeTerminal,
@@ -1208,6 +1211,7 @@ function ImportStep({
1211
project.environmentId === landingProject.environmentId,
1212
)
1213
) {
1214
+ // oxlint-disable-next-line react/set-state-in-effect -- The landing project is known only once the projects subscription delivers it.
1215
setLandingProject(null);
1216
void onDone(landingProject, importWarningRef.current, importedThreadCountRef.current).then(
1217
(completed) => {
@@ -1217,23 +1221,16 @@ function ImportStep({
1221
}
1222
}, [landingProject, onDone, projects, setIsImporting]);
1223
1220
- const { available: candidates, recent } = useMemo(
1221
- () =>
1222
- partitionOnboardingProjects(
1223
- scans.flatMap((scan) =>
1224
- (scan.data?.candidates ?? []).map((candidate) => ({
1225
- ...candidate,
1226
- environmentId: scan.environmentId,
1227
- key: onboardingProjectKey(scan.environmentId, candidate.path),
1228
- })),
1229
- ),
1230
- ),
1231
- [scans],
1232
- );
1233
- const selectedKeys = useMemo(
1234
- () => selectedPaths ?? new Set(recent.map((candidate) => candidate.key)),
1235
- [selectedPaths, recent],
1224
+ const { available: candidates, recent } = partitionOnboardingProjects(
1225
+ scans.flatMap((scan) =>
1226
+ (scan.data?.candidates ?? []).map((candidate) => ({
1227
+ ...candidate,
1228
+ environmentId: scan.environmentId,
1229
+ key: onboardingProjectKey(scan.environmentId, candidate.path),
1230
+ })),
1231
+ ),
1232
);
1233
+ const selectedKeys = selectedPaths ?? new Set(recent.map((candidate) => candidate.key));
1234
const selected = candidates.filter((candidate) => selectedKeys.has(candidate.key));
1235
1236
const canImport = selected.every((candidate) =>
@@ -1531,7 +1528,7 @@ function ImportCandidateList({
1528
readonly selectedKeys: ReadonlySet<string>;
1529
readonly onSelectionChange: (next: ReadonlySet<string>) => void;
1530
}) {
1534
- const { repositories, other } = useMemo(() => groupOnboardingProjects(candidates), [candidates]);
1531
+ const { repositories, other } = groupOnboardingProjects(candidates);
1532
const setKeys = (keys: ReadonlyArray<string>, checked: boolean) => {
1533
const next = new Set(selectedKeys);
1534
for (const key of keys) {