paperclip/server/src
Dotta 5f87090894
Make managed Cloud OAuth handoffs invisible (#12790)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Apps let people give agents governed access to external providers
> - Paperclip Cloud brokers shared provider authorization for managed
stacks
> - The managed flow sent the browser through a confirmation page after
the tenant had already prepared sign-in
> - A lost confirmation response could also show an expired-session
error before the provider page opened
> - This pull request adds an opaque handoff contract and one shared
tenant coordinator
> - The benefit is a direct and recoverable transition from Paperclip to
every Cloud-brokered provider

## Linked Issues or Issue Description

**What happened?**

A managed Paperclip Cloud connection opened the Cloud confirmation
route. A response-loss race could show an expired-session error while
the authorization still continued.

**Expected behavior**

The current Paperclip loading state must stay visible while the tenant
exchanges an opaque session. The browser must then open the provider
directly. Self-hosted and direct OAuth must keep their existing
behavior.

**Steps to reproduce**

1. Open Apps on a Paperclip Cloud stack.
2. Start a managed provider connection.
3. Select Continue to sign in.
4. Observe that the browser visits the Cloud confirmation route before
it reaches the provider.

**Paperclip version or commit**

`b872cd3d1b404bdaff70af493a2973ceb7e5d6ec`

**Deployment mode**

Paperclip Cloud hosted stack.

No related open issue or pull request was found in the repository
search.

## What Changed

- Add a backward-compatible opaque Cloud handoff to the shared OAuth
start contract.
- Validate the Cloud descriptor on the server and expose no
browser-selected endpoint.
- Exchange managed handoffs through one fixed same-origin route in every
Apps OAuth launcher.
- Keep dialog popups reserved before asynchronous work and retain the
tenant loading state.
- Add recent-login resume storage, bounded retry behavior, terminal
tenant errors, tests, and Storybook states.

## Verification

- `pnpm check:token-gates`
- `pnpm -r typecheck`
- Focused connector and UI suites: 184 passed and 202 skipped.
- `pnpm build`
- `pnpm build-storybook`
- The full local suite reached one unrelated macOS path-alias failure.
The untouched test expected `/var/...` and received the equivalent
`/private/var/...`. The same test reproduces in isolation.

## Risks

- A malformed managed descriptor now fails closed in Paperclip instead
of opening a URL.
- A legacy Cloud deployment can omit the descriptor. Paperclip then uses
the existing validated confirmation URL.
- Direct provider OAuth and self-hosted flows do not receive a handoff
and remain unchanged.
- Rollback is a normal revert of this commit because the contract is
optional and backward compatible.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- OpenAI Codex with GPT-5.6, reasoning mode, tool use, 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
- [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>
2026-09-03 16:33:13 -05:00
..
__tests__ Make managed Cloud OAuth handoffs invisible (#12790) 2026-09-03 16:33:13 -05:00
adapters fix(security): harden privileged server boundaries (#12776) 2026-09-03 14:15:32 -05:00
auth feat(runner): add Codex-native application integration (#12591) 2026-08-31 14:38:38 -05:00
built-ins/agents Remove cheap model profiles (#12683) 2026-09-01 14:57:38 -05:00
http fix(server): raise company import zip upload limit to 1 GB and make it operator-configurable (#11184) 2026-08-10 12:47:03 -07:00
lib perf(server): reduce issue detail request overhead (#10414) 2026-08-11 14:39:23 -04:00
middleware fix(server): retry cloud-tenant auth sync once on a dropped DB connection (#12773) 2026-09-03 12:16:55 -07:00
onboarding-assets fix: reliably show plans in the Plan pane and restore sticky plan confirmation CTAs (#10930) 2026-08-05 19:32:07 -07:00
realtime feat(runner): add remote execution substrate (#12638) 2026-09-01 01:29:06 -05:00
routes Make managed Cloud OAuth handoffs invisible (#12790) 2026-09-03 16:33:13 -05:00
secrets feat(secrets): write through external values and deep-link details (#10196) 2026-07-27 19:08:07 -05:00
services Make managed Cloud OAuth handoffs invisible (#12790) 2026-09-03 16:33:13 -05:00
storage feat(run-logs): durable run-log store via object-storage mirror (#8984) 2026-07-14 15:45:39 -07:00
types feat(mcp) [split 3/8]: add tool access policy core (#9558) 2026-07-14 14:22:39 -05:00
vendor/paperclip-runner feat(runner): add remote execution substrate (#12638) 2026-09-01 01:29:06 -05:00
agent-auth-jwt.ts fix(server): align agent run JWT default TTL with documented 48h default (#10176) 2026-08-12 16:44:20 -07:00
app.ts Secure Cloud canonical runtime identity (#12766) 2026-09-03 12:01:47 -05:00
attachment-types.ts Remove the company brand color and per-company attachment limit (#12291) 2026-08-27 12:11:05 -07:00
board-claim.ts [codex] Add agent permissions and controls plan (#6386) 2026-05-22 08:12:52 -05:00
build-commit.ts fix(server): preserve source SHA without Git metadata (#9638) 2026-07-15 20:03:52 -05:00
build-version.ts fix(server): stamp the real build version into images instead of the package.json placeholder (#10257) 2026-07-25 10:06:28 -07:00
config-file.ts fix(config): preserve extensions and guard invalid repairs (#11005) 2026-08-07 00:41:19 -05:00
config.ts feat(apps): improve gateway and workspace connection UX (#12340) 2026-08-29 12:08:32 -05:00
db-errors.ts fix(issues): make DELETE /api/issues/:id succeed for issues with dependents (#11331) 2026-08-13 12:02:15 -07:00
dev-native-runner-status.ts feat(runner): integrate Codex native execution (#12616) 2026-08-31 22:51:17 -05:00
dev-runner-worktree.ts feat(workspaces): sign the workspace login handoff and gate readiness (#11671) 2026-08-19 02:37:02 -05:00
dev-server-status.ts [codex] UI and dev ops quality-of-life (#6384) 2026-05-19 15:52:39 -05:00
dev-watch-ignore.ts fix(server): ignore sibling worktrees in dev watch (#11074) 2026-08-07 18:30:16 -07:00
embedded-postgres-supervisor.ts fix(workspaces): recover degraded runtime databases (#11651) 2026-08-18 17:40:54 -05:00
errors.ts feat(artifacts): bridge Markdown work products into the document review surface (#11822) 2026-08-20 17:28:01 -07:00
first-admin-claim.ts [codex] Add private browser first-admin claim flow (#6755) 2026-05-27 21:15:01 -10:00
home-paths.ts feat(server): thread plural referenced-project workspaces through run prep (#10448) 2026-07-29 14:27:05 -07:00
index.ts fix(server): stop paging Sentry for supervised boot races in managed cloud (#12772) 2026-09-03 10:02:42 -07:00
instrumentation.test.ts fix(server): export manual OpenTelemetry spans (#10565) 2026-07-31 12:47:57 -07:00
instrumentation.ts fix(observability): pin the Sentry browser SDK and gate the optional Sentry server peer on the exact version (#12270) 2026-08-27 07:20:03 -07:00
log-redaction.ts Sync/master post pap1497 followups 2026 04 15 (#3779) 2026-04-15 21:13:56 -05:00
paths.ts
…
peer-version-check.ts fix(observability): pin the Sentry browser SDK and gate the optional Sentry server peer on the exact version (#12270) 2026-08-27 07:20:03 -07:00
redaction.ts fix(agents): redact plaintext env values in agent read and mutation responses (#9860) 2026-09-03 14:13:26 -05:00
runtime-api.ts Prefer loopback runtime API URL for local agents (#5102) 2026-06-20 14:03:21 -07:00
runtime-tools-token.test.ts feat(connections): add self-serve intent runtime (#12345) 2026-08-29 12:08:34 -05:00
runtime-tools-token.ts feat(connections): add self-serve intent runtime (#12345) 2026-08-29 12:08:34 -05:00
sentry-dsn.ts feat(server): split the Sentry DSN into front-end and backend variables (#12678) 2026-09-01 11:02:04 -07:00
sentry.ts feat(server): split the Sentry DSN into front-end and backend variables (#12678) 2026-09-01 11:02:04 -07:00
server-info.ts fix(server): preserve source SHA without Git metadata (#9638) 2026-07-15 20:03:52 -05:00
shutdown.test.ts feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190) 2026-08-26 11:15:45 -07:00
shutdown.ts feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190) 2026-08-26 11:15:45 -07:00
startup-banner.ts fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400) 2026-08-14 22:11:16 -07:00
startup-refusals.ts fix(server): stop paging Sentry for supervised boot races in managed cloud (#12772) 2026-09-03 10:02:42 -07:00
static-index-html.ts [codex] Bundle local branch fixes from PAP-10032 (#6604) 2026-05-25 07:25:26 -05:00
static-ui-cache.ts fix(ui): keep the installed service worker fresh on parked tabs (#12198) 2026-08-25 16:12:02 -07:00
telemetry.ts fix: add periodic flush and graceful shutdown for server-side telemetry 2026-04-02 10:47:29 -05:00
ui-branding.ts Ensure worktree execution starts only after activation (#9374) 2026-07-10 16:11:26 -05:00
url-utils.test.ts fix(runtime): only rewrite base-URL port for loopback hosts (#10258) 2026-08-13 09:47:13 -07:00
url-utils.ts fix(runtime): only rewrite base-URL port for loopback hosts (#10258) 2026-08-13 09:47:13 -07:00
version.ts fix(server): stamp the real build version into images instead of the package.json placeholder (#10257) 2026-07-25 10:06:28 -07:00
vite-html-renderer.ts [codex] Add backup endpoint and dev runtime hardening (#4087) 2026-04-20 06:08:55 -05:00
worktree-config.ts feat(apps): consolidate connector management (#12684) 2026-09-01 14:55:35 -05:00
worktree-seed-manifest.ts feat(workspaces): sign the workspace login handoff and gate readiness (#11671) 2026-08-19 02:37:02 -05:00