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
This commit is contained in:
Tonio authored and GitHub committed 2026-11-30 09:30:52 +00:00
1 parent 429a004da5
commit bc98abda0c
7 files changed
+86 -32

No files matched your search

@@ -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 => {
+5 -5
View File
@@ -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);
+3 -3
View File
@@ -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);
+20 -4
View File
@@ -90,12 +90,11 @@ describe("the connect step's cards", () => {
</OnboardingSignInMark.Provider>
);
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(
<OnboardingSignInMark.Provider value={<span />}>
<ProviderSubscriptionCard providerName="OpenAI" mode="displayed_code"
authorizationUrl="https://example.test/login">{null}</ProviderSubscriptionCard>
</OnboardingSignInMark.Provider>,
);
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", () => {
+8 -16
View File
@@ -510,12 +510,7 @@ export function ProviderSubscriptionCard({
return (
<OnboardingLoginCard revealTogether loading={loading} instruction={
<span className="grid gap-1">
<span>1. {waiting ? (
<a href={authorizationUrl} target="_blank" rel="noopener noreferrer"
aria-label={`Reopen ${providerName} sign-in`} className="underline underline-offset-2 hover:text-foreground">
{signInInstruction}
</a>
) : signInInstruction}{mode === "submitted_code" && " and copy the authorization code"}.</span>
<span>1. {signInInstruction}{mode === "submitted_code" && " and copy the authorization code"}.</span>
<span>2. {mode === "submitted_code" ? "Return to this window and enter the authorization code." : "Enter the code below in the sign-in window."}</span>
</span>
}>
@@ -525,16 +520,13 @@ export function ProviderSubscriptionCard({
<Loader2 className="size-4 motion-safe:animate-spin" />
{mode === "submitted_code" ? "Waiting for code…" : "Waiting…"}
</Button>
) : <Button asChild className="gap-1 rounded-full py-0 pl-3 pr-6">
<a href={authorizationUrl} target="_blank" rel="noopener noreferrer" onClick={event => {
setOpenedUrl(authorizationUrl ?? null);
if (onOpenAuthorization) {
event.preventDefault();
onOpenAuthorization();
}
}}>
<span className="size-(--sz-30px) shrink-0">{mark}</span>Sign in
</a>
) : <Button type="button" disabled={!authorizationUrl} className="gap-1 rounded-full py-0 pl-3 pr-6" onClick={() => {
if (!authorizationUrl) return;
setOpenedUrl(authorizationUrl);
if (onOpenAuthorization) onOpenAuthorization();
else window.open(authorizationUrl, "_blank", "noopener,noreferrer");
}}>
<span className="size-(--sz-30px) shrink-0">{mark}</span>Sign in
</Button>}
<div className="min-h-(--sz-44px) min-w-0 flex-1 basis-44">{children}</div>
</div>
@@ -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(
<QueryClientProvider client={client}>
<OnboardingSignInMark.Provider value={<span />}>
<AdapterLoginPanel companyId="company-1" environmentId="sandbox-1"
adapterType="codex_local" autoStart chrome="onboarding" />
</OnboardingSignInMark.Provider>
</QueryClientProvider>,
));
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);
+18 -2
View File
@@ -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<string | null>(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 (
<ProviderSubscriptionCard