Repository navigation
Replace extension RPC with the SDK shared session - #197
Open
callumalpass wants to merge 1 commit into
Open
callumalpass wants to merge 1 commit into
callumalpass wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reader's extension no longer serializes
Mdbaseand Reader repository calls through its own offscreen RPC bridge. Every extension-origin context creates an SDK entry with one build identity and calls it directly; the SDK owns the shared Worker, replica, sign-in and transport.session: { build, host: false }, follows visibility, opens sign-in throughchrome.tabs.create, and borrows Reader repositories from its own current connection.setForeground(false). It serves no application RPC.A UUID generated once per Vite build is passed to every page and the separately built background bundle. Rebuilt artifacts cannot accidentally join an old build. The service worker is now an ES module: the SDK validates
import.meta.url, which a classic IIFE cannot provide. The obsoleteimportScriptspage-status loader is deleted. Reader's fetch overrides remain in both page mounting and the page-status worker.Deleted the app RPC channel and lifetime lock, command allowlists, method proxies, snapshot/error/argument serialization, callback/abort dispatch, host/client implementations, memory bus and bridge tests. Regenerated catalogs to remove the five deleted bridge messages. The one remaining host-lifecycle message only asks the service worker to create the offscreen document; visible entries ask again when the SDK re-enters
startingafter host loss. No SDK calls or record data cross that message.The SDK's tab group elects a host with Web Locks and tunnels its ports over BroadcastChannel; its entry binds module/current/declaration origins. BroadcastChannel is same-origin and storage-partition scoped; content-script isolation does not move the web document onto the extension origin. Content scripts therefore do not join this session and need no repository message path. The service worker does join:
host: falseskips the Worker requirement. Chrome supports static module service-worker imports, but not dynamic imports.Added a Chromium test that builds two separate SDK bundles, starts the non-hosting context first, proves only one original SDK Worker runs, opens the same local unsynced replica, reads writes in both directions and verifies closing the follower leaves the host usable. Only registration is intercepted; original pinned Worker/WASM/SQLite bytes run unchanged, and every other external request is refused. CI runs it after installing Chromium. Unit fixtures additionally cover independent adapter generations and two clients of one memory replica.
Validation on
794d9b85(Node 22.22.0, pnpm 10.7.0; finite checks/builds throughrpnpm):pnpm install --frozen-lockfilerpnpm checkrpnpm test:workspacesrpnpm --pull apps/reader/dist build:productionMDBASE_ENV=production pnpm build.rpnpm --pull apps/extension/dist --filter @mdbase-reader/extension packageMDBASE_ENV=production pnpm --filter @mdbase-reader/app manifest;MDBASE_ENV=production pnpm --filter @mdbase-reader/extension manifest:mdbase;test -z "$(git status --porcelain)"pnpm --filter @mdbase-reader/extension test:browserpnpm --filter @mdbase-reader/app test:pdf-touchpnpm --filter @mdbase-reader/app test:html-svgrpnpm --pull apps/reader/dist --filter @mdbase-reader/app build:feedback-test;node .scratch/feedback-suite.mjs(invokespnpm --filter @mdbase-reader/app test:feedbackagainst an owned loopback preview)rpnpm check:release-downloads;rpnpm test:release-downloadsPackaged-extension smoke:
node .scratch/extension-smoke.mjsuses Playwrightchromium.launchPersistentContextwith--disable-extensions-exceptand--load-extensionagainst the packaged productiondist. Options, welcome and capture render; one offscreen document is created; the module service worker exposes Web Locks, BroadcastChannel and OPFS, and has noWorkerconstructor. No uncaught page errors or external requests. The owned profile/browser was removed/closed.Limits: the production package declares the store origin
chrome-extension://kimdfjefhbfgfecconmaiaaindjccidp, while local Chromium assigns the unpacked artifactchrome-extension://ciielciajpkmeignjfaicgpnlpilogai. The SDK refuses that registration binding before sign-in. Authenticated sign-in, connected-library opening and a real capture save were not verified. This smoke and the intercepted local-replica test do not establish authenticated extension or log-durability acceptance. No trust policy, app origin or SDK pin was changed to bypass it.Behavior to review: selections now belong to each context; saved-page lookup follows the last ready page selection. The module background parses its SDK code on wake-up instead of importing it later, while SDK construction/startup remain on demand. Capture-create follow-through and its in-memory journal now last for the originating context's lifetime; pending replica writes still belong to the shared Worker, but automatic renaming after a later path refusal only follows while that context stays open. These changes are documented in the topic page and changelog fragment. No other product or SDK gaps were found.
packages/connectis untouched for the concurrent legacy-removal lane.