mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-24 05:47:10 +01:00
<!-- Write all pull request text in Simplified Technical English (ASD-STE100): short sentences, one instruction per sentence, simple approved vocabulary, and the active voice. --> ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - On Cloud workspaces, connectors such as GitHub use managed sign-in through Paperclip Cloud > - Paperclip asks the Cloud connector broker which sign-ins this instance has and whether its registration is active > - When the broker rate-limits or fails that check, Paperclip treats the failure as "no Cloud sign-ins" and "not registered" > - The GitHub card then says "Add key", and the connect screen offers self-hosted Cloud registration, which cannot succeed on a Cloud workspace > - This pull request keeps the last answer Cloud confirmed when the broker does not answer, and shows a retry instead of registration > - The benefit is that a busy or unreachable broker no longer changes what the user sees, or sends them into a setup flow that cannot work ## Linked Issues or Issue Description **What happened?** On a production Cloud workspace, the GitHub card on the Connectors page said "Add key" instead of "Connect". On the GitHub connect screen, "Connect with Paperclip" failed with "Paperclip Cloud enrollment could not be started". On another production workspace, "Continue to GitHub" failed with "Internal server error". **Steps to reproduce** 1. Open Connectors on a Cloud workspace while the Cloud connector broker returns 429 to the workspace's signed requests. 2. Look at the GitHub card. It says "Add key". 3. Open Connect GitHub. The self-hosted registration card shows. Its button fails. **Expected behavior** The card says "Connect". A broker that is busy or unreachable gives a retry, not a registration flow that cannot succeed. **Root cause** The broker rate-limited signed requests from production stacks (`429 RATE_LIMITED`; Sentry shows it from 8 production stacks in 7 days, and none on staging). The fix for that is in paperclipai/paperclip-cloud#1751. In this repository, `getCapabilities()` mapped every error to an empty list and cached it for 60 seconds. The enrollment status check mapped every error to `unverified`, and the connect screen treated `unverified` like "not registered". Refs paperclipai/paperclip-cloud#1751 ## What Changed - `paperclip-cloud-connector.ts`: a 429, a 5xx, or an unreachable broker is now a "no verdict" failure (`isTransientPaperclipCloudConnectorError`). - On a "no verdict" failure, capability and instance-status checks return the last answer Cloud confirmed for this connector identity. `invalidatePaperclipCloudConnectorCapabilities()` clears those saved answers. - `paperclipCloudConnectorCapabilitiesFromEnv` keeps an unanswered check for only 5 seconds, not 60. Gallery reads soon ask Cloud again, but a failing broker does not get one request per read. - `paperclip-cloud-connector-status.ts`: when Cloud does not answer the status check (429, 5xx, or network), the status is the new `unreachable`. Incomplete managed settings now report `misconfigured`: the connect screen and the Connections banner tell the user to ask their administrator, because registration cannot run there. `unverified` stays for a saved identity that belongs to another broker, which keeps the registration step. - `Connections.tsx`: the Cloud banner shows a message without the Enable button for `unreachable` and `misconfigured`. - A Cloud rejection, or a confirmed removed or suspended registration, clears the saved sign-ins and the gallery's cached list. An unreadable answer (a non-JSON body) or a 408 counts as no verdict. An answer from a request that started before an invalidation is not saved. - `ConnectionSetupFlow.tsx`: when the Cloud status is `unreachable`, the screen shows "Paperclip couldn’t reach Paperclip Cloud to start GitHub sign-in. Try again in a moment." with a Try again button. It no longer offers registration. Try again reloads both the gallery and the Cloud status. ## Verification - New file `server/src/services/paperclip-cloud-connector-saved-answers.test.ts` (7 tests): the last confirmed sign-ins and status are kept through 429 and 503 responses; a busy broker with no earlier answer gives no verdict; a rejection or removal is not undone by a later 429; a late answer does not replace a newer one; a 429 capability check is kept for only 5 seconds; `unreachable` and `unverified` are reported separately. They fail without this change and pass with it. - `ui/src/pages/apps/AppsConnect.test.tsx`: an `unreachable` status shows the retry and not "Connect with Paperclip"; an `unverified` status still shows registration. - Server connector tests (saved-answers, connector, enrollment): 94/94 pass. Cloud-related AppsConnect tests: 4/4 pass. - `pnpm verify` selected a broad set of server tests and was stopped (exit 143) under machine load. The Cloud-floor tests that it reported as failing pass when run alone (`company-cloud-floor.test.ts` 3/3). CI covers the full suite. ## Risks - Low risk. The saved answers live in memory and are cleared by the existing invalidation and by a restart. A workspace whose Cloud registration was removed still sees that on the next confirmed answer: a 401 maps to `removed` as before. - A saved `active` status can stay in use while the broker keeps failing. This is intended: a failure gives no new information. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, browser, Sentry reads). ## 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 - [ ] All Paperclip CI gates are green - [ ] 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: Claude Opus 5.5 <noreply@anthropic.com>