Skip to content

Add option to run in production mode#15

Merged
achimala merged 4 commits intoachimala:mainfrom
dhvcc:feat/update-build
Mar 1, 2026
Merged

Add option to run in production mode#15
achimala merged 4 commits intoachimala:mainfrom
dhvcc:feat/update-build

Conversation

@dhvcc
Copy link
Contributor

@dhvcc dhvcc commented Mar 1, 2026

Personally, I wanted an option to run FE in production mode

I know the project is very much still in progress, but I can't really stand laggy UI especially on mobile, when I just want to use the app remotely

Lighthouse reports (ran multiple times to prevent random results)

bun run dev -- --agents=codex,opencode
Screenshot 2026-03-01 at 8 26 51 PM

bun run start
Screenshot 2026-03-01 at 8 27 31 PM

Summary by CodeRabbit

  • Documentation

    • Added production mode setup guide with simplified two-command deployment workflow and local endpoint defaults.
  • New Features

    • Production mode support with configurable backend API endpoint via FARFIELD_API_ORIGIN environment variable.
    • Added production start commands for streamlined deployment.

@coderabbitai
Copy link

coderabbitai bot commented Mar 1, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes introduce production mode deployment capabilities by establishing environment-based API endpoint configuration, adding production build and start scripts across package files, updating web dependencies, and documenting the two-command production workflow.

Changes

