From bc98abda0c936a55c7cc6105f8262c160e9a376e Mon Sep 17 00:00:00 2001 From: Tonio Date: Mon, 30 Nov 2026 09:30:52 +0000 Subject: [PATCH] Keep onboarding subscription instructions plain (#23274) ## Thinking Path > - Paperclip connects agents to models. > - People choose a subscription during onboarding. > - The panel has a sign-in button and instructions. > - A second link appeared inside the instructions while waiting. > - The requested design keeps the instructions plain and the actions on buttons. ## Linked Issues or Issue Description **Subsystem affected** Subscription onboarding for Claude and OpenAI. Refs #23268 and #23270. **Current behavior** The waiting instructions contain a link to the provider. **Proposed behavior** Use plain text for both instructions. Open provider sign-in from the button. Keep the waiting button disabled and offer Retry when the attempt ends. ## What Changed Removed the waiting instruction link. Made the sign-in pill a native button. Use the published code deadline to show expiry even if the status poll misses the timeout. Updated the wizard tests. ## Verification All 25 login card and form tests passed locally. Both provider cases check the waiting state for links. ## Risks Closing the provider tab while waiting means the user must return to the provider tab, go Back, or wait to retry. ## Model Used OpenAI GPT-6 with Codex repository and test tools. ## Checklist - [ ] I have included a thinking path that traces from project context to this change - [ ] I have specified the model used (with version and capability details) - [ ] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [ ] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [ ] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [ ] I have run tests locally and they pass - [ ] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [ ] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge --- .../e2e/conference-room-typing-intro.spec.ts | 2 +- tests/e2e/onboarding-resume.spec.ts | 10 +++--- tests/e2e/onboarding.spec.ts | 6 ++-- ui/src/components/AdapterLoginChrome.test.tsx | 24 +++++++++++--- ui/src/components/AdapterLoginChrome.tsx | 24 +++++--------- .../AgentConfigForm.render.test.tsx | 32 ++++++++++++++++++- ui/src/components/AgentConfigForm.tsx | 20 ++++++++++-- 7 files changed, 86 insertions(+), 32 deletions(-) diff --git a/tests/e2e/conference-room-typing-intro.spec.ts b/tests/e2e/conference-room-typing-intro.spec.ts index e251a62946a..d43284232a5 100644 --- a/tests/e2e/conference-room-typing-intro.spec.ts +++ b/tests/e2e/conference-room-typing-intro.spec.ts @@ -144,7 +144,7 @@ test.describe("Chat launch after onboarding wizard", () => { await runOnboardingWizard(page, companyName, { source: /Claude/, complete: async () => { const code = page.getByRole("textbox", { name: "Authorization code", exact: true }); await expect(code).toBeVisible({ timeout: 20_000 }); - await expect(page.getByRole("link", { name: "Sign in", exact: true })).toBeVisible(); + await expect(page.getByRole("button", { name: "Sign in", exact: true })).toBeVisible(); await expect(page.getByRole("button", { name: "Next", exact: true })).toBeDisabled(); await expect(page.getByRole("button", { name: "Connect", exact: true })).toHaveCount(0); await code.evaluate(input => { diff --git a/tests/e2e/onboarding-resume.spec.ts b/tests/e2e/onboarding-resume.spec.ts index 9af9bf635e0..203ffd13bde 100644 --- a/tests/e2e/onboarding-resume.spec.ts +++ b/tests/e2e/onboarding-resume.spec.ts @@ -196,11 +196,11 @@ test.describe("Onboarding wizard", () => { await source.click(); const cardInstruction = page.getByText("Return to this window and enter the authorization code."); - const authorizationLink = page.getByRole("link", { name: "Sign in", exact: true }); + const signInButton = page.getByRole("button", { name: "Sign in", exact: true }); await expect(cardInstruction).toBeVisible({ timeout: 30_000 }); - await expect(authorizationLink).toBeVisible({ timeout: 15_000 }); - await expect(authorizationLink).toHaveAttribute("href", AUTHORIZATION_URL); + await expect(signInButton).toBeVisible({ timeout: 15_000 }); + await expect(signInButton).toBeEnabled(); expect(startCalls).toBe(1); const companiesRes = await page.request.get("/api/companies"); @@ -238,8 +238,8 @@ test.describe("Onboarding wizard", () => { await expect(page.getByTestId("onboarding-wizard").getByText("Ada", { exact: true })).toBeVisible(); await expect(page.getByRole("radio", { name: "Claude Subscription", exact: true })).toBeChecked(); await expect(cardInstruction).toBeVisible({ timeout: 15_000 }); - await expect(authorizationLink).toBeVisible({ timeout: 15_000 }); - await expect(authorizationLink).toHaveAttribute("href", AUTHORIZATION_URL); + await expect(signInButton).toBeVisible({ timeout: 15_000 }); + await expect(signInButton).toBeEnabled(); await expect.poll(readDraft).toMatchObject(resumedSelection); expect(startCalls, "reopening must resume the session without a second source choice").toBe(1); expect(hireCalls, "a pending login must not hire an agent").toBe(0); diff --git a/tests/e2e/onboarding.spec.ts b/tests/e2e/onboarding.spec.ts index cae3be267ff..99b56d0c873 100644 --- a/tests/e2e/onboarding.spec.ts +++ b/tests/e2e/onboarding.spec.ts @@ -399,9 +399,9 @@ test.describe("Onboarding wizard", () => { await source.click(); await expect(cardInstruction).toBeVisible({ timeout: 30_000 }); - const cardLink = page.getByRole("link", { name: "Sign in", exact: true }); - await expect(cardLink).toBeVisible({ timeout: 15_000 }); - await expect(cardLink).toHaveAttribute("href", /claude\.ai\/oauth\/authorize/); + const signInButton = page.getByRole("button", { name: "Sign in", exact: true }); + await expect(signInButton).toBeVisible({ timeout: 15_000 }); + await expect(signInButton).toBeEnabled(); await expect.poll(() => persistedAgentStatus).toBe(200); const persisted = await page.request.get(`/api/agents/${persistedAgentId}`); expect(persisted.ok()).toBe(true); diff --git a/ui/src/components/AdapterLoginChrome.test.tsx b/ui/src/components/AdapterLoginChrome.test.tsx index 5afef715778..03a2d577928 100644 --- a/ui/src/components/AdapterLoginChrome.test.tsx +++ b/ui/src/components/AdapterLoginChrome.test.tsx @@ -90,12 +90,11 @@ describe("the connect step's cards", () => { ); render(card()); - flushSync(() => container.querySelector("a")!.click()); + flushSync(() => container.querySelector("button")!.click()); expect(open).toHaveBeenCalledOnce(); expect(container.querySelector("button")?.disabled).toBe(true); expect(container.textContent).toContain(waitingLabel); - const reopen = container.querySelector(`a[aria-label="Reopen ${providerName} sign-in"]`); - expect(reopen?.getAttribute("href")).toBe("https://example.test/login"); + expect(container.querySelector("a")).toBeNull(); expect(container.querySelector("input")?.disabled).toBe(false); flushSync(() => root!.render(card("expired"))); expect(container.textContent).toContain("Your setup is saved."); @@ -104,7 +103,24 @@ describe("the connect step's cards", () => { button.click(); expect(retry).toHaveBeenCalledOnce(); flushSync(() => root!.render(card())); - expect(container.querySelector("a")?.textContent).toBe("Sign in"); + expect(container.querySelector("button")?.textContent).toBe("Sign in"); + }); + + it("opens the provider URL from the sign-in button without a caller handler", () => { + const open = vi.spyOn(window, "open").mockReturnValue(null); + try { + render( + }> + {null} + , + ); + flushSync(() => container.querySelector("button")!.click()); + expect(open).toHaveBeenCalledWith("https://example.test/login", "_blank", "noopener,noreferrer"); + expect(container.querySelector("a")).toBeNull(); + } finally { + open.mockRestore(); + } }); it("gives every card field the same input, from one declaration", () => { diff --git a/ui/src/components/AdapterLoginChrome.tsx b/ui/src/components/AdapterLoginChrome.tsx index bcb5d57b64f..90cd2f296d5 100644 --- a/ui/src/components/AdapterLoginChrome.tsx +++ b/ui/src/components/AdapterLoginChrome.tsx @@ -510,12 +510,7 @@ export function ProviderSubscriptionCard({ return ( - 1. {waiting ? ( - - {signInInstruction} - - ) : signInInstruction}{mode === "submitted_code" && " and copy the authorization code"}. + 1. {signInInstruction}{mode === "submitted_code" && " and copy the authorization code"}. 2. {mode === "submitted_code" ? "Return to this window and enter the authorization code." : "Enter the code below in the sign-in window."} }> @@ -525,16 +520,13 @@ export function ProviderSubscriptionCard({ {mode === "submitted_code" ? "Waiting for code…" : "Waiting…"} - ) : }
{children}
diff --git a/ui/src/components/AgentConfigForm.render.test.tsx b/ui/src/components/AgentConfigForm.render.test.tsx index 1b96a837463..3c026d08f0f 100644 --- a/ui/src/components/AgentConfigForm.render.test.tsx +++ b/ui/src/components/AgentConfigForm.render.test.tsx @@ -7,7 +7,8 @@ import type { Agent, Environment } from "@paperclipai/shared"; import { getEnvironmentCapabilities } from "@paperclipai/shared"; import { TooltipProvider } from "@/components/ui/tooltip"; import { ToastProvider } from "../context/ToastContext"; -import { AdapterTypeDropdown, AgentConfigForm } from "./AgentConfigForm"; +import { OnboardingSignInMark } from "./AdapterLoginChrome"; +import { AdapterLoginPanel, AdapterTypeDropdown, AgentConfigForm } from "./AgentConfigForm"; import { isBlockedFromReplay } from "@/lib/analytics/replay-recording.test-utils"; import { ApiError } from "../api/client"; import { CodexLocalConfigFields } from "../adapters/codex-local/config-fields"; @@ -236,6 +237,35 @@ describe("AgentConfigForm session replay masking", () => { vi.clearAllMocks(); }); + it("shows expiry for an ended OpenAI session after its code deadline", async () => { + const container = document.createElement("div"); + const root = createRoot(container); + roots.push(root); + const client = new QueryClient({ defaultOptions: { queries: { retry: false } } }); + mockAgentsApi.getAdapterAuthLoginStatus.mockResolvedValue({ + sessionId: "session-1", environmentId: "sandbox-1", status: "waiting_for_user", + expiresAt: new Date(Date.now() - 1).toISOString(), + prompt: { url: "https://auth.example.test/device", code: "WXYZ-1234" }, + }); + await act(() => root.render( + + }> + + + , + )); + await vi.waitFor(() => expect(container.textContent).toContain("WXYZ-1234")); + expect(container.textContent).not.toContain("This sign-in expired."); + client.setQueryData(["adapter-login-status", "company-1", "codex_local", "session-1"], { + sessionId: "session-1", environmentId: "sandbox-1", status: "failed", prompt: null, + expiresAt: new Date(Date.now() - 1).toISOString(), + failure: { reason: "login_command_failed", message: null }, + }); + await vi.waitFor(() => expect(container.textContent).toContain("This sign-in expired.")); + expect(container.textContent).toContain("Retry sign in"); + }); + it("blocks the displayed login code from session replay", async () => { const container = document.createElement("div"); document.body.appendChild(container); diff --git a/ui/src/components/AgentConfigForm.tsx b/ui/src/components/AgentConfigForm.tsx index 1ff59529eee..be3dc2dd819 100644 --- a/ui/src/components/AgentConfigForm.tsx +++ b/ui/src/components/AgentConfigForm.tsx @@ -3045,6 +3045,22 @@ function DisplayedCodeLoginPanel({ const session = statusQuery.data ?? startLogin.data ?? null; const status = session?.status ?? null; const prompt = latchedPrompt; + const [expiredCodeSession, setExpiredCodeSession] = useState(null); + const codeDeadline = statusQuery.data?.expiresAt ?? + (startLogin.data?.sessionId === sessionId ? startLogin.data?.expiresAt : null) ?? + (activeSessionQuery.data?.sessionId === sessionId ? activeSessionQuery.data?.expiresAt : null); + const sessionEnded = status === "failed" || status === "cancelled" || + (statusQuery.error instanceof ApiError && statusQuery.error.status === 404); + useEffect(() => { + if (chrome !== "onboarding" || !loginActive || !prompt || !sessionId || !codeDeadline || + retrying || !sessionEnded) return; + const remaining = Date.parse(codeDeadline) - Date.now(); + if (!Number.isFinite(remaining)) return; + const timer = setTimeout(() => setExpiredCodeSession(sessionId), Math.max(0, remaining)); + return () => clearTimeout(timer); + }, [chrome, loginActive, prompt, sessionId, codeDeadline, retrying, sessionEnded]); + const codeExpired = Boolean(sessionId && expiredCodeSession === sessionId && status !== "authenticated"); + const isTerminal = status ? ADAPTER_LOGIN_TERMINAL_STATUSES.has(status) : false; const isActive = loginActive && Boolean(sessionId) && !isTerminal && !retrying; // A saving bind also blocks a new Sign in: the bind is an agent-update save, @@ -3198,7 +3214,7 @@ function DisplayedCodeLoginPanel({ onPromptReadyRef.current?.(loginActive ? prompt?.url ?? null : null); }, [loginActive, prompt]); - const failed = Boolean(isTerminal && status !== "authenticated") || statusQuery.isError; + const failed = codeExpired || Boolean(isTerminal && status !== "authenticated") || statusQuery.isError; const retryingRef = useRef(false); const retryLogin = useMutation({ mutationFn: async () => { @@ -3256,7 +3272,7 @@ function DisplayedCodeLoginPanel({ if (chrome === "onboarding") { const failure = !retryLogin.isPending && (startError || failed) - ? status === "timed_out" ? "expired" : "failed" + ? codeExpired || status === "timed_out" ? "expired" : "failed" : undefined; return (