Show waiting and retry in the onboarding sign-in card (#23268)

## Thinking Path

> - Paperclip helps people manage AI agents.
> - Onboarding connects an agent to a model.
> - Users open the provider sign-in from the connection card.
> - The card should show when the provider is waiting and how to recover
after a timeout.
> - This change keeps both actions in the same place.

## Linked Issues or Issue Description

**Subsystem affected**

Model connection during first-agent onboarding. Related work includes
#23255 and #6636.

**Current behavior**

The sign-in link remains active after opening the provider. Retry
appears in the footer.

**Proposed behavior**

Show a waiting label beside the code. Offer retry inside the card when
sign-in expires. Keep Next disabled during these states.

## What Changed

- Show the provider-specific waiting label after opening sign-in.
- Show a retry action and saved-setup message in the card.
- Cover both providers and the reset after retry.

## Verification

- Ran the UI typecheck.
- Ran the adapter login card and local login tests. All 33 passed.

## Risks

Local and hosted sign-in expose retry through different handlers. This
change keeps the existing session handlers.

## Model Used

OpenAI GPT-6 with Codex repository and test tools.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] 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
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
TonioandPaperclip authored and GitHub committed 2026-11-30 07:30:05 +00:00
1 parent e55b475f30
commit 111973c5e3
3 files changed
+84 -7

No files matched your search

