Align the default-account note with the onboarding API key field (#23009)

## Thinking Path

> - People use Paperclip to manage agents at work.
> - Onboarding connects the first agent to a model provider.
> - When a user enters a new API key, the form explains which account
becomes the default.
> - The note touched the input border. Its text started to the left of
the placeholder.
> - The field now lays out its own note and exposes it as an accessible
description.

## Linked Issues or Issue Description

**What happened?**

The default-account note touched the lower edge of the API key field.
The input had no accessible description.

**Expected behavior**

The note should sit below the field, align with the input text, and wrap
at narrow widths. Assistive technology should announce it with the
field.

**Steps to reproduce**

1. Start onboarding with a new organization that has no saved provider
keys.
2. Name the agent. Choose **Use API key instead**, then **OpenAI**.
3. Inspect the field and note at desktop width and at 320 px.

**Paperclip version or commit**

Reproduced on `e18fe61c8f`. Related PR #19557 added the note.

## What Changed

- Give the shared onboarding field an optional description. Use the
input's horizontal inset and an 8 px vertical gap.
- Associate the description with its input through `aria-describedby`.
- Pass the existing provider-specific sentence from the new-key form.
Add a regression test for fields with and without a description.

## Verification

- The regression test failed on the original field and passed after the
fix. All 17 focused field and saved-credential tests passed.
- The UI typecheck passed. The selected UI suites passed 3,944 tests,
with one skip.
- In Chrome, verified alignment and wrapping at 1280 × 900 and 320 ×
740. Checked the accessible description, password masking, and the
saved-key path with a disposable database.
- Three local CLI worktree tests could not start native PostgreSQL
clusters because the host exhausted its shared-memory slots. The CLI
telemetry test passed on a separate run using its standard environment.

## Risks

The field also serves sign-in flows. The description is optional. Fields
without one retain their existing input markup.

## Model Used

OpenAI Codex (GPT-6) with local code execution and browser verification.

## 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
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] 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: Scott Tong <scott@scotts-mbp-m5-max.local>

Co-authored-by: Scott Tong <scott@scotts-mbp-m5-max.local>
This commit is contained in:
scotttongandScott Tong authored and GitHub committed 2026-11-26 00:44:56 +00:00
1 parent 8aface6cc3
commit e45340c0cf
3 files changed
+29 -3

No files matched your search

@@ -121,6 +121,20 @@ describe("the connect step's cards", () => {
expect(key!.getAttribute("aria-label")).toBe("API key");
});
it("associates a field with its optional description", () => {
render(
<>
<OnboardingCardField description="Account details" value="" onChange={() => {}} onSubmit={() => {}} />
<OnboardingCardField value="" onChange={() => {}} onSubmit={() => {}} />
</>,
);
const [described, plain] = container.querySelectorAll("input");
const descriptionId = described!.getAttribute("aria-describedby");
expect(document.getElementById(descriptionId ?? "")?.textContent).toBe("Account details");
expect(plain!.hasAttribute("aria-describedby")).toBe(false);
});
it("holds one height across the card's waiting and ready states", () => {
// The card opens on a spinner and then fills. Both states share a floor, so
// the footer below is pushed down once for one event rather than twice —
+14 -2
View File
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState, type ClipboardEvent, type ReactNode } from "react";
import { useEffect, useId, useRef, useState, type ClipboardEvent, type ReactNode } from "react";
import { AnimatePresence, motion } from "motion/react";
import { Copy, Check, Loader2 } from "lucide-react";
@@ -365,6 +365,7 @@ export function OnboardingCardField({
onPaste,
disabled,
label = "Authorization code",
description,
placeholder = "Paste authorization code here",
masked = false,
autoFocus = false,
@@ -376,6 +377,7 @@ export function OnboardingCardField({
onPaste?: (event: ClipboardEvent<HTMLInputElement>) => void;
disabled?: boolean;
label?: string;
description?: string;
placeholder?: string;
/**
* Dots instead of the value. The key card asks for it because a provider key
@@ -395,11 +397,13 @@ export function OnboardingCardField({
autoFocus?: boolean;
className?: string;
}) {
return (
const descriptionId = useId();
const input = (
<input
// eslint-disable-next-line jsx-a11y/no-autofocus -- see the prop's note
autoFocus={autoFocus}
aria-label={label}
aria-describedby={description ? descriptionId : undefined}
type={masked ? "password" : "text"}
autoComplete="off"
spellCheck={false}
@@ -417,6 +421,14 @@ export function OnboardingCardField({
className={className ? cn(onboardingCardInputClass, className) : onboardingCardInputClass}
/>
);
if (!description) return input;
return (
<div className="flex flex-col gap-2">
{input}
<p id={descriptionId} className="px-5 text-xs text-muted-foreground">{description}</p>
</div>
);
}
/** Shared authentication presentation. Hosts retain their existing session lifecycle. */
+1 -1
View File
@@ -3306,6 +3306,7 @@ function OnboardingWizardInner({
}} />}
{!selectedApiKey && !hasGatewaySelection && !connectionModels && <OnboardingCardField
label="API key"
description={managedProvider ? `This will be your default ${CONNECT_SOURCE_NAMES[adapterType] ?? managedProvider} account.` : undefined}
placeholder="Enter API key here"
masked
// The card is the answer to the tile just pressed, so
@@ -3319,7 +3320,6 @@ function OnboardingWizardInner({
}}
onSubmit={() => handleConnectStepPrimary()}
/>}
{managedProvider && !selectedApiKey && !hasGatewaySelection && !connectionModels && <p className="text-xs text-muted-foreground">This will be your default {CONNECT_SOURCE_NAMES[adapterType] ?? managedProvider} account.</p>}
{hasGatewaySelection && (gatewayLookupFailed ? <>
<p role="alert" className="text-sm text-destructive">Your saved gateway connection could not be loaded. Retry to choose a model and connect your agent.</p>
<Button type="button" variant="outline" disabled={loading || adapterEnvLoading} onClick={() => { void connectionModelState.refresh(); }}>