The best way to control Claude Code, Codex and more from any computer or phone
fix(web): the welcome wizard keeps the project selection when you go back a stage (#24719)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Jackson Miller committed
Nov 1, 2026 at 15:56 UTC
aa056f7d0fcba782b3b1fbb3fed070a3e8186927
2 files changed
+69
-7
apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx
+39
-1
@@ -22,6 +22,7 @@ type CreateProjectInput = {
22
};
23
const state = vi.hoisted(() => ({
24
selectedEnvironment: "primary",
25
+ addedEnvironments: [] as string[],
26
sessions: new Map<string, unknown>(),
27
projects: null as unknown,
28
providers: null as unknown,
@@ -67,7 +68,9 @@ vi.mock(import("../../state/environments"), async (original) => {
68
return {
69
...(await original()),
70
usePrimaryEnvironment: (() => primary) as never,
70
- useEnvironments: (() => ({ environments: [environment(state.selectedEnvironment)] })) as never,
71
+ useEnvironments: (() => ({
72
+ environments: [state.selectedEnvironment, ...state.addedEnvironments].map(environment),
73
+ })) as never,
74
};
75
});
76
vi.mock(import("../../state/server"), async (original) => {
@@ -232,6 +235,12 @@ async function click(label: string) {
235
await act(async () => target.click());
236
}
237
238
+async function clickStage(label: string) {
239
+ const stage = document.querySelector<HTMLButtonElement>(`button[aria-label="${label}"]`);
240
+ expect(stage?.disabled).toBe(false);
241
+ await act(async () => stage?.click());
242
+}
243
+
244
async function mountImport(remote = false) {
245
state.selectedEnvironment = remote ? "remote" : "primary";
246
await using stack = new AsyncDisposableStack();
@@ -253,6 +262,7 @@ async function mountImport(remote = false) {
262
// Returns the clock spy so each test can `using` it; the spy would otherwise outlive the test.
263
function setup() {
264
const now = vi.spyOn(Date, "now").mockReturnValue(NOW);
265
+ state.addedEnvironments = [];
266
state.sessions.clear();
267
for (const id of [primaryId, remoteId]) {
268
state.sessions.set(
@@ -282,6 +292,34 @@ function setup() {
292
return now;
293
}
294
295
+it("keeps the project selection after going back a stage", async () => {
296
+ using _now = setup();
297
+ await using _screen = await mountImport();
298
+ await click("Select none");
299
+ expect(pageText()).toContain("0 of 2 selected");
300
+
301
+ await clickStage("Agents, step 2");
302
+ await click("Continue");
303
+ expect(pageText()).toContain("Import your projects");
304
+ expect(pageText()).toContain("0 of 2 selected");
305
+});
306
+
307
+it("ticks the recent projects of a computer added after the selection changed", async () => {
308
+ using _now = setup();
309
+ await using _screen = await mountImport();
310
+ await click("Select none");
311
+
312
+ state.addedEnvironments = ["remote"];
313
+ await clickStage("Connect, step 1");
314
+ await click("Continue");
315
+ await click("Continue");
316
+ expect(pageText()).toContain("2 of 4 selected");
317
+
318
+ await click("Import 2 projects");
319
+ const created = state.createProject.mock.calls as Array<[CreateProjectInput]>;
320
+ expect(created.map(([call]) => call.environmentId)).toEqual([remoteId, remoteId]);
321
+});
322
+
323
it("rechecks after project creation and can retry its history without recreating the project", async () => {
324
using _now = setup();
325
const creation = deferred<void>();
apps/web/src/components/onboarding/WelcomeWizard.tsx
+30
-6
@@ -131,6 +131,7 @@ export function WelcomeWizard({
131
const [setupIds, setSetupIds] = useState<readonly EnvironmentId[]>(
132
resumeEnvironmentId ? [resumeEnvironmentId] : [],
133
);
134
+ const [importSelection, setImportSelection] = useState<ImportSelection | null>(null);
135
const [isImporting, setIsImporting] = useState(false);
136
const finishingPromiseRef = useRef<Promise<boolean> | null>(null);
137
const completionErrorToastIdRef = useRef<ReturnType<typeof toastManager.add> | null>(null);
@@ -286,6 +287,8 @@ export function WelcomeWizard({
287
) : (
288
<ImportStep
289
scans={scans}
290
+ importSelection={importSelection}
291
+ onImportSelectionChange={setImportSelection}
292
isImporting={isImporting}
293
setIsImporting={setIsImporting}
294
onDone={finish}
@@ -1190,13 +1193,23 @@ function AgentInstallTerminal({
1193
1194
const IMPORT_PERMISSION_MESSAGE = "This connection cannot import projects or thread history.";
1195
1196
+interface ImportSelection {
1197
+ // Computers whose projects were listed when the selection changed; later ones get the defaults.
1198
+ readonly environmentIds: ReadonlySet<EnvironmentId>;
1199
+ readonly keys: ReadonlySet<string>;
1200
+}
1201
+
1202
function ImportStep({
1203
scans,
1204
+ importSelection,
1205
+ onImportSelectionChange,
1206
isImporting,
1207
setIsImporting,
1208
onDone,
1209
}: {
1210
readonly scans: ReturnType<typeof useProjectScans>;
1211
+ readonly importSelection: ImportSelection | null;
1212
+ readonly onImportSelectionChange: (next: ImportSelection) => void;
1213
readonly isImporting: boolean;
1214
readonly setIsImporting: (value: boolean) => void;
1215
readonly onDone: (
@@ -1209,7 +1222,6 @@ function ImportStep({
1222
const writableEnvironments = useEnvironmentsWithScope(scans, AuthOrchestrationOperateScope);
1223
const createProject = useAtomCommand(projectEnvironment.create, { reportFailure: false });
1224
const importThreads = useAtomCommand(agentSessionImport, { reportFailure: false });
1212
- const [selectedPaths, setSelectedPaths] = useState<ReadonlySet<string> | null>(null);
1225
const importWarningRef = useRef("");
1226
const importedThreadCountRef = useRef(0);
1227
const importedProjectsRef = useRef(new Map<string, ScopedProjectRef>());
@@ -1237,8 +1249,20 @@ function ImportStep({
1249
})),
1250
),
1251
);
1240
- const selectedKeys = selectedPaths ?? new Set(recent.map((candidate) => candidate.key));
1241
- const selected = candidates.filter((candidate) => selectedKeys.has(candidate.key));
1252
+ const recentKeys = new Set(recent.map((candidate) => candidate.key));
1253
+ const selected = candidates.filter((candidate) =>
1254
+ importSelection?.environmentIds.has(candidate.environmentId)
1255
+ ? importSelection.keys.has(candidate.key)
1256
+ : recentKeys.has(candidate.key),
1257
+ );
1258
+ const selectedKeys = new Set(selected.map((candidate) => candidate.key));
1259
+ const setSelectedKeys = (keys: ReadonlySet<string>) =>
1260
+ onImportSelectionChange({
1261
+ environmentIds: new Set(
1262
+ scans.flatMap((scan) => (scan.data === null ? [] : [scan.environmentId])),
1263
+ ),
1264
+ keys,
1265
+ });
1266
1267
const canImport = selected.every((candidate) =>
1268
writableEnvironments.has(candidate.environmentId),
@@ -1448,7 +1472,7 @@ function ImportStep({
1472
variant="ghost"
1473
size="xs"
1474
disabled={isImporting || selected.length === candidates.length}
1451
- onClick={() => setSelectedPaths(new Set(candidates.map((item) => item.key)))}
1475
+ onClick={() => setSelectedKeys(new Set(candidates.map((item) => item.key)))}
1476
>
1477
Select all
1478
</Button>
@@ -1456,7 +1480,7 @@ function ImportStep({
1480
variant="ghost"
1481
size="xs"
1482
disabled={isImporting || selected.length === 0}
1459
- onClick={() => setSelectedPaths(new Set())}
1483
+ onClick={() => setSelectedKeys(new Set())}
1484
>
1485
Select none
1486
</Button>
@@ -1509,7 +1533,7 @@ function ImportStep({
1533
<ImportCandidateList
1534
candidates={scanCandidates}
1535
selectedKeys={selectedKeys}
1512
- onSelectionChange={setSelectedPaths}
1536
+ onSelectionChange={setSelectedKeys}
1537
/>
1538
</fieldset>
1539
);