From 84285c03a58985d68b2778e0ea19145eba11a738 Mon Sep 17 00:00:00 2001 From: Miles Pries Date: Sun, 22 Nov 2026 21:36:15 -0600 Subject: [PATCH 1/2] fix(web): onboarding Sign in is no longer stuck disabled after an install After Install finishes in the Welcome page's setup terminal, the agent's row switches to Sign in (since #36477), but the button stayed disabled until the terminal was closed, because any open terminal for that agent disabled it. Now it is disabled only while the terminal holds that same step or is still running a command, so Sign in cannot cut off an installer. Sign in replaces the finished install terminal with a fresh one that has the login command typed. Reusing the same terminal made its viewport read the close as an exit and drop it. Co-Authored-By: Claude Opus 5.5 --- .../WelcomePage.import.browser.test.tsx | 43 ++++++++++++++++++- .../src/components/onboarding/WelcomePage.tsx | 11 ++++- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/onboarding/WelcomePage.import.browser.test.tsx b/apps/web/src/components/onboarding/WelcomePage.import.browser.test.tsx index 5615fa3081842..ba96f394d45be 100644 --- a/apps/web/src/components/onboarding/WelcomePage.import.browser.test.tsx +++ b/apps/web/src/components/onboarding/WelcomePage.import.browser.test.tsx @@ -52,6 +52,7 @@ const state = vi.hoisted(() => ({ openTerminal: vi.fn(), writeTerminal: vi.fn(), closeTerminal: vi.fn(), + attachedTerminals: new Map void>(), })); vi.mock(import("@t3tools/client-runtime/state/session"), async (original) => { @@ -175,7 +176,14 @@ vi.mock(import("../../state/terminalSessions"), async (original) => { }); vi.mock(import("../ThreadTerminalDrawer"), async (original) => ({ ...(await original()), - TerminalViewport: () =>
, + TerminalViewport: ({ terminalId, onSessionExited }) => ( +
{ + state.attachedTerminals.set(terminalId, onSessionExited); + return () => void state.attachedTerminals.delete(terminalId); + }} + /> + ), })); vi.mock(import("../../state/use-atom-command"), async (original) => ({ ...(await original()), @@ -367,6 +375,12 @@ function setup() { for (const command of [state.openTerminal, state.writeTerminal, state.closeTerminal]) { command.mockReset().mockResolvedValue(AsyncResult.success(undefined)); } + // Closing a terminal whose viewport is still attached reports an exit, as in the real one. + state.attachedTerminals.clear(); + state.closeTerminal.mockImplementation(async ({ input }: { input: { terminalId: string } }) => { + state.attachedTerminals.get(input.terminalId)?.(); + return AsyncResult.success(undefined); + }); localStorage.removeItem(welcomeImportSelectionKey(primaryId)); return now; } @@ -665,7 +679,7 @@ it("offers Update for a signed-in agent whose version is broken, and keeps Start expect(button("Import 2 projects and start").disabled).toBe(true); }); -it("checks an agent again once its install command finishes in the setup terminal", async () => { +it("checks an agent again once its install command finishes, then replaces it with sign-in", async () => { using _now = setup(); appAtomRegistry.set( sessionAtom(primaryId), @@ -690,10 +704,35 @@ it("checks an agent again once its install command finishes in the setup termina await act(async () => appAtomRegistry.set(runningTerminalIds, [terminalId])); expect(state.refreshProviders).not.toHaveBeenCalledWith(recheck); + // Another check sees the new, signed-out binary before the installer exits. + await act(async () => + appAtomRegistry.set(state.providers as Atom.Writable>, [ + { ...readyClaude, status: "error", auth: { status: "unauthenticated" } }, + ]), + ); + expect(button("Sign in").disabled).toBe(true); // The shell stays open at its prompt after the install, so only the command exits. await act(async () => appAtomRegistry.set(runningTerminalIds, [])); expect(state.refreshProviders).toHaveBeenCalledWith(recheck); expect(state.closeTerminal).not.toHaveBeenCalled(); + + await click("Sign in"); + await vi.waitFor(() => + expect(state.writeTerminal).toHaveBeenLastCalledWith({ + environmentId: primaryId, + input: { + threadId: expect.any(String), + terminalId: expect.any(String), + data: "claude auth login", + }, + }), + ); + await vi.waitFor(() => + expect(pageText()).toContain("Review the command, then press Enter to run it."), + ); + expect(state.openTerminal.mock.calls[1]![0].input.terminalId).not.toBe(terminalId); + expect(state.closeTerminal).toHaveBeenCalledOnce(); + expect(state.closeTerminal.mock.calls[0]![0].input.terminalId).toBe(terminalId); }); it("keeps an import opt-out on the page when storage cannot save it", async () => { diff --git a/apps/web/src/components/onboarding/WelcomePage.tsx b/apps/web/src/components/onboarding/WelcomePage.tsx index 5c1b4218117fc..4fecca6b6b72b 100644 --- a/apps/web/src/components/onboarding/WelcomePage.tsx +++ b/apps/web/src/components/onboarding/WelcomePage.tsx @@ -416,6 +416,7 @@ interface AgentTerminalSession { readonly environmentId: EnvironmentId; readonly driver: OnboardingAgentDriver; readonly providerInstanceId: ServerProvider["instanceId"]; + readonly step: "install" | "signIn"; readonly cwd: string; readonly command: string; readonly keybindings: ServerConfig["keybindings"]; @@ -467,6 +468,9 @@ function AgentsSection({ const [addingProvider, setAddingProvider] = useState(false); const [codexSetupId, setCodexSetupId] = useState(null); const [cliTerminalFor, setCliTerminalFor] = useState(null); + // Another check can see a new binary before its installer exits; Sign in must not cut it off. + const setupCommandRunning = + useThreadRunningTerminalIds({ environmentId, threadId: AGENT_ONBOARDING_THREAD_ID }).length > 0; // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- asks the environment to refresh its provider list when the environment changes useEffect(() => { @@ -516,6 +520,7 @@ function AgentsSection({ environmentId, driver: provider.driver, providerInstanceId: provider.instanceId, + step: provider.installed ? "signIn" : "install", cwd: serverConfig.cwd, command: provider.installed ? resolveOnboardingProviderLoginCommand( @@ -623,7 +628,8 @@ function AgentsSection({ name={name} signIn={state === "signIn"} disabled={ - terminalSession?.providerInstanceId === provider.instanceId || + (terminalSession?.providerInstanceId === provider.instanceId && + (terminalSession.step === state || setupCommandRunning)) || serverConfig === null || !canOperateTerminal } @@ -739,7 +745,8 @@ function AgentsSection({ {isPrimary ? : null} {terminalSession !== null ? ( void refreshProviders({ From 2ad707aff3420be5cb12c1a384578dcabd9833e2 Mon Sep 17 00:00:00 2001 From: Miles Pries Date: Mon, 23 Nov 2026 00:22:33 -0600 Subject: [PATCH 2/2] test(web): onboarding Sign in check goes through vi.waitFor The mid-install check read the button's disabled state directly. docs/internals/testing.md asks browser tests to assert through vi.waitFor or expect.element. Co-Authored-By: Claude Fable 5.2 --- .../components/onboarding/WelcomePage.import.browser.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/components/onboarding/WelcomePage.import.browser.test.tsx b/apps/web/src/components/onboarding/WelcomePage.import.browser.test.tsx index ba96f394d45be..b1429b4801692 100644 --- a/apps/web/src/components/onboarding/WelcomePage.import.browser.test.tsx +++ b/apps/web/src/components/onboarding/WelcomePage.import.browser.test.tsx @@ -710,7 +710,7 @@ it("checks an agent again once its install command finishes, then replaces it wi { ...readyClaude, status: "error", auth: { status: "unauthenticated" } }, ]), ); - expect(button("Sign in").disabled).toBe(true); + await vi.waitFor(() => expect(button("Sign in").disabled).toBe(true)); // The shell stays open at its prompt after the install, so only the command exits. await act(async () => appAtomRegistry.set(runningTerminalIds, [])); expect(state.refreshProviders).toHaveBeenCalledWith(recheck);