Repository navigation
fix(desktop): bundle a single pi-ai copy so OAuth refresh works when packaged - #438
Merged
Merged
Conversation
…packaged
bun's isolated install can give Pace's direct pi-ai import and
pi-coding-agent's pi-ai different peer-hash directories. In v0.1.0 the
registerBunOAuthFlows() call landed on the copy nobody read, rollup
tree-shook it, and pi-coding-agent's loaders fell back to a runtime
import("./radius.js") that does not exist in app.asar, so every expired
OAuth token (Radius, Codex, Copilot, ...) failed with "Cannot find module".
Resolve every @earendil-works import through pi-coding-agent so the graph
shares one copy, fail the build if a Pi package is duplicated or the OAuth
loader registry is tree-shaken out, and cover the refresh path end to end
in the shipped-bundle suite.
4 tasks done
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
3 tasks done
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.
Summary
OAuth refresh failed for radius: Cannot find module '.../app.asar/out/main/chunks/radius.js', and the UI showed it as "Provider authentication failed". With bun's isolated install, Pace's direct import of@earendil-works/pi-aiand pi-coding-agent's own pi-ai resolved to two different peer-hash copies (0.99.1+c02ada…vs0.99.1+d95c98…).registerBunOAuthFlows()registered on copy A, which nothing reads, so rollup tree-shook the call entirely. Copy B'sbundledLoaderswas never assigned, so it fell back to the runtimeimport("./radius.js"), and that file is not in the asar. This hits every OAuth provider: Radius, Codex, ChatGPT, Copilot, OpenRouter, Kimi, Meta, xAI, Anthropic.bun install --frozen-lockfile). The OAuth loader in the output is identical line-for-line to the shipped asar, and there are 0 registration symbols.dedupePiPackages()resolves every@earendil-works/*import as if pi-coding-agent made it, so the whole graph shares one copy per package. Packageexportssubpaths keep working.assertSinglePiPackageCopy()fails the build if a Pi package is bundled from more than one directory, or if the OAuth loader registry is missing from the emitted code. The moduleId check alone does not catch the v0.1.0 failure, so the emitted-code markers are required. Confirmed on v0.1.0: the build fails without dedupe and passes with it.scripts/test-bundled-runtime.mjs, which runs inbuild:release. It sets up an expired Radius OAuth credential plus a mock gateway, prompts in the session process, and asserts: the refresh_token grant reaches the gateway, nothing says "Cannot find module", the chat request carries the new token, and auth.json is updated.Test plan
registerBunOAuthFlows()commented out, the new test fails with exactly the production error (red)node --test scripts/test-bundled-runtime.mjs4/4 (green)bun run build/typecheck/lint