Skip to content

Add Tauri local API sidecar and desktop runtime routing with cloud fallback#46

Merged
koala73 merged 2 commits into
codex/add-tauri-v2-integration-and-configurationfrom
codex/implement-local-backend-process-with-tauri
Feb 13, 2026
Merged

Add Tauri local API sidecar and desktop runtime routing with cloud fallback#46
koala73 merged 2 commits into
codex/add-tauri-v2-integration-and-configurationfrom
codex/implement-local-backend-process-with-tauri

Conversation

@koala73

@koala73 koala73 commented Feb 13, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide a local backend for the Tauri desktop app so core functionality (news, summarization, markets, telemetry, status) does not require Vercel edge functions and can run offline or with reduced cloud dependency.
  • Minimize frontend changes by exposing the same /api/* paths locally and failing over to the cloud when handlers are missing or local execution fails.

Description

  • Add a Node sidecar local API server at src-tauri/sidecar/local-api-server.mjs that dispatches /api/* to existing api/*.js handlers when present and proxies to the cloud (https://worldmonitor.app) as a fallback.
  • Start/stop the sidecar with the Tauri app lifecycle by launching it from src-tauri/src/main.rs and managing the child process state.
  • Update Tauri configuration in src-tauri/tauri.conf.json to allow the local API origin (http://127.0.0.1:46123) in the CSP and to include ../api and sidecar/local-api-server.mjs as bundle resources.
  • Desktop runtime routing changes in src/services/runtime.ts: default desktop API base set to http://127.0.0.1:46123, added getRemoteApiBaseUrl() and an installRuntimeFetchPatch() function that patches fetch to route /api/* to the local sidecar with automatic cloud fallback.
  • Enable the runtime fetch patch at app start by calling installRuntimeFetchPatch() from src/main.ts.
  • Update ServiceStatusPanel (src/components/ServiceStatusPanel.ts) to render local backend status and to show clear messaging when the local backend is unavailable and the UI is using the cloud fallback.
  • Add documentation docs/local-backend-audit.md listing prioritized /api/* endpoints for desktop parity and describing the localization strategy.
  • Minor formatting run via cargo fmt adjusted src-tauri/build.rs.

Testing

  • npm run typecheck (tsc --noEmit) passed successfully.
  • cargo fmt completed successfully and reformatted src-tauri/build.rs where needed.
  • cargo check failed in this environment due to network restrictions while downloading crates index (environment-specific HTTP 403); this is unrelated to the code changes themselves.
  • Local sidecar smoke tests (automated invocation): launched node src-tauri/sidecar/local-api-server.mjs and verified GET /api/local-status and GET /api/service-status returned expected JSON responses (local status included), demonstrating the sidecar dispatch and health endpoints work in this environment.
  • Playwright screenshot attempt failed because the dev server was not reachable from the test environment (net::ERR_EMPTY_RESPONSE), so UI screenshot validation could not be completed here.

Codex Task

@vercel

vercel Bot commented Feb 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worldmonitor Ready Ready Preview, Comment Feb 13, 2026 5:08am
worldmonitor-startup Ready Ready Preview, Comment Feb 13, 2026 5:08am
worldmonitor-test Ready Ready Preview, Comment Feb 13, 2026 5:08am

Request Review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55189242bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/services/runtime.ts Outdated
Comment on lines +68 to +69
if (!url.startsWith('/api/')) {
return nativeFetch(input, init);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle absolute /api URLs in desktop fetch patch

installRuntimeFetchPatch() only applies local→cloud retry logic when url.startsWith('/api/'), but desktop callers that go through proxyUrl()/toRuntimeUrl() issue absolute URLs like http://127.0.0.1:46123/api/... and therefore skip this branch. In the exact scenario this change is meant to cover (sidecar not running, e.g. node missing or launch failure), those requests fail outright instead of falling back to cloud, so panels using fetchWithProxy lose data in desktop mode.

Useful? React with 👍 / 👎.

Comment thread src-tauri/sidecar/local-api-server.mjs Outdated
body,
});

return await mod.default(request);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fall back to cloud on local handler error responses

The sidecar only proxies to cloud when the handler throws, but it returns local non-OK responses directly (return await mod.default(request)). Several existing API handlers intentionally return 4xx/5xx when local secrets are missing (for example Groq-backed endpoints return 503), which means desktop users without those env vars get hard failures even though cloud fallback is available. This breaks the stated “local execution with cloud fallback” behavior for common endpoints.

Useful? React with 👍 / 👎.

@koala73
koala73 merged commit 7be050c into codex/add-tauri-v2-integration-and-configuration Feb 13, 2026
4 checks passed
@koala73
koala73 deleted the codex/implement-local-backend-process-with-tauri branch February 15, 2026 08:04
@SebastienMelki SebastienMelki added the area: desktop Tauri desktop app label Feb 17, 2026
facusturla pushed a commit to facusturla/worldmonitor that referenced this pull request Feb 27, 2026
…llback (koala73#46)

### Motivation
- Provide a local backend for the Tauri desktop app so core
functionality (news, summarization, markets, telemetry, status) does not
require Vercel edge functions and can run offline or with reduced cloud
dependency.
- Minimize frontend changes by exposing the same `/api/*` paths locally
and failing over to the cloud when handlers are missing or local
execution fails.

### Description
- Add a Node sidecar local API server at
`src-tauri/sidecar/local-api-server.mjs` that dispatches `/api/*` to
existing `api/*.js` handlers when present and proxies to the cloud
(`https://worldmonitor.app`) as a fallback.
- Start/stop the sidecar with the Tauri app lifecycle by launching it
from `src-tauri/src/main.rs` and managing the child process state.
- Update Tauri configuration in `src-tauri/tauri.conf.json` to allow the
local API origin (`http://127.0.0.1:46123`) in the CSP and to include
`../api` and `sidecar/local-api-server.mjs` as bundle resources.
- Desktop runtime routing changes in `src/services/runtime.ts`: default
desktop API base set to `http://127.0.0.1:46123`, added
`getRemoteApiBaseUrl()` and an `installRuntimeFetchPatch()` function
that patches `fetch` to route `/api/*` to the local sidecar with
automatic cloud fallback.
- Enable the runtime fetch patch at app start by calling
`installRuntimeFetchPatch()` from `src/main.ts`.
- Update `ServiceStatusPanel` (`src/components/ServiceStatusPanel.ts`)
to render local backend status and to show clear messaging when the
local backend is unavailable and the UI is using the cloud fallback.
- Add documentation `docs/local-backend-audit.md` listing prioritized
`/api/*` endpoints for desktop parity and describing the localization
strategy.
- Minor formatting run via `cargo fmt` adjusted `src-tauri/build.rs`.

### Testing
- `npm run typecheck` (`tsc --noEmit`) passed successfully.
- `cargo fmt` completed successfully and reformatted
`src-tauri/build.rs` where needed.
- `cargo check` failed in this environment due to network restrictions
while downloading crates index (environment-specific HTTP 403); this is
unrelated to the code changes themselves.
- Local sidecar smoke tests (automated invocation): launched `node
src-tauri/sidecar/local-api-server.mjs` and verified `GET
/api/local-status` and `GET /api/service-status` returned expected JSON
responses (local status included), demonstrating the sidecar dispatch
and health endpoints work in this environment.
- Playwright screenshot attempt failed because the dev server was not
reachable from the test environment (`net::ERR_EMPTY_RESPONSE`), so UI
screenshot validation could not be completed here.

------
[Codex
Task](https://chatgpt.com/codex/tasks/task_e_698ead50f548833398717fa3b8c92230)
@koala73 koala73 mentioned this pull request Mar 26, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: desktop Tauri desktop app codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants