mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
Refine Connect account sign-in controls and access badges (#23576)
## Thinking Path > - Paperclip lets people connect provider accounts to agents. > - The Connect account dialog shows the sign-in controls and credential access. > - A pasted callback requires an additional submit action. > - The desktop dialog has room for the three controls on one row. > - Back should return to the provider grid in one step. ## Linked Issues or Issue Description Related PR #23551. **What happened?** The submit control occupied a second row and Back collapsed the selected provider before returning to the grid. **Expected behavior** Keep desktop controls inline, stack them on mobile, and return directly to the grid. **Steps to reproduce** Select Antigravity under Other Models. Inspect the sign-in controls, then press Back. ## What Changed Adjust the Antigravity and Grok sign-in marks. Show overlapping credential access badges. Simplify the submit label and the Back action. ## Verification All 35 focused AdapterLoginChrome and AgentProviderConnection tests passed. ## Risks Narrow viewports use a stacked layout. The available callback controls depend on the environment. ## Model Used OpenAI GPT-6, via Codex. ## 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:
1 parent
49165825a0
commit
a93d971eed
7 files changed
+93
-30
No files matched your search
@@ -420,7 +420,7 @@ describe("session replay", () => {
|
||||
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(input, "http://127.0.0.1:41234/?state=bad&code=abc");
|
||||
input!.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
});
|
||||
const submitButton = Array.from(container.querySelectorAll("button")).find(b => b.textContent === "Submit redirect URL") as HTMLButtonElement;
|
||||
const submitButton = Array.from(container.querySelectorAll("button")).find(b => b.textContent === "Submit") as HTMLButtonElement;
|
||||
await act(async () => { submitButton.click(); });
|
||||
await vi.waitFor(() => expect(container.querySelector('[role="alert"]')?.textContent).toContain("does not match"));
|
||||
expect(submitCode).toHaveBeenCalledWith("http://127.0.0.1:41234/?state=bad&code=abc");
|
||||
@@ -432,13 +432,13 @@ describe("session replay", () => {
|
||||
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(retryInput, "http://127.0.0.1:41234/?state=good&code=xyz");
|
||||
retryInput!.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
});
|
||||
const retrySubmit = Array.from(container.querySelectorAll("button")).find(b => b.textContent === "Submit redirect URL") as HTMLButtonElement;
|
||||
const retrySubmit = Array.from(container.querySelectorAll("button")).find(b => b.textContent === "Submit") as HTMLButtonElement;
|
||||
await act(async () => { retrySubmit.click(); });
|
||||
await vi.waitFor(() => expect(container.textContent).toContain("Finishing sign-in"));
|
||||
expect(submitCode).toHaveBeenCalledWith("http://127.0.0.1:41234/?state=good&code=xyz");
|
||||
});
|
||||
|
||||
it("prompts for an authorization code with a Submit code button for antigravity.google/oauth-callback", async () => {
|
||||
it("prompts for an authorization code with a Submit button for antigravity.google/oauth-callback", async () => {
|
||||
const submitCode = vi.fn().mockResolvedValueOnce(undefined);
|
||||
const container = await render(
|
||||
<LocalProviderLoginInstructions
|
||||
@@ -459,7 +459,7 @@ describe("session replay", () => {
|
||||
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(input, "4/0code-value");
|
||||
input!.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
});
|
||||
const submitButton = Array.from(container.querySelectorAll("button")).find(b => b.textContent === "Submit code") as HTMLButtonElement | undefined;
|
||||
const submitButton = Array.from(container.querySelectorAll("button")).find(b => b.textContent === "Submit") as HTMLButtonElement | undefined;
|
||||
expect(submitButton).toBeDefined();
|
||||
await act(async () => { submitButton!.click(); });
|
||||
expect(submitCode).toHaveBeenCalledWith("4/0code-value");
|
||||
|
||||
@@ -524,7 +524,7 @@ export function ProviderSubscriptionCard({
|
||||
<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">
|
||||
<div className="flex min-h-(--sz-44px) flex-col gap-3 sm:flex-row sm:items-center">
|
||||
{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>}
|
||||
@@ -547,7 +547,7 @@ export function ProviderSubscriptionCard({
|
||||
</span>
|
||||
}>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
{waiting ? (
|
||||
<Button type="button" disabled className="rounded-full px-5">
|
||||
<Loader2 className="size-4 motion-safe:animate-spin" />
|
||||
@@ -556,7 +556,7 @@ export function ProviderSubscriptionCard({
|
||||
) : <Button type="button" disabled={!authorizationUrl} className="gap-1 rounded-full py-0 pl-3 pr-6" onClick={openAuthorizationLink}>
|
||||
<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 className="min-h-(--sz-44px) min-w-0 sm:flex-1">{children}</div>
|
||||
</div>
|
||||
{waiting && authorizationUrl && (
|
||||
<div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground">
|
||||
@@ -882,29 +882,31 @@ export function LocalProviderLoginInstructions({ adapterType, login, hostedRedir
|
||||
{submitError && <p role="alert" className="px-2 text-xs text-destructive">{submitError}</p>}
|
||||
{!onboardingSignIn && <Button type="button" disabled={!browserCode.trim() || submitting} onClick={() => void submitBrowserCode()}>Submit code</Button>}
|
||||
</div> : hostedGoogleRedirect ? <div className="flex flex-col gap-2">
|
||||
<p className="px-2 text-xs text-muted-foreground">
|
||||
{(!onboardingSignIn || optionalHostedGoogleRedirect) && <p className="px-2 text-xs text-muted-foreground">
|
||||
{optionalHostedGoogleRedirect
|
||||
? <>Finish signing in in the Antigravity browser window, then return here. If your browser is on another machine and the <code className="font-mono">127.0.0.1</code> redirect page won’t load, copy the full URL from your address bar and paste it below.</>
|
||||
: isHostedAntigravityCodeCallback(safeAuthorizationUrl)
|
||||
? <>After signing in to Antigravity, copy the authorization code shown on the page and paste it below.</>
|
||||
: <>After signing in to Antigravity, copy the authorization code or full callback URL from your browser and paste it below.</>}
|
||||
</p>
|
||||
<OnboardingCardField
|
||||
label={isHostedAntigravityCodeCallback(safeAuthorizationUrl) ? "Antigravity authorization code" : "Antigravity authorization code or callback URL"}
|
||||
placeholder={isHostedAntigravityCodeCallback(safeAuthorizationUrl) ? "Paste authorization code here" : "Paste authorization code or callback URL here"}
|
||||
className={cn(ANALYTICS_MASK_CLASS, ANALYTICS_NO_CAPTURE_CLASS)}
|
||||
value={browserCode}
|
||||
onChange={(value) => {
|
||||
setSubmitError(null);
|
||||
setBrowserCode(value);
|
||||
}}
|
||||
onPaste={pasteBrowserCode}
|
||||
onSubmit={() => void submitBrowserCode()}
|
||||
disabled={submitting}
|
||||
/>
|
||||
<Button type="button" disabled={!browserCode.trim() || submitting} onClick={() => void submitBrowserCode()}>
|
||||
{isHostedAntigravityCodeCallback(safeAuthorizationUrl) ? "Submit code" : "Submit redirect URL"}
|
||||
</Button>
|
||||
</p>}
|
||||
<div className="grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center">
|
||||
<OnboardingCardField
|
||||
label={isHostedAntigravityCodeCallback(safeAuthorizationUrl) ? "Antigravity authorization code" : "Antigravity authorization code or callback URL"}
|
||||
placeholder={isHostedAntigravityCodeCallback(safeAuthorizationUrl) ? "Paste authorization code here" : "Paste authorization code or callback URL here"}
|
||||
className={cn(ANALYTICS_MASK_CLASS, ANALYTICS_NO_CAPTURE_CLASS)}
|
||||
value={browserCode}
|
||||
onChange={(value) => {
|
||||
setSubmitError(null);
|
||||
setBrowserCode(value);
|
||||
}}
|
||||
onPaste={pasteBrowserCode}
|
||||
onSubmit={() => void submitBrowserCode()}
|
||||
disabled={submitting}
|
||||
/>
|
||||
<Button type="button" disabled={!browserCode.trim() || submitting} onClick={() => void submitBrowserCode()}>
|
||||
Submit
|
||||
</Button>
|
||||
</div>
|
||||
{submitError && <p role="alert" className="px-2 text-xs text-destructive">{submitError}</p>}
|
||||
</div> : adapterType === "antigravity_runtime" ? <p>Finish signing in in the Antigravity browser window, then return here.</p> : <OnboardingLoginCodeRow code={login?.code ?? ""} />}
|
||||
</ProviderSubscriptionCard>}
|
||||
|
||||
@@ -194,7 +194,7 @@ it("immediately triggers check after submitting a hosted Google redirect URL", a
|
||||
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(input, "http://127.0.0.1:41234/?state=hosted&code=abc123");
|
||||
input.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
});
|
||||
flushSync(() => Array.from(host.querySelectorAll("button")).find(b => b.textContent === "Submit redirect URL")!.click());
|
||||
flushSync(() => Array.from(host.querySelectorAll("button")).find(b => b.textContent === "Submit")!.click());
|
||||
|
||||
await vi.waitFor(() => expect(api.submitLocalLoginCode).toHaveBeenCalledWith("company", "attempt-1", "http://127.0.0.1:41234/?state=hosted&code=abc123"));
|
||||
await vi.waitFor(() => expect(api.checkLocalLogin).toHaveBeenCalledTimes(2));
|
||||
|
||||
@@ -322,6 +322,13 @@ export function AgentProviderConnection({
|
||||
const providerMark = (wizardCard || managedAccount?.providerDialog) && (adapterType === "claude_local" || adapterType === "codex_local")
|
||||
? <ModelSourceMark type={adapterType} Fallback={Loader2} />
|
||||
: <AdapterMark type={adapterType} className={managedAccount?.providerDialog ? "size-full" : undefined} />;
|
||||
const signInMark = adapterType === "claude_local" || adapterType === "codex_local" ? providerMark : (
|
||||
<span className="grid size-full place-items-center">
|
||||
{adapterType === "grok_local"
|
||||
? <span aria-hidden className="size-(--sz-22px) bg-current mask-[url('/brands/adapters/grok.svg')] mask-contain mask-center mask-no-repeat" />
|
||||
: <AdapterMark type={adapterType} className="size-5" />}
|
||||
</span>
|
||||
);
|
||||
const switchMode = (next: ModelConnectionMode) => {
|
||||
if (advancedConnection && next === (advanced ? "advanced" : method)) return;
|
||||
onDraftChanged?.();
|
||||
@@ -399,7 +406,7 @@ export function AgentProviderConnection({
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<OnboardingSignInMark.Provider value={inlineLogin ? providerMark : null}>
|
||||
<OnboardingSignInMark.Provider value={inlineLogin ? signInMark : null}>
|
||||
<motion.div
|
||||
initial={false}
|
||||
animate={{ height: opened ? "auto" : 0, opacity: opened ? 1 : 0 }}
|
||||
@@ -469,7 +476,7 @@ export function AgentProviderConnection({
|
||||
<OnboardingLoginCard revealTogether instruction={`Connect your ${provider} subscription.`}>
|
||||
<Button type="button" disabled={managedAccount?.disabled} className="w-fit gap-1 rounded-full py-0 pl-3 pr-6"
|
||||
onClick={() => setLoginRequested(true)}>
|
||||
<span className="size-(--sz-30px) shrink-0">{providerMark}</span>Prepare sign-in
|
||||
<span className="size-(--sz-30px) shrink-0">{signInMark}</span>Prepare sign-in
|
||||
</Button>
|
||||
</OnboardingLoginCard>
|
||||
) : needsLogin ? !awaitingLoginRequest && (
|
||||
@@ -557,6 +564,7 @@ export function AgentProviderConnection({
|
||||
if (opened && !advancedConnection) {
|
||||
localLoginPrimary.resetSubmitting();
|
||||
cancel();
|
||||
if (managedAccount?.providerDialog) onBack();
|
||||
} else onBack();
|
||||
}}
|
||||
compact={Boolean(wizardCard)}
|
||||
|
||||
@@ -93,6 +93,8 @@ import { toolsApi } from "@/api/tools";
|
||||
import { agentsApi } from "@/api/agents";
|
||||
import { appCopyFor, credentialFieldLabel } from "@/lib/app-gallery-copy";
|
||||
import { JsonSchemaForm, validateJsonSchemaForm, type JsonSchemaNode } from "@/components/JsonSchemaForm";
|
||||
import { credentialAccessBadges } from "./credential-access-badges";
|
||||
import { Avatar, AvatarFallback, AvatarGroup, AvatarGroupCount } from "@/components/ui/avatar";
|
||||
import { AgentMultiSelect, type AgentMultiSelectOption } from "@/components/AgentMultiSelect";
|
||||
import { describeError, errorStatus } from "@/api/errors";
|
||||
import { InlineBanner } from "@/components/InlineBanner";
|
||||
@@ -4684,10 +4686,34 @@ export function ConnectionAccessDefaults({
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const expanded = open || forceOpen;
|
||||
const { installChoice, installAgentIds } = accessProps;
|
||||
const { visible, remaining } = useMemo(
|
||||
() => credentialAccessBadges(flat ? agents ?? [] : [], installAgentIds, installChoice === "all"),
|
||||
[flat, agents, installAgentIds, installChoice],
|
||||
);
|
||||
const ownerLabel = accessProps.grantKind === "organization" ? "Organization" : "You";
|
||||
|
||||
return (
|
||||
<Collapsible open={expanded} onOpenChange={setOpen} className={flat ? "w-full" : "mt-6 rounded-lg border border-border bg-muted/30 px-4 py-3"}>
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1">
|
||||
<p className="text-sm text-muted-foreground">{sentence}</p>
|
||||
<div className={cn("flex flex-wrap justify-between gap-x-3 gap-y-1", flat ? "items-center" : "items-baseline")}>
|
||||
<div className="grid gap-2">
|
||||
<p className={cn("text-muted-foreground", flat ? "text-xs" : "text-sm")}>{sentence}</p>
|
||||
{flat && <AvatarGroup aria-label="Credential access">
|
||||
<Avatar title={ownerLabel} aria-label={ownerLabel} role="img">
|
||||
<AvatarFallback className="bg-linear-to-b from-accent to-secondary text-foreground">
|
||||
{accessProps.grantKind === "organization" ? <UsersRound className="size-4" /> : <UserRound className="size-4" />}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
{visible.map((agent, index) => (
|
||||
<Avatar key={agent.id} title={agent.name} aria-label={agent.name} role="img">
|
||||
<AvatarFallback className={cn("bg-linear-to-b from-background/60 text-foreground", [
|
||||
"bg-(--status-task-icon-done)/50", "bg-(--status-task-icon-todo)/50", "bg-(--status-task-icon-in_review)/50", "bg-(--status-task-icon-in_progress)/50",
|
||||
][index])}>{Array.from(agent.name.trim())[0]?.toLocaleUpperCase()}</AvatarFallback>
|
||||
</Avatar>
|
||||
))}
|
||||
{remaining > 0 && <AvatarGroupCount aria-label={`${remaining} more agents`}>+{remaining}</AvatarGroupCount>}
|
||||
</AvatarGroup>}
|
||||
</div>
|
||||
<CollapsibleTrigger asChild><Button
|
||||
type="button"
|
||||
variant="link"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { expect, it, vi } from "vitest";
|
||||
import { credentialAccessBadges } from "./credential-access-badges";
|
||||
|
||||
it("limits the visible badges and stops scanning once the first four matches are found", () => {
|
||||
const agents = Array.from({ length: 500 }, (_, i) => ({ id: String(i) }));
|
||||
const selected = new Set(["4", "10", "100", "200", "400"]);
|
||||
const lookups = vi.spyOn(selected, "has");
|
||||
expect(credentialAccessBadges(agents, selected, true)).toEqual({ visible: agents.slice(0, 4), remaining: 496 });
|
||||
expect(lookups).not.toHaveBeenCalled();
|
||||
expect(credentialAccessBadges(agents, selected, false)).toEqual({
|
||||
visible: [agents[4], agents[10], agents[100], agents[200]], remaining: 1,
|
||||
});
|
||||
expect(lookups).toHaveBeenCalledTimes(201);
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
export function credentialAccessBadges<T extends { id: string }>(
|
||||
agents: readonly T[],
|
||||
selected: ReadonlySet<string>,
|
||||
allAgents: boolean,
|
||||
) {
|
||||
const count = allAgents ? agents.length : selected.size;
|
||||
const visible: T[] = [];
|
||||
for (const agent of agents) {
|
||||
if (visible.length === Math.min(4, count)) break;
|
||||
if (allAgents || selected.has(agent.id)) visible.push(agent);
|
||||
}
|
||||
return { visible, remaining: count - visible.length };
|
||||
}
|
||||
Reference in new issue
Block a user