@@ -9,6 +9,8 @@ import {
LocalProviderLoginInstructions,
OnboardingLoginCard,
OnboardingCardField,
OnboardingSignInMark,
ProviderSubscriptionCard,
OnboardingLoginCodeRow,
onboardingCardInputClass,
resolveLocalLoginPrimaryAction,
@@ -73,6 +75,38 @@ describe("the connect step's cards", () => {
flushSync(() => root!.render(node));
}
it.each([
["submitted_code", "Claude", "Waiting for code…"],
["displayed_code", "OpenAI", "Waiting for sign-in…"],
] as const)("keeps waiting and retry inside the %s card", (mode, providerName, waitingLabel) => {
const open = vi.fn();
const retry = vi.fn();
const card = (failure?: "expired") => (
<OnboardingSignInMark.Provider value={<span />}>
<ProviderSubscriptionCard providerName={providerName} mode={mode} failure={failure}
authorizationUrl="https://example.test/login" onOpenAuthorization={open} onRetry={retry}>
{failure ? null : <input aria-label="Code" />}
</ProviderSubscriptionCard>
</OnboardingSignInMark.Provider>
);
render(card());
flushSync(() => container.querySelector("a")!.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("input")?.disabled).toBe(false);
flushSync(() => root!.render(card("expired")));
expect(container.textContent).toContain("Your setup is saved.");
const button = container.querySelector("button")!;
expect(button.textContent).toBe("Retry sign in");
button.click();
expect(retry).toHaveBeenCalledOnce();
flushSync(() => root!.render(card()));
expect(container.querySelector("a")?.textContent).toBe("Sign in");
});
it("gives every card field the same input, from one declaration", () => {
// The step asks for three different things in this row — a browser code, a
// key — and they sit one toggle apart in the same canvas, so a divergence
+45 -4
View File
@@ -458,6 +458,7 @@ export function OnboardingCardField({
);
}
export const OnboardingSignInRetry = createContext<(() => void) | null>(null);
export const OnboardingSignInMark = createContext<ReactNode>(null);
/** Shared authentication presentation. Hosts retain their existing session lifecycle. */
@@ -483,17 +484,50 @@ export function ProviderSubscriptionCard({
children: ReactNode;
}) {
const mark = useContext(OnboardingSignInMark);
if (mark && !failure && (mode === "submitted_code" || mode === "displayed_code")) {
const retry = useContext(OnboardingSignInRetry) ?? onRetry;
const [openedUrl, setOpenedUrl] = useState<string | null>(null);
useEffect(() => {
if (loading || failure) setOpenedUrl(null);
}, [loading, failure]);
if (mark && failure) {
return (
<OnboardingLoginCard revealTogether instruction={<span role="alert" className="grid gap-1">
<span>{failureMessage ?? (failure === "expired" ? "This sign-in expired. Retry signing in to get a new code." : "Sign-in didn’t finish. Try signing in again.")}</span>
<span>Your setup is saved.</span>
</span>}>
<div className="flex min-h-(--sz-44px) items-center gap-3">
{retry && <Button type="button" className="gap-1 rounded-full py-0 pl-3 pr-6" onClick={retry}>
<span className="size-(--sz-30px) shrink-0">{mark}</span>Retry sign in
</Button>}
{children}
</div>
</OnboardingLoginCard>
);
}
if (mark && (mode === "submitted_code" || mode === "displayed_code")) {
const waiting = Boolean(openedUrl && openedUrl === authorizationUrl);
const signInInstruction = `Sign into your ${providerName} account`;
return (
<OnboardingLoginCard revealTogether loading={loading} instruction={
<span className="grid gap-1">
<span>1. Sign into your {providerName} account{mode === "submitted_code" && " and copy the authorization code"}.</span>
<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>2. {mode === "submitted_code" ? "Return to this window and enter the authorization code." : "Enter the code below in the sign-in window."}</span>
</span>
}>
<div className="flex flex-wrap items-center gap-3">
<Button asChild className="gap-1 rounded-full py-0 pl-3 pr-6">
{waiting ? (
<Button type="button" disabled className="rounded-full px-5">
<Loader2 className="size-4 motion-safe:animate-spin" />
{mode === "submitted_code" ? "Waiting for code…" : "Waiting for sign-in…"}
</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();
@@ -501,7 +535,7 @@ export function ProviderSubscriptionCard({
}}>
<span className="size-(--sz-30px) shrink-0">{mark}</span>Sign in
</a>
</Button>
</Button>}
<div className="min-h-(--sz-44px) min-w-0 flex-1 basis-44">{children}</div>
</div>
</OnboardingLoginCard>
@@ -741,6 +775,13 @@ export function LocalProviderLoginInstructions({ adapterType, login, hostedRedir
const safeAuthorizationUrl = isHttpAuthorizationUrl(login?.authorizationUrl) ? login.authorizationUrl : null;
const awaitingBrowserSignIn = browserLogin && !ready && !login?.authorizationUrl && !needsRetry;
const showInlineRetry = Boolean(login && !login.preparing && !ready && !awaitingBrowserSignIn && (isolated || login.error) && !(primaryHandlesRetry && needsRetry));
if (onboardingSignIn && login && needsRetry && !ready) {
return <ProviderSubscriptionCard providerName={connectSourceName(adapterType)}
mode={adapterType === "claude_local" ? "submitted_code" : "displayed_code"}
failure={login.status === "expired" ? "expired" : "failed"}
failureMessage={login.status === "expired" ? undefined : login.error ?? undefined}
onRetry={login.retry}>{null}</ProviderSubscriptionCard>;
}
return <div className="min-w-0 max-w-full space-y-3 text-sm text-muted-foreground">
{ready ? <>
<p role="status" className={cn("flex items-center gap-2 text-foreground", ANALYTICS_MASK_CLASS)}><Check className="size-4 shrink-0 text-(--status-task-icon-done)" />{login?.accountLabel ?? provider} is signed in. Click Connect to use this account.</p>
+5 -3
View File
@@ -1,4 +1,4 @@
import { OnboardingSignInMark } from "./AdapterLoginChrome";
import { OnboardingSignInMark, OnboardingSignInRetry } from "./AdapterLoginChrome";
import type { AiConnectionLoginIntent } from "@paperclipai/shared";
import { cancelAdapterLoginSession, cancelPendingAdapterLogin, matchesAdapterLoginTarget } from "./useAdapterLoginCancellation";
import { useQueryView } from "@/components/QueryView";
@@ -1685,9 +1685,9 @@ function OnboardingWizardInner({
});
const localLoginAction = localLoginPrimary.action;
const connectCta = resolveOnboardingConnectCta({
passiveSubscriptionFooter: subscriptionSignIn && localLoginAction?.kind !== "retry" && !error && !visibleAdapterEnvError,
passiveSubscriptionFooter: subscriptionSignIn && (Boolean(retryLogin) || localLoginAction?.kind === "retry" || (!error && !visibleAdapterEnvError)),
setupError,
retryLogin: Boolean(retryLogin),
retryLogin: !subscriptionSignIn && Boolean(retryLogin),
connectProgress,
adapterEnvLoading,
connectPhase,
@@ -3356,6 +3356,7 @@ function OnboardingWizardInner({
`connectCardMounted`.
*/}
<OnboardingSignInMark.Provider value={subscriptionSignIn ? <ModelSourceMark type={adapterType} Fallback={Loader2} /> : null}>
<OnboardingSignInRetry.Provider value={subscriptionSignIn && retryLogin ? handleConnectStepPrimary : null}>
{!connectCardMounted ? null : connectProgress ? (
<p role="status" className="flex items-center gap-2 text-sm text-muted-foreground">
<Loader2 className="size-4 animate-spin" />
@@ -3526,6 +3527,7 @@ function OnboardingWizardInner({
/>
) : browserSignInUnavailable ? <p role="status" className="text-xs text-muted-foreground">This environment does not support browser sign-in. Go back to use an API key or choose another model.</p> : null
) : null}
</OnboardingSignInRetry.Provider>
</OnboardingSignInMark.Provider>
{showAdvancedSetup && (
<details className="mt-2 space-y-3">