Skip to content

[AI] Run Actual in one browser tab at a time - #109

Merged
chrisvasz merged 1 commit into
masterfrom
claude/single-tab-lock
Oct 6, 2026
Merged

chrisvasz merged 1 commit into
masterfrom
claude/single-tab-lock

Conversation

@chrisvasz

Copy link
Copy Markdown
Owner

Replace the multi-tab SharedWorker coordinator with a "one tab at a time" model, ahead of the move from absurd-sql to sqlite-wasm/OPFS (where only one worker per origin can hold the databases).

  • Each tab requests the actual-backend Web Lock (ifAvailable: true) and holds it for the life of the page. If it gets the lock, it starts the backend in its own dedicated Worker, as iOS, Android and Playwright already did. If not, it starts no backend and shows "Already open in another tab" on the existing FatalError screen.
  • Deleted the coordinator, WorkerBridge, the SharedWorker entry, the OpenID-callback workaround, and the production importScripts retry that only existed because a failed load bricked the SharedWorker (dev keeps its retries). The SharedArrayBuffer/COOP/COEP code stays; absurd-sql still needs it.
  • The service worker now passes /gocardless/ through to the sync server, whose link page closes the bank-sync tab. Without this, that tab loaded the full app and showed the already-open message.

Deliberately left out: takeover, messaging between tabs, and auto-retry when the other tab closes.

Known limitations:

  • With no Web Locks (plain HTTP plus the SharedArrayBuffer override) or a rejected lock request, the check is skipped and every tab runs its own backend.
  • Bank-sync callbacks that land on the SPA instead of the sync server (Enable Banking when the frontend is served from a different origin, e.g. Vite dev on :3001) will show the already-open message. The GoCardless link still completes in the original tab, since it polls; Enable Banking's auth won't.
  • A tab whose backend failed to start still holds the lock, so other tabs show the already-open message rather than the real error.

Tested: yarn typecheck, yarn lint, loot-core and desktop-client unit tests. In a browser against the dev server: a second tab shows the message and starts no backend; after closing the first tab, reloading the second loads normally; reloading the only tab works. Not tested: Safari, the GoCardless and Enable Banking flows, and the production service worker. No unit tests cover the lock itself.

🤖 Generated with Claude Code

Replace the multi-tab SharedWorker coordinator with a single-tab model.
Each tab takes the "actual-backend" Web Lock (ifAvailable) before
starting its own dedicated backend Worker and holds it for the life of
the page. A tab that can't get the lock starts no backend and shows
"Already open in another tab" on the FatalError screen. If the lock
request rejects (storage blocked), start anyway so the real storage
error is shown.

Delete the coordinator, the WorkerBridge, the SharedWorker entry point,
the OpenID-callback workaround, and the production importScripts retry
that only existed because a failed load bricked the SharedWorker.

Let the service worker pass /gocardless/ through to the sync server,
whose link page closes the bank-sync tab; otherwise that tab loaded the
app and showed the already-open message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chrisvasz
chrisvasz force-pushed the claude/single-tab-lock branch from 09b936d to babf1ed Compare October 6, 2026 02:11
@chrisvasz
chrisvasz merged commit b8e244b into master Oct 6, 2026
8 checks passed
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