Skip to content

Fix justfile mod conflicts and prod build env loading - #24

Closed
kixelated wants to merge 3 commits into
mainfrom
fix/justfile-mod-conflict-and-build-env
Closed

kixelated wants to merge 3 commits into
mainfrom
fix/justfile-mod-conflict-and-build-env

Conversation

@kixelated

@kixelated kixelated commented Apr 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

This PR predates the current justfile layout. Current main already resolves the module/default-recipe conflicts, and its live app build selects the correct API environment.

Approach

No additional runtime or environment change is recommended. The remote source remains at 4331055. A local conflict-resolution checkpoint was preserved without pushing it.

Impact

No new source changes were pushed. No public API or wire change.

Alternatives

Keep the current bun vite build --mode live recipe. Forcing Vite to run under Bun reproduces the environment leak, but current main does not force that runtime. Adding --bun and then compensating with NODE_ENV=production adds behavior without a current requirement.

Validation

At unchanged 171ed63:

  • bun vite build --mode live embeds https://api.hang.live and no http://localhost:3000, with the Nix shell's Bun 1.3.1 and with the migration's Bun 1.4.2.
  • The same existing recipe with NODE_ENV=development still embeds the correct live API.
  • bun --bun vite build --mode live reproduces the localhost API leak.
  • just --dry-run dev and just --dry-run native resolve the existing module/default recipes. Neither service was started.
  • quest gate just build passes.
  • quest gate just check passes API/app TypeScript, Biome, and both metadata tests, then fails at native formatting because this host has no real Cargo behind its wrapper. The unchanged-base and local merged-head runs both report mbx[error]: could not find the real Cargo after excluding /home/kixelated/.local/share/mbx/bin/cargo. moq-dev/hang.live#32 already adds the explicit Rust toolchain.

Review

No new source head was pushed or submitted for local review. The original PR head is not ready to land; the current implementation need is superseded.

Waiting

  • Maintainer: close this PR as superseded (recommended), or retain it if forcing Bun as the build runtime is a new requirement. Closing requires the maintainer's explicit choice; the current build already meets the original goal.

(Written by GPT-6.1 Sol with xhigh)

kixelated and others added 2 commits April 17, 2026 08:26
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Rename `mod dev` to `mod relay "dev"` in the root justfile so it no
  longer collides with the top-level `dev:` recipe. The dev/ directory
  contains relay tooling, so `just relay root` / `just relay auth-token`
  are semantically clearer anyway.
- Remove the top-level `native:` recipe and add `default: dev` to
  native/justfile so `just native` still runs the Tauri dev app without
  clashing with `mod native`.
- Drop `--bun` from `bun vite build`. Bun's runtime auto-loads
  .env.development into process.env, which shadows Vite's --mode-based
  env resolution and caused the production build to ship
  `http://localhost:3000` as `VITE_API_URL`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Walkthrough

The pull request updates configuration and task automation across multiple files. The staging environment variable RELAY_URL in api/wrangler.jsonc is changed to a different endpoint. In app/justfile, the dev task is modified to use bun --bun runtime invocation, and build documentation is clarified. The root justfile refactors module organization by renaming the dev module reference to relay "dev", updating corresponding task invocations, removing the standalone native recipe, and restructuring concurrent task execution to include separate api and app development tasks. A default recipe is added to native/justfile to set dev as the default command.

Pre-merge checks: Passed 2

Check name Status Explanation
Title check Passed The title accurately summarizes the two main changes: renaming justfile module declarations to resolve conflicts and fixing production build environment loading.
Description check Passed The description addresses justfile conflicts and Vite environment loading, which relate to the changes.
Finishing Touches

🧪 Generate unit tests (beta)

  • Create PR with unit tests
  • Commit unit tests in branch fix/justfile-mod-conflict-and-build-env
✨ Simplify code

  • Create PR with simplified code
  • Commit simplified code in branch fix/justfile-mod-conflict-and-build-env
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
app/justfile (2)

22-23: Confirm --bun is intentional only for dev.

