Skip to content

Embedded in another app's page, an app's sign-in opens in a tab of its own - #2897

Queued
mxmzb wants to merge 3 commits into
mainfrom
embed-connect-in-window
Queued

mxmzb wants to merge 3 commits into
mainfrom
embed-connect-in-window

Conversation

@mxmzb

@mxmzb mxmzb commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Embedded in another app's page (configureEmbed), every screen that starts an app's sign-in did window.location.href = authorizationUrl. That sent the host app's own page to the vendor. The vendor then brought the person back to OpenBot's public address, where somebody signed in through the host has no session, so they ended on a sign-in screen, out of the app they were using.

What changes

API (additions only):

  • ConnectionReturnTo and SharedConnectionReturnTo gain window: a page that needs no sign-in and closes the tab the sign-in ran in. It applies to connectApp, connectSharedApp and authorizeAction.
  • getDeployment gains windowConnections. A client sends window only where the server says so, as with mobile and mobileConnections.

Web app, embedded only:

  • lib/plugins/consent-tab.ts: the sign-in opens in a tab claimed on the click, because a browser only allows one while the click is recent and asking the server for the address comes first. The opener is severed, so the vendor's page can't reach the host page. If the tab is blocked, the sign-in still opens in the page, as before.
  • A connect asks for returnTo: window only when all of these hold:
    • the server offers it;
    • a tab claimed on the press is actually held. With none (blocked, or a connect the page starts itself) the sign-in opens in the host page, which the closing page couldn't close, so it comes back to OpenBot's own pages as before;
    • the apps aren't authorized action by action. That consent ends at OpenBot's verifier, which needs the person's session.
  • Once the person is back, the connection is confirmed and the lists read again, as OpenBot Desktop's window already does (confirmOnReturn). Embedded, a confirm answered "not connected" is asked again at the next return, for up to fifteen minutes, because the person may come back to the host page before they finish in the other tab.
  • The screens that sent their own page to a sign-in now go through the consent tab: an app's page, Admin's app page, Add custom MCP, a Composio app's row, an action's consent and the personal edition's tiles. A source scan in the new test keeps a new one from doing it again.
  • Through Composio, OpenBot's step before the sign-in is left out when embedded. As a dialog it counts down to a sign-in no click opens, so the tab would be blocked; as a page it lives on the host's origin, which serves the host app and not OpenBot.

Not embedded, nothing changes. claim does nothing, and go sends the page to the sign-in exactly as before.

Docs: "Connecting apps" under Embedded sign-in, including that a sandboxed frame around the host page needs allow-popups.

Changelog

Apps.

  • Embedded in another app's page, an app's sign-in opens in a tab of its own. The host page stays where it is, and the tab closes once the sign-in is done, instead of the host page going to the vendor and coming back to a sign-in screen.

API.

  • Added: returnTo: window on connectApp, connectSharedApp and authorizeAction, and windowConnections on getDeployment. A client asks for window only where the server offers it.

Tests

  • app/tests/embedded-consent-window.test.ts (15):
    • Embedded and offered: connect, a shared app's connect and an action's consent ask for window.
    • Not embedded: connections and apps, as before.
    • Against a server that doesn't offer it, with no tab held, or where apps are authorized action by action: never window.
    • A tab the person closed before the sign-in was ready: a new one opens, never the host page.
    • A confirm that's too early is asked again at the next return, and stops once connected.
    • The tab is claimed on the click and sent to the sign-in, with the page left alone and the opener severed. It's dropped when nothing opens, and a blocked tab falls back to the page.
    • Not embedded: nothing is claimed.
    • No screen in the list sends its own page to a sign-in.
    • The returnTo and scan tests failed before the change.
  • 102 related app test files: 710 pass, 0 fail.
  • Format, lint and typecheck clean.
  • api:generate leaves nothing changed, api:lint is valid, and oasdiff breaking reports no breaking changes.
  • In real browsers, with the server half, embedded in a host page on another origin:
    • Chromium: an admin adds a custom MCP from Add custom MCP. The host page stays where it was; the sign-in runs in its own tab, the vendor returns it to the closing page, and the tab closes. The app's page in the host reads "Connected".
    • WebKit and Chromium: a member connects their own account from the app's page, with the same result. The credentials are recorded.
    • Rerun after the review fixes, in both browsers.

🤖 Generated with Claude Code

mxmzb and others added 2 commits December 3, 2026 21:24
…s own

Embedded (configureEmbed), a screen that sent its tab to an app's sign-in sent the host app's
page, and the vendor brought the person back to OpenBot's public address, where somebody signed
in through the host has no session: a sign-in screen, out of the app they were using.

- The API: returnTo window on connectApp, connectSharedApp and authorizeAction, a page that needs
  no sign-in and closes the tab the sign-in ran in, offered where getDeployment says
  windowConnections.