Cohort / File(s) Summary
Documentation
README.md
Adds "Production Mode (No Extra Proxy)" section detailing the two-command production flow (bun run build; bun run start), default local endpoint configuration (backend 127.0.0.1:4311, frontend 127.0.0.1:4312), and FARFIELD_API_ORIGIN override mechanism.
Production Scripts
package.json, apps/web/package.json
Root package.json adds start and start:prod scripts to run server and web apps in parallel. Web package.json adds start script for vite preview on 127.0.0.1:4312.
Build Configuration & Dependencies
apps/web/vite.config.ts, apps/web/package.json
Vite config implements zod-based environment validation for FARFIELD_API_ORIGIN, establishes apiOrigin constant with default fallback (http://127.0.0.1:4311), and replaces hardcoded proxy targets with dynamic apiOrigin value. Adds @farfield/protocol and workbox-window dependencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 The build scripts hop with glee,
Production flows now set and free!
Environment whispers through the air,
API origins handled with care.
From bun to vite, a config so bright,
The deployment path shines clear and right! 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a production mode option to run the frontend with improved performance, as evidenced by the Lighthouse scores in the PR description.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/web/vite.config.ts`:
- Around line 7-8: The env value assigned to apiOrigin
(process.env["FARFIELD_API_ORIGIN"] ?? "http://127.0.0.1:4311") is not validated
and may cause unclear runtime proxy errors; update vite.config.ts to validate
FARFIELD_API_ORIGIN with a Zod schema (e.g., z.string().url().optional()) and
use z.parse or safeParse to either accept the value or throw a clear startup
error, then set apiOrigin from the validated result (falling back to the default
only after successful validation) so the process fails fast with a descriptive
message if FARFIELD_API_ORIGIN is invalid.

In `@README.md`:
- Around line 46-51: Update the README text that currently reads “Build once and
run in production mode with one command:” to correctly state “with two
commands:” (or similar wording) since the snippet shows separate `bun run build`
and `bun run start` steps; locate the sentence near the code block containing
the `bun run build` and `bun run start` snippet and change the wording to
reflect two commands (or alternatively note how to run both with a single
combined command if you add a combined script).

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63ef59e and c301fbe.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • README.md
  • apps/web/package.json
  • apps/web/vite.config.ts
  • package.json

Reword instructions in README
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/codex-protocol/src/app-server.ts`:
- Around line 33-39: The RateLimit schemas currently call .passthrough() which
allows unknown fields; replace .passthrough() with .strict() on
RateLimitWindowSchema and the other rate-limit schema declarations referenced in
the review (the schemas at the other locations mentioned) so any extra fields
cause validation to fail; locate the RateLimitWindowSchema symbol (and the other
rate-limit schema symbols on the referenced lines) and change the terminal
.passthrough() call to .strict().

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efd5fd8 and c1c9623.

⛔ Files ignored due to path filters (3)
  • bun.lock is excluded by !**/*.lock
  • packages/codex-protocol/src/generated/app-server/GetAccountRateLimitsResponseSchema.ts is excluded by !**/generated/**
  • packages/codex-protocol/src/generated/app-server/index.ts is excluded by !**/generated/**
📒 Files selected for processing (3)
  • apps/web/package.json
  • apps/web/tsconfig.json
  • packages/codex-protocol/src/app-server.ts

@dhvcc
Copy link
Contributor Author

dhvcc commented Mar 1, 2026

Idk why the strict test fails to be honest. As funny as it is, works on my machine
Could be that some build artifacts need to be present

@achimala
Copy link
Owner

achimala commented Mar 1, 2026

FYI we now (as of like 10 seconds ago) automatically deploy production builds to https://farfield.app

I was also frustrated by this :)

Still have to run and expose the server via a VPN. Trying to come up with better solutions to this (I know there's the outstanding PR for Cloudflare tunneling - still looking into the best course of action here)

@achimala
Copy link
Owner

achimala commented Mar 1, 2026

Idk why the strict test fails to be honest. As funny as it is, works on my machine Could be that some build artifacts need to be present

I think these drifted with a couple merged PRs / my own recent work to re-align us to the latest Codex app-server schema. So don't worry about it, I'll get this sorted out…

@dhvcc dhvcc force-pushed the feat/update-build branch from 537737d to 6b18cae Compare March 1, 2026 22:18
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
package.json (1)

14-15: The start:prod alias is redundant but harmless.

start:prod simply calls start, providing no additional functionality. Consider removing it to reduce script clutter, or document why the alias exists (e.g., for discoverability in a particular workflow).

♻️ Optional: Remove redundant alias
     "start": "bun run --parallel --filter `@farfield/server` --filter `@farfield/web` start",
-    "start:prod": "bun run start",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 14 - 15, The package.json contains a redundant npm
script alias "start:prod" that simply invokes "start"; remove the "start:prod"
entry or, if you want to keep it for discoverability, add a comment in
documentation explaining its purpose; locate the "start" and "start:prod" script
entries in package.json and either delete the "start:prod" key or update project
docs to justify keeping it.
README.md (1)

82-86: Consider using a different example value for the override.

The FARFIELD_API_ORIGIN example uses the default value (http://127.0.0.1:4311), which doesn't illustrate a meaningful override. Consider showing a different host or port to clarify when this variable is actually needed.

📝 Suggested doc improvement
 If you need a custom backend origin for API proxying:

 ```bash
-FARFIELD_API_ORIGIN=http://127.0.0.1:4311 bun run start
+FARFIELD_API_ORIGIN=http://192.168.1.100:4311 bun run start
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @README.md around lines 82 - 86, Update the README example for
FARFIELD_API_ORIGIN so it uses a clearly different host/port to demonstrate an
actual override (e.g., replace the default http://127.0.0.1:4311 with an
external example like http://192.168.1.100:4311 or https://api.example.com:443);
locate the snippet that shows the environment variable FARFIELD_API_ORIGIN and
replace only the example value, keeping the surrounding command (bun run start)
unchanged and ensuring the new example makes it obvious when a custom backend
origin is required.


</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @package.json:

  • Around line 14-15: The package.json contains a redundant npm script alias
    "start:prod" that simply invokes "start"; remove the "start:prod" entry or, if
    you want to keep it for discoverability, add a comment in documentation
    explaining its purpose; locate the "start" and "start:prod" script entries in
    package.json and either delete the "start:prod" key or update project docs to
    justify keeping it.

In @README.md:

  • Around line 82-86: Update the README example for FARFIELD_API_ORIGIN so it
    uses a clearly different host/port to demonstrate an actual override (e.g.,
    replace the default http://127.0.0.1:4311 with an external example like
    http://192.168.1.100:4311 or https://api.example.com:443); locate the snippet
    that shows the environment variable FARFIELD_API_ORIGIN and replace only the
    example value, keeping the surrounding command (bun run start) unchanged and
    ensuring the new example makes it obvious when a custom backend origin is
    required.

</details>

---

<details>
<summary>ℹ️ Review info</summary>

**Configuration used**: defaults

**Review profile**: CHILL

**Plan**: Pro

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 537737d20445b40e21f327826641919817c2757a and 6b18caea6927384f37a418a54afc6ab0ccc3bf95.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `README.md`
* `package.json`

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@achimala achimala merged commit 4d7d5da into achimala:main Mar 1, 2026
1 of 2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Mar 1, 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.

2 participants