Repository navigation
perf(agent-runtime): split sidecar bundle - #1284
Merged
Merged
Conversation
The release entry was a single 7.8 MB file even though trusted extensions and native Pi sessions are optional. Split the ESM output and load those heavy modules only when their features are used. Build into a staging directory and replace the generated bundle only after esbuild succeeds, keeping stale hashed chunks out of releases without discarding the previous bundle on build failure.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The lazy-loading and staged bundle changes preserve existing contracts and have focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Splits the agent sidecar into lazy-loaded ESM chunks while preserving its stable packaged entry point.
Changes:
- Lazy-loads native session and trusted-extension implementations.
- Adds staged bundle replacement with hashed chunks.
- Expands lifecycle and packaged-bundle regression coverage.
| File | Description |
|---|---|
packages/agent-runtime/src/sidecar.ts |
Lazily loads the native Pi service. |
packages/agent-runtime/src/runtime.ts |
Lazily loads and deduplicates extension runner initialization. |
packages/agent-runtime/src/native-pi-session.ts |
Re-exports the extracted session prefix. |
packages/agent-runtime/src/native-pi-session-id.ts |
Defines the lightweight session prefix constant. |
packages/agent-runtime/src/extensions/runtime-lifecycle.test.ts |
Tests concurrent lazy extension loading. |
packages/agent-runtime/src/extensions/loader.ts |
Updates split-bundle documentation. |
packages/agent-runtime/src/extensions/bundle.test.ts |
Tests split ESM extension loading. |
packages/agent-runtime/scripts/bundle.mjs |
Implements staged, hashed bundle generation. |
packages/agent-runtime/package.json |
Routes bundling through the new script. |
apps/desktop/test/agent-runtime-bundle-package.test.mjs |
Verifies packaging, chunk replacement, and sidecar startup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch was previously 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.
Summary
sidecar.jsas the release entry.Validation
pnpm --filter @pi-desktop/agent-runtime typecheckpnpm -C packages/agent-runtime exec vitest run --testTimeout=60000(82 files, 1,155 tests)node --test apps/desktop/test/agent-runtime-bundle-package.test.mjs(build and process smoke outsidenode_modules)pnpm lint:biomepnpm check:pr-base