- The web app, embedded: the sign-in opens in a tab claimed on the press (lib/plugins/consent-tab.ts),
  every connect asks for returnTo window where the server offers it, and the connection is read
  again once the person is back, as OpenBot Desktop's window does. Through Composio, OpenBot's
  step before the sign-in is left out when embedded: no page of OpenBot's runs on the host's origin
  to show it. Not embedded, nothing changes.
- Docs: Connecting apps, under Embedded sign-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…until connected

From review:
- returnTo window only while a tab claimed on the press is there for the sign-in. With none (the
  browser blocked it, or the page started the press itself) the sign-in opens in the host page,
  which a page that closes its tab could not close, so it comes back to OpenBot's own pages as
  before. A tab the person closed before the sign-in was ready opens a new one, never the host page.
- Never for apps authorized action by action: that consent ends at OpenBot's verifier, which needs
  the person's session.
- Embedded, a confirm answered "not connected" is asked again at the next return, for up to fifteen
  minutes, so coming back to the host page before finishing no longer loses the account.
- Admin's app page claims only for an app reached as you, and lets go of the tab where reading the
  catalogue fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The security side is right, but one gap blocks this: only some of the ways in are fixed.

I checked the redirect and the closing page and found no problems:

  • The return is a fixed page the server chooses, never an address.
  • The closing page reads one flag, reflects nothing and runs under a strict CSP.
  • There's no postMessage, and the opener is cut before the tab navigates, so no code or state reaches the host page.
  • The spec change only adds things, and the clients are regenerated.
  • Outside embedded mode, nothing changes.

Must fix

  • useConnectInNewTab opens its own tab with window.open and never registers it in held (app/src/lib/plugins/consent-tab.ts:56-62). So connectsInWindow is false for every press that goes through it, and those requests still send returnTo: connections. That covers:

    • the chat connect cards (connect-app-card.tsx, another-account-card.tsx)
    • app-access-action.tsx
    • Browse apps (use-directory-press.ts)

    Embedded, those tabs end on /connections/<key> with no session, which is a sign-in screen. markConnectReturn can't rescue it either, because it writes to the blank tab's sessionStorage on the host's origin.

    Fix: register the claimed tab in held (export a hold/release from consent-tab.ts), and add a test that a chat card's connect sends window when embedded.

Nits, not blocking

  • consent-tab.ts:111-120 has three gaps:

    • a blocked reopen after the person closed the tab fails silently;
    • connectsInWindow counts tabs held by any screen, while go uses only its own;
    • a screen that unmounts mid-press leaves its tab held.

    Tie the window decision to the screen's own tab, and drop the tab on unmount.

  • docs/configuration.md:837: a sandboxed frame needs allow-popups-to-escape-sandbox as well as allow-popups, or vendor sign-in pages break.

  • confirm-on-return.ts:111: putting an entry back after the awaits can overwrite a newer press. For 15 minutes after an unfinished consent, every focus reloads every plugin list, so consider a backoff.

  • Embedded, the notice before a Composio sign-in is skipped. That drops a step people get today. A Continue-only dialog would keep it.

  • Embedded, Add custom MCP opens and closes a blank tab even for a server that needs no sign-in.

  • The success heading says "signed in to the app". Our word is "connect": "Connected".

  • Out of scope, but worth knowing: the GitHub identity link (linked-accounts.tsx:228) still takes over the host page when embedded.

CI: the WebKit shards were still running at review time.

…he closing page too

From Dave's review of this PR:
- useConnectInNewTab claims its own tab and never registered it as held, so a chat card's connect,
  Browse apps and an app's access row still asked for OpenBot's own pages and landed on a sign-in
  screen when embedded. Its tab is now held (holdConsentTab) until it is sent to the sign-in or
  closed. Test: an embedded chat card's connect sends returnTo window.
- A screen that goes lets go of the tab it claimed.
- A confirm put back for the next return never replaces a newer press for the same app.
- Docs: a sandboxed frame needs allow-popups-to-escape-sandbox as well as allow-popups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chat cards, Browse apps and app access now hold their tab too, so every way in asks for the closing page. Approving.

  • All four new-tab entry points open their tab through one claim that holds it, and every way out of the press lets it go. Outside embedded mode, nothing changes.
  • The new card test would fail without the hold, because the connect would still send connections.
  • Screens now let go of their tab when they go, a confirm that's put back can't replace a newer press for the same app, and the sandbox note now includes allow-popups-to-escape-sandbox.
  • One edge for later: if you reach Admin's app page through a reconnect, it moves to the reconnect page before the sign-in, so that sign-in no longer has a held tab.

Merge once CI is green. It goes in 1.2.10.

@davidmckayv
davidmckayv enabled auto-merge December 3, 2026 21:14
@davidmckayv
davidmckayv added this pull request to the merge queue Dec 3, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants