Skip to content

Resolve frontend assets at runtime in release bundles#38

Merged
GordonBeeming merged 2 commits into
mainfrom
gb/fix-prod-frontend-dist
Jun 26, 2026
Merged

Resolve frontend assets at runtime in release bundles#38
GordonBeeming merged 2 commits into
mainfrom
gb/fix-prod-frontend-dist

Conversation

@GordonBeeming

Copy link
Copy Markdown
Owner

Summary

  • Fixes the production app showing "Build the web assets with npm run build, then reload." when opening a workspace. The HTTP server resolved its asset directory from the compile-time CARGO_MANIFEST_DIR, so a CI-built binary looked for dist at the build machine's checkout (/Users/runner/work/ide/ide/dist), which doesn't exist on a user's machine, and the assets were never copied into the bundle anyway.
  • Bundle dist as a Tauri resource (tauri.conf.json) so the web assets ship inside the .app.
  • Resolve the serve directory at runtime from the app's resource dir via a new resolve_frontend_dist helper, falling back to the source-tree path for cargo run / tauri dev.

Test plan

  • npm run tauri:check — config validator passes
  • cargo test resolve_frontend_dist — 3 new resolver unit tests pass
  • npm run tauri:build — bundle builds; ide.app/Contents/Resources/dist/index.html present
  • Live: launched the built binary against a workspace, workspace route serves the real SPA (<div id="root"> + hashed JS asset 200s), zero "Build the web assets" hits
  • Dev fallback intact (manifest-relative path when resources aren't staged)

The HTTP server resolved its web-asset directory from the compile-time
`CARGO_MANIFEST_DIR`, so a binary built in CI looked for `dist` at the
build machine's checkout path (e.g. `/Users/runner/work/ide/ide/dist`),
which doesn't exist on a user's machine. The landing page still rendered
because it's server-side Rust, but opening a workspace served the SPA from
the missing path and fell back to the "Build the web assets" message. The
assets were never copied into the bundle either.

Bundle `dist` as a Tauri resource and pick the serve directory at runtime
from the app's resource dir, falling back to the source-tree path for
`cargo run` / `tauri dev`.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
@GordonBeeming GordonBeeming marked this pull request as ready for review June 26, 2026 11:29
Copilot AI review requested due to automatic review settings June 26, 2026 11:29

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to dynamically resolve the frontend assets directory at runtime instead of relying solely on the compile-time CARGO_MANIFEST_DIR path, which is unreliable in release bundles. It adds a resolve_frontend_dist helper function that checks the app's resource directory for bundled assets (falling back to the source-tree path for development), integrates it into the application startup, updates the Tauri bundle configuration to include the dist folder as a resource, and adds comprehensive unit tests. There are no review comments, and the changes look solid, so I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes release bundles failing to serve the built SPA when opening a workspace by bundling dist into the Tauri app resources and resolving the HTTP server’s frontend asset directory at runtime (instead of using the compile-time CARGO_MANIFEST_DIR path that points to the CI/build machine).

Changes:

  • Bundle ../dist into the Tauri app as a named resource (dist) for release builds.
  • Add a resolve_frontend_dist helper to prefer the bundled resource dir at runtime, with a dev fallback to the source-tree dist.
  • Add unit tests covering the resolver’s resource-dir and fallback behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src-tauri/tauri.conf.json Adds dist to bundle resources so web assets ship inside the app bundle.
src-tauri/src/lib.rs Resolves frontend assets directory at runtime and adds unit tests for the resolver.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src-tauri/src/lib.rs
Address PR review feedback: when the resource dir has no staged assets
and the baked `CARGO_MANIFEST_DIR` path doesn't exist (a relocated bundle
or unstaged resources in a release build), fall back to a resource-dir
path instead of the build machine's checkout. Only use the manifest path
when it actually exists on disk, which is the dev / `cargo run` case.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
@GordonBeeming GordonBeeming merged commit e12f9f6 into main Jun 26, 2026
2 of 4 checks passed
@GordonBeeming GordonBeeming deleted the gb/fix-prod-frontend-dist branch June 26, 2026 11:43
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.

2 participants