mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
fix(ui): let a selected saved subscription be used without a tile click (#14996)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - A user creates an agent in the New Agent flow and connects a model provider in the model step. > - When a saved subscription exists, the step shows it as the selected default and labels the primary button "Use saved subscription". > - The button stays disabled until the user clicks the provider tile, which adds no auth step on this path. > - This extra click is a papercut: the visible choice looks ready but does not work. > - This pull request lets a selected saved subscription enable the button without the tile click. > - The benefit is one less confusing step, with no change to new sign-ins or API keys. ## Linked Issues or Issue Description No public issue exists. The description follows the bug template. **What happened** In New Agent > Connect model, choose a provider that has a saved subscription (for example OpenAI with a saved default). The saved subscription shows as selected and the primary button reads "Use saved subscription". The button stays disabled until you click the provider tile. **Expected behavior** The button is enabled when a saved subscription is selected. A click on it reuses that subscription. **Steps to reproduce** 1. Have a saved OpenAI subscription. 2. Open New Agent and go to the model connection step for a Codex agent. 3. Do not click the OpenAI Subscription tile. 4. See that "Use saved subscription" is disabled. **Paperclip version or commit** master at `4abff286c`. ## What Changed - `AgentProviderConnection.tsx`: the `!opened` gate on the footer primary button no longer applies when `method === "subscription"` and a saved subscription is selected. All other disabled conditions stay (pending auth, loading saved keys, login readiness, API key input). - `connect()` never reads `opened`, so no auth step is skipped. New sign-ins and API keys still require the user to open the provider tile. - `AgentProviderConnection.test.tsx`: a regression test that renders the initial state (tile not opened, saved subscription selected) and expects the button to be enabled and to connect with the saved subscription. A guard test checks that a new sign-in still requires opening the tile. ## Verification - `cd ui && npx vitest run src/components/new-agent src/components/ai-connections --no-file-parallelism`: 6 files, 64/64 tests pass. - The new regression test fails on master and passes with this change. - `pnpm --filter @paperclipai/ui typecheck`: 0 errors. - `node scripts/check-token-gates.mjs`: all gates clean. - Component QA in Storybook (real component, provider verification simulated): before, the button is disabled and skipped by Tab until the tile click. After, a direct click and Tab+Enter both connect, with exactly one verification callback. Selecting a new subscription still requires opening the tile. - Full-app before/after QA with a disposable empty backend and a simulated provider response: same result. - Not tested: a live OpenAI sign-in. Repo-wide `pnpm -r typecheck`, `pnpm test:run` and `pnpm build` are left to CI. Manual check: open New Agent with a saved subscription, go to the model step, and click "Use saved subscription" without clicking the tile. ## Risks - Low risk. The change is one condition in one component. - If a future change makes `connect()` depend on the tile being opened for saved subscriptions, this path would skip that work. The comment at the condition records why the gate is skipped. - Open PR #14698 edits nearby lines in the same component. A small merge conflict is possible. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with tool use (shell, file edit, browser automation). Extended reasoning on. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: scotttong <squadbot000@users.noreply.github.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2 files changed
+33
-1
No files matched your search
@@ -378,6 +378,36 @@ describe("AgentProviderConnection reuse", () => {
|
||||
});
|
||||
expect(host.textContent).toContain("New subscription login");
|
||||
});
|
||||
it("lets a visible saved subscription be used without opening the provider first", async () => {
|
||||
const { test, connected } = await mount("codex_local", false, true, true);
|
||||
expect(host.querySelector("select")).not.toBeNull();
|
||||
const use = [...host.querySelectorAll("button")].find((b) =>
|
||||
b.textContent?.includes("Use saved subscription"),
|
||||
)!;
|
||||
expect(use.disabled).toBe(false);
|
||||
click("Use saved subscription");
|
||||
await vi.waitFor(() =>
|
||||
expect(connected).toHaveBeenCalledWith({
|
||||
env: {
|
||||
CODEX_HOME: { type: "secret_ref", secretId: "codex-home", version: "latest" },
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(test).toHaveBeenCalledWith(connected.mock.calls[0][0]);
|
||||
});
|
||||
it("still requires opening the provider before starting a new subscription login", async () => {
|
||||
await mount("codex_local", false, true, true);
|
||||
flushSync(() => {
|
||||
const select = host.querySelector("select")!;
|
||||
select.value = "";
|
||||
select.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
});
|
||||
const primary = [...host.querySelectorAll("button")].find((b) =>
|
||||
b.textContent?.includes("Connect"),
|
||||
)!;
|
||||
expect(primary.disabled).toBe(true);
|
||||
expect(mocks.loginPanel).not.toHaveBeenCalled();
|
||||
});
|
||||
it.each(["claude_local", "codex_local"] as const)(
|
||||
"passes a personal reference without credentials for %s",
|
||||
async (adapter) => {
|
||||
|
||||
@@ -419,7 +419,9 @@ export function AgentProviderConnection({
|
||||
(!managedAccount && auth.isPending) ||
|
||||
savedKeys.loading ||
|
||||
(adapterType === "claude_local" && storedLogin.isPending) ||
|
||||
!opened ||
|
||||
// The saved-subscription chooser renders outside the opened section,
|
||||
// so reusing the visible choice must not wait for a tile click.
|
||||
(!opened && !(method === "subscription" && savedSubscription)) ||
|
||||
(Boolean(needsLogin) && (!authorizationUrl || loginPhase !== "ready")) ||
|
||||
(method === "api" &&
|
||||
!apiKey.trim() &&
|
||||
|
||||
Reference in new issue
Block a user