feat: add Bun runtime support with cross-platform binary builds#622
feat: add Bun runtime support with cross-platform binary builds#622pcfreak30 wants to merge 4 commits intohotovo:mainfrom
Conversation
Summary of ChangesHello @pcfreak30, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the application's deployment flexibility by introducing full support for the Bun runtime and its capability to produce cross-platform standalone binaries. The changes involve a complete overhaul of how resources are managed, how the database interacts with different runtimes, and how the application is built and initialized, ultimately enabling a more efficient and portable distribution model without compromising existing Electron/Node.js functionality. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive support for the Bun runtime, enabling cross-platform binary builds. The changes are extensive and well-executed. Key highlights include a new bunup.config.ts for multi-platform compilation, a robust embedded resource system in bun-resources.ts featuring a clever CWD workaround with mutex protection, and a well-designed refactoring of data-manager.ts using the adapter pattern to support both bun:sqlite and better-sqlite3. The startup logic and server initialization have also been updated effectively for the Bun environment. The overall implementation is solid. I've provided a few suggestions to enhance code cleanliness and robustness. Excellent work on this complex feature.
| * @param content The content of the message. | ||
| */ | ||
| public saveMessage(id: string, type: 'tool' | 'assistant', project: string, model: string, usageReport: UsageReportData | undefined, content: unknown): void { | ||
| public async saveMessage( |
There was a problem hiding this comment.
The function has been made async, but the callers were not updated. Consider using await or void there.
| * @param to End date | ||
| * @returns Array of usage data rows | ||
| */ | ||
| public async queryUsageData(from: Date, to: Date): Promise<UsageDataRow[]> { |
There was a problem hiding this comment.
Please verify that UsageDashboard works after the change.
src/main/bun-resources.ts
Outdated
| } | ||
|
|
||
| // List of text resources to extract (must match what's embedded in build script) | ||
| const textResources = [ |
There was a problem hiding this comment.
This is not very maintainable approach. We will need to manage this manually whenever anything changes in the resources.
src/main/start-up.ts
Outdated
| const destConnectorPath = path.join(AIDER_DESK_CONNECTOR_DIR, 'connector.py'); | ||
| fs.copyFileSync(sourceConnectorPath, destConnectorPath); | ||
|
|
||
| if (isBunBinary()) { |
There was a problem hiding this comment.
There is a logic in paths.ts file to determine value RESOURCE_DIR. I think the isBunBinary conditioning should go there instead.
|
|
||
| if (fs.existsSync(sourceMcpServerDir)) { | ||
| const files = fs.readdirSync(sourceMcpServerDir); | ||
| if (isBunBinary()) { |
There was a problem hiding this comment.
It would be better to extract this as separate file with all the special start up logic for Bun.
There was a problem hiding this comment.
Or maybe have helper function copyResourceFile that will decide how to copy the file, so the this file does not have to know about the Bun.
package.json
Outdated
| "postbuild:server": "npm rebuild", | ||
| "build": "npm run typecheck && electron-vite build && npm run build:mcp", | ||
| "build": "npm run typecheck && npm run build:renderer && npm run build:mcp", | ||
| "build:renderer": "electron-vite build", |
There was a problem hiding this comment.
This is not really only renderer but the whole app with renderer and main.
tsconfig.json
Outdated
| "baseUrl": ".", | ||
| "paths": { | ||
| "@/*": [ | ||
| "src/main/*" |
There was a problem hiding this comment.
This is not correct in the context of tsconfig.web.json.
There was a problem hiding this comment.
@wladimiiir this is kind of required. bunup removed needing a custom build script but I cannot reasonably get it to use a custom tsconfig that doesnt create weird build time race conditions.
I have tried and it was better to give in and put the alias in the default config.
| "compilerOptions": { | ||
| "composite": true, | ||
| "types": ["electron-vite/node"], | ||
| "types": ["electron-vite/node", "bun"], |
There was a problem hiding this comment.
Can we have separate tsconfig.bun.json file instead to keep this clean?
There was a problem hiding this comment.
@wladimiiir no, bunup requires the default config and I could not get it to listen otherwise... despite me RE'ing the code and figuring out where it passes the tsconfig data.
There was a problem hiding this comment.
@wladimiiir no, bunup requires the default config and I could not get it to listen otherwise... despite me RE'ing the code and figuring out where it passes the tsconfig data.
This problem seems to be resolved and im reviewing the other issues.
wladimiiir
left a comment
There was a problem hiding this comment.
Please see my comments.
Add comprehensive support for building and running AiderDesk as compiled Bun binaries across multiple platforms (Linux x64/arm64, macOS x64/arm64, Windows x64). Key changes: - Add bunup.config.ts for multi-platform Bun binary compilation - Implement embedded resource system with mutex-protected I/O operations - Add bun-resources.ts for resource extraction, caching, and renderer file serving - Refactor data-manager.ts with adapter pattern supporting bun:sqlite and better-sqlite3 - Update startup and server initialization for Bun binary environment - Add platform-specific binary and resource path handling - Add build scripts for Bun: build:bun, build:bun:all, and platform-specific targets - Add dependencies: bunup, @types/bun, simple-git-hooks - Update TypeScript configurations for Bun types and path mappings
- Remove unused readFileSync import from build config - Add error logging to catch block for better debugging - Simplify typeAssertions in database adapters to use ISqliteStatement interface
- Extract Bun startup logic to dedicated bun-startup.ts module - Implement dynamic resource discovery using glob instead of hardcoded lists - Add fallback resource mechanism for reliability - Create copyResourceFile helper to abstract Bun vs filesystem access - Add setupMcpServerForBun and setupAiderConnectorForBun helpers - Fix async dataManager.init() call with proper await - Fix async dataManager.saveMessage() calls (await for assistant, void for tool) - Rename build:renderer to build:app for clarity - Remove duplicate code from start-up.ts - Fix all func-style linting errors by converting to arrow expressions - Fix @typescript-eslint/no-explicit-any errors with proper type interfaces
469ba35 to
f7c1697
Compare
Add comprehensive support for building and running AiderDesk as compiled Bun binaries across multiple platforms (Linux x64/arm64, macOS x64/arm64, Windows x64).
Key changes:
Notes:
simple-git-hooksis forced in b/cbunupmakes some weird devtools assumptions and errors if its not in$PATH. Added this simply to ensure no build issues.CWD. Probably not bulletproof, but it should defensively guard against most things.