bun --bun vite dev keeps Bun as the runtime here, which means .env.development is auto-loaded into process.env. That's fine for dev (mode is development anyway), but worth noting the asymmetry with build — if dev ever needs --mode overrides, the same shadowing bug will resurface. A short comment mirroring the one above would help future readers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/justfile` around lines 22 - 23, Add a short comment above the dev target
explaining that the dev task intentionally runs "bun --bun vite dev" to use Bun
as the runtime so .env.development is auto-loaded into process.env, and note the
asymmetry with the build target (which does not use --bun) and the potential for
future "--mode" overrides to reintroduce env shadowing; reference the dev target
and the "bun --bun vite dev" command so future readers understand this is
deliberate and where to change it if they need consistent behavior with build.

11-14: Build fix looks correct; consider asserting it in CI.

Dropping --bun from bun vite build is the right fix — Bun's auto-loading of .env.development into process.env was shadowing Vite's --mode-based resolution and leaking VITE_API_URL=http://localhost:3000 into prod bundles. To prevent regressions, consider a tiny post-build grep in the deploy recipe (e.g., fail if localhost:3000 appears in dist/) so a future re-introduction of --bun here is caught immediately.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/justfile` around lines 11 - 14, Add a CI-safe assertion to catch
reintroduction of Bun's env leakage by extending the build/deploy flow: in the
existing just recipe named build env="development" (or in the deploy recipe that
runs after it) add a post-build check that searches the generated dist/ files
for the string "localhost:3000" and fails the recipe (exit non-zero) if found;
implement this as a simple grep/ack command with a clear error message so future
changes that re-add `--bun` or otherwise leak development URLs will break CI
immediately.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/justfile`:
- Around line 22-23: Add a short comment above the dev target explaining that
the dev task intentionally runs "bun --bun vite dev" to use Bun as the runtime
so .env.development is auto-loaded into process.env, and note the asymmetry with
the build target (which does not use --bun) and the potential for future
"--mode" overrides to reintroduce env shadowing; reference the dev target and
the "bun --bun vite dev" command so future readers understand this is deliberate
and where to change it if they need consistent behavior with build.
- Around line 11-14: Add a CI-safe assertion to catch reintroduction of Bun's
env leakage by extending the build/deploy flow: in the existing just recipe
named build env="development" (or in the deploy recipe that runs after it) add a
post-build check that searches the generated dist/ files for the string
"localhost:3000" and fails the recipe (exit non-zero) if found; implement this
as a simple grep/ack command with a clear error message so future changes that
re-add `--bun` or otherwise leak development URLs will break CI immediately.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: defc2bec-64a2-4af9-8f44-d88a6ffd90c5

📥 Commits

Reviewing files that changed from the base of the PR and between 1a8d7b5 and 27e8edb.

📒 Files selected for processing (4)
  • api/wrangler.jsonc
  • app/justfile
  • justfile
  • native/justfile

Bun's auto-dotenv only loads .env.development when NODE_ENV is unset or
"development". Setting NODE_ENV=production before `bun --bun vite build`
points the auto-loader at the nonexistent .env.production, leaving
process.env clean so Vite's --mode resolution wins. This matches what
Vite does internally for any `vite build` invocation anyway.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as draft November 7, 2026 17:18

Copy link
Copy Markdown
Collaborator Author

Rechecked the original goal on current main. The existing bun vite build --mode live bundle uses https://api.hang.live, with Bun 1.3.1 and 1.4.2; forcing the Bun runtime with --bun reproduces the localhost leak. Current main also already resolves the module/default conflicts, so I recommend closing this PR as superseded rather than introducing --bun plus an environment override.

The old dev-runtime comment is superseded because the current dev recipe remains unchanged. I am declining a blanket post-build ban on localhost:3000: the default development build intentionally uses a local API. Validation here compared the selected live-mode URL directly.

The PR is now a draft awaiting the maintainer's close-or-retain decision. No source changes were pushed.

(Written by GPT-6.1 Sol with xhigh)

Copy link
Copy Markdown
Collaborator Author

Closing as superseded, following the maintainer's delegated choice to use the recommended course. Current main already resolves the module/default conflicts and its live build embeds https://api.hang.live with both tested Bun versions. Forcing Bun's runtime recreates the localhost leak; adding that runtime requirement is unnecessary. The reproduction and comparison are recorded in the evidence comment.

(Written by GPT-6.1 Sol with xhigh)

@kixelated kixelated closed this Nov 7, 2026
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.

1 participant