From 4a4e25fcb1ac9db75b4f58667d8bfd62e0458cf3 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sat, 24 Oct 2026 23:53:16 -0400 Subject: [PATCH 1/2] fix(web): the welcome wizard keeps the project selection when you go back a stage The import step kept its project selection in its own state, so clicking an earlier stage in the wizard's header unmounted it and Continue brought back the default selection. The wizard now owns the selection, like it already does for the chosen computers. Co-Authored-By: Claude Opus 5.5 --- .../WelcomeWizard.import.browser.test.tsx | 16 ++++++++++++++++ .../src/components/onboarding/WelcomeWizard.tsx | 14 ++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx b/apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx index 5f4bc3fbb69e7..5e802c5900b20 100644 --- a/apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx +++ b/apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx @@ -282,6 +282,22 @@ function setup() { return now; } +it("keeps the project selection after going back a stage", async () => { + using _now = setup(); + await using _screen = await mountImport(); + await click("Select none"); + expect(pageText()).toContain("0 of 2 selected"); + + const agentsStage = document.querySelector( + 'button[aria-label="Agents, step 2"]', + ); + expect(agentsStage?.disabled).toBe(false); + await act(async () => agentsStage?.click()); + await click("Continue"); + expect(pageText()).toContain("Import your projects"); + expect(pageText()).toContain("0 of 2 selected"); +}); + it("rechecks after project creation and can retry its history without recreating the project", async () => { using _now = setup(); const creation = deferred(); diff --git a/apps/web/src/components/onboarding/WelcomeWizard.tsx b/apps/web/src/components/onboarding/WelcomeWizard.tsx index 50d65192c0249..c5ce9db31834b 100644 --- a/apps/web/src/components/onboarding/WelcomeWizard.tsx +++ b/apps/web/src/components/onboarding/WelcomeWizard.tsx @@ -124,6 +124,7 @@ export function WelcomeWizard({ const [setupIds, setSetupIds] = useState( resumeEnvironmentId ? [resumeEnvironmentId] : [], ); + const [importSelection, setImportSelection] = useState | null>(null); const [isImporting, setIsImporting] = useState(false); const finishingPromiseRef = useRef | null>(null); const completionErrorToastIdRef = useRef | null>(null); @@ -279,6 +280,8 @@ export function WelcomeWizard({ ) : ( ()); @@ -1430,7 +1436,7 @@ function ImportStep({ variant="ghost" size="xs" disabled={isImporting || selected.length === candidates.length} - onClick={() => setSelectedPaths(new Set(candidates.map((item) => item.key)))} + onClick={() => onSelectedPathsChange(new Set(candidates.map((item) => item.key)))} > Select all @@ -1438,7 +1444,7 @@ function ImportStep({ variant="ghost" size="xs" disabled={isImporting || selected.length === 0} - onClick={() => setSelectedPaths(new Set())} + onClick={() => onSelectedPathsChange(new Set())} > Select none @@ -1491,7 +1497,7 @@ function ImportStep({ ); From b8b8e9b0e55030bb9ae5344cc0c018d4aaffeadc Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Tue, 27 Oct 2026 22:18:02 -0400 Subject: [PATCH 2/2] fix(web): computers added later get their default project selection The wizard keeps the project selection when you go back a stage. If you then added a computer, its recent projects stayed unticked, because the kept selection only knew the earlier computers. The selection now records which computers it covers, and any other computer gets the usual recent defaults. Co-Authored-By: Claude Opus 5.5 --- .../WelcomeWizard.import.browser.test.tsx | 34 ++++++++++++--- .../components/onboarding/WelcomeWizard.tsx | 42 +++++++++++++------ 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx b/apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx index 5e802c5900b20..c55691d9ca5cc 100644 --- a/apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx +++ b/apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx @@ -22,6 +22,7 @@ type CreateProjectInput = { }; const state = vi.hoisted(() => ({ selectedEnvironment: "primary", + addedEnvironments: [] as string[], sessions: new Map(), projects: null as unknown, providers: null as unknown, @@ -67,7 +68,9 @@ vi.mock(import("../../state/environments"), async (original) => { return { ...(await original()), usePrimaryEnvironment: (() => primary) as never, - useEnvironments: (() => ({ environments: [environment(state.selectedEnvironment)] })) as never, + useEnvironments: (() => ({ + environments: [state.selectedEnvironment, ...state.addedEnvironments].map(environment), + })) as never, }; }); vi.mock(import("../../state/server"), async (original) => { @@ -232,6 +235,12 @@ async function click(label: string) { await act(async () => target.click()); } +async function clickStage(label: string) { + const stage = document.querySelector(`button[aria-label="${label}"]`); + expect(stage?.disabled).toBe(false); + await act(async () => stage?.click()); +} + async function mountImport(remote = false) { state.selectedEnvironment = remote ? "remote" : "primary"; await using stack = new AsyncDisposableStack(); @@ -253,6 +262,7 @@ async function mountImport(remote = false) { // Returns the clock spy so each test can `using` it; the spy would otherwise outlive the test. function setup() { const now = vi.spyOn(Date, "now").mockReturnValue(NOW); + state.addedEnvironments = []; state.sessions.clear(); for (const id of [primaryId, remoteId]) { state.sessions.set( @@ -288,16 +298,28 @@ it("keeps the project selection after going back a stage", async () => { await click("Select none"); expect(pageText()).toContain("0 of 2 selected"); - const agentsStage = document.querySelector( - 'button[aria-label="Agents, step 2"]', - ); - expect(agentsStage?.disabled).toBe(false); - await act(async () => agentsStage?.click()); + await clickStage("Agents, step 2"); await click("Continue"); expect(pageText()).toContain("Import your projects"); expect(pageText()).toContain("0 of 2 selected"); }); +it("ticks the recent projects of a computer added after the selection changed", async () => { + using _now = setup(); + await using _screen = await mountImport(); + await click("Select none"); + + state.addedEnvironments = ["remote"]; + await clickStage("Connect, step 1"); + await click("Continue"); + await click("Continue"); + expect(pageText()).toContain("2 of 4 selected"); + + await click("Import 2 projects"); + const created = state.createProject.mock.calls as Array<[CreateProjectInput]>; + expect(created.map(([call]) => call.environmentId)).toEqual([remoteId, remoteId]); +}); + it("rechecks after project creation and can retry its history without recreating the project", async () => { using _now = setup(); const creation = deferred(); diff --git a/apps/web/src/components/onboarding/WelcomeWizard.tsx b/apps/web/src/components/onboarding/WelcomeWizard.tsx index c5ce9db31834b..682b9c6cb7b27 100644 --- a/apps/web/src/components/onboarding/WelcomeWizard.tsx +++ b/apps/web/src/components/onboarding/WelcomeWizard.tsx @@ -124,7 +124,7 @@ export function WelcomeWizard({ const [setupIds, setSetupIds] = useState( resumeEnvironmentId ? [resumeEnvironmentId] : [], ); - const [importSelection, setImportSelection] = useState | null>(null); + const [importSelection, setImportSelection] = useState(null); const [isImporting, setIsImporting] = useState(false); const finishingPromiseRef = useRef | null>(null); const completionErrorToastIdRef = useRef | null>(null); @@ -280,8 +280,8 @@ export function WelcomeWizard({ ) : ( ; + readonly keys: ReadonlySet; +} + function ImportStep({ scans, - selectedPaths, - onSelectedPathsChange, + importSelection, + onImportSelectionChange, isImporting, setIsImporting, onDone, }: { readonly scans: ReturnType; - readonly selectedPaths: ReadonlySet | null; - readonly onSelectedPathsChange: (next: ReadonlySet) => void; + readonly importSelection: ImportSelection | null; + readonly onImportSelectionChange: (next: ImportSelection) => void; readonly isImporting: boolean; readonly setIsImporting: (value: boolean) => void; readonly onDone: ( @@ -1225,8 +1231,20 @@ function ImportStep({ })), ), ); - const selectedKeys = selectedPaths ?? new Set(recent.map((candidate) => candidate.key)); - const selected = candidates.filter((candidate) => selectedKeys.has(candidate.key)); + const recentKeys = new Set(recent.map((candidate) => candidate.key)); + const selected = candidates.filter((candidate) => + importSelection?.environmentIds.has(candidate.environmentId) + ? importSelection.keys.has(candidate.key) + : recentKeys.has(candidate.key), + ); + const selectedKeys = new Set(selected.map((candidate) => candidate.key)); + const setSelectedKeys = (keys: ReadonlySet) => + onImportSelectionChange({ + environmentIds: new Set( + scans.flatMap((scan) => (scan.data === null ? [] : [scan.environmentId])), + ), + keys, + }); const canImport = selected.every((candidate) => writableEnvironments.has(candidate.environmentId), @@ -1436,7 +1454,7 @@ function ImportStep({ variant="ghost" size="xs" disabled={isImporting || selected.length === candidates.length} - onClick={() => onSelectedPathsChange(new Set(candidates.map((item) => item.key)))} + onClick={() => setSelectedKeys(new Set(candidates.map((item) => item.key)))} > Select all @@ -1444,7 +1462,7 @@ function ImportStep({ variant="ghost" size="xs" disabled={isImporting || selected.length === 0} - onClick={() => onSelectedPathsChange(new Set())} + onClick={() => setSelectedKeys(new Set())} > Select none @@ -1497,7 +1515,7 @@ function ImportStep({ );