Skip to content

A tab signed out elsewhere stops asking, and goes to sign-in - #2816

Merged
davidmckayv merged 3 commits into
mainfrom
fix/signed-out-tab-stops
Dec 2, 2026
Merged

davidmckayv merged 3 commits into
mainfrom
fix/signed-out-tab-stops

Conversation

@davidmckayv

@davidmckayv davidmckayv commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

A Cloud alert today (GET /api/v2/organizations/:organizationId/conversation-events refused 401 at 25%) traced to one person's tab, signed out since 14:40Z and still on web/1.2.5. For hours it kept asking OpenBot, and it never told the person they were signed out. Two things did the asking:

  • The conversation events socket reconnected for ever. A browser hides the 401 that refuses a WebSocket upgrade, so the page only saw the socket close, and it backed off to 30 seconds and tried again. Only SSO_REQUIRED_CLOSE stopped it.
  • The check of who holds a computer's wheel polled every 1 to 2 seconds. It counted a 401 as a missed read, and only BOT_GONE stopped it.

Now:

  • A socket refused before it opens asks once who is signed in. It uses getPerson, the same question the _authed gate asks, and doesn't ask again more often than every 30 seconds. If nobody is signed in, the socket stops, and it opens again only once somebody is signed in. Any other answer (the network, a 5xx, a proxy's page) keeps today's backoff. This runs after the embed renewal that already happened on a refused-before-open close, so it follows that existing pattern.
  • The wheel check stops on OpenBot's own 401, just as it does for BOT_GONE. Coming back to the tab asks once more, also as for BOT_GONE. A 401 that isn't OpenBot's JSON (a proxy) still counts only as a missed read (refusedAsSignedOut).
  • Either way the app finds out (lib/auth/session-check.ts and components/auth/signed-out-watch.tsx, mounted in _authed), and the signed-in gate runs again. In a browser that means the existing sign-in screen, which brings the person back to the page they were on. Inside OpenBot Desktop it means Desktop's sign_in_refused, and embedded it means the host's renewal. Nothing is drawn that wasn't drawn before.
  • The socket names the app in a new optional client query parameter (web/1.2.8), because a browser can't set OpenBot-Client on a WebSocket. The server writes it into its log when it refuses the socket (the backend half, in its own PR).

Why the client re-checks instead of the server accepting the upgrade and closing with a "signed out" code: a server change would only help apps released from now on, together with servers upgraded from now on. The re-check works against every server in the support window, Cloud included. It also reuses the gate's own flow, so every way of signing in (browser, Desktop, embedded) is handled the way it already is on a load. And it works for any Bot, because nothing about it depends on the Bot.

Where it runs

  • New state that outlives a request? None on the server. In the browser: one question at a time about who is signed in, and its listeners.
  • Second replica? No server change in this repo.
  • Anything serialised? No.
  • Fanned out to a browser? No.
  • New listener, port, or schedule? No.

Boundary and audit

  • Nothing new acts. Nothing new is trusted from the client: the client query parameter is only logged.

API and database

  • api/asyncapi.yaml: one new optional query parameter on conversationEvents, client. It is additive: a socket opened without it is answered the same, and nothing is refused for it. It is listed in api/accepted-live-breaking-changes.md, as capabilities was on 2026-11-26. bun run api:live:diff passes, and bun run api:generate changes nothing. There is no OpenAPI change and no database change. I read docs/api-and-migrations.md.

Changelog

Signing in.

  • A tab signed out elsewhere goes to the sign-in screen and stops asking OpenBot. Before, it reconnected its live socket every 30 seconds and checked a Bot computer's wheel every second or two, for as long as it stayed open.

Proof

Red on main's hooks, green on this branch. I put back main's use-channel-events.ts, use-control.ts and control.ts, kept the tests, ran them, then restored the branch:

Test main branch
app/tests/stay-signed-in-browser.test.tsx, "signed out elsewhere while open": Playwright, Chromium and WebKit. It runs the real gate, frame, sidebar and wheel against a real HTTP and WebSocket server, which then refuses everything with OpenBot's 401 and closes the socket. The test checks that the tab lands on sign-in, and that across 2 minutes of the page's clock (Playwright page.clock.runFor, four times the 30-second backoff ceiling) there are no new upgrades, wheel reads or people/me reads. 2 of 2 fail (the tab never reaches sign-in) 2 pass; the whole file passes, 10 of 10
app/tests/signed-out-tab-stops.test.tsx, through the real hooks: a socket refused with nobody signed in stops and says so; one refused while signed in keeps reconnecting and asks only once; a stopped socket opens again after a sign-in; the wheel stops on OpenBot's 401; a proxy's 401 is still a missed read 4 of 5 fail (the wheel was read 4 times where 2 were expected; the socket never asked) 5 pass

I also ran the existing socket, wheel, gate and error-reporting suites (58 tests across 9 files), tsc --noEmit for the app, and biome on the changed files.

Screenshots: the sign-in screen the tab lands on, in Chromium and WebKit. It is the existing screen, unchanged.

A browser hides the 401 that refuses a WebSocket upgrade, so the
conversation events socket only saw it close and reconnected for ever,
backing off to 30 seconds. The read of a computer's wheel took OpenBot's
401 for a missed read and asked again every second or two. One person's
tab, signed out since the afternoon, did both for hours and never told
them (Cloud alert: conversation-events 401 at 25%).

- A socket refused before it opens asks once who is signed in (getPerson,
  the gate's own question), then no more than every 30 seconds. Nobody:
  it stops, and opens again only once somebody is signed in.
- The wheel's read stops on OpenBot's own 401, as it does for a Bot that
  is gone. A proxy's 401 is still only a missed read.
- Either way the app is told (SignedOutWatch), and the signed-in gate runs
  again: the sign-in screen, or Desktop's and the embed's own renewal.
- The socket names the app in an optional `client` query parameter, so a
  refused socket is logged with the app that asked.
@davidmckayv
davidmckayv force-pushed the fix/signed-out-tab-stops branch from 67e17d1 to be18d99 Compare December 2, 2026 21:18
@davidmckayv
davidmckayv added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 1c30c3f Dec 2, 2026
26 checks passed
@davidmckayv
davidmckayv deleted the fix/signed-out-tab-stops branch December 2, 2026 22:09
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.

1 participant