Add Tauri v2#45
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91808461ab
ℹ️ 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".
| export async function fetchWithProxy(url: string): Promise<Response> { | ||
| return fetch(url); | ||
| return fetch(proxyUrl(url)); |
There was a problem hiding this comment.
Route all
/api fetches through the desktop bridge
The desktop runtime rewrite is opt-in via fetchWithProxy, but many existing callsites still use raw fetch('/api/...') / fetch(API_URLS...) (for example src/services/ucdp-events.ts, src/services/climate.ts, and src/components/ServiceStatusPanel.ts), and src-tauri/tauri.conf.json does not configure a local API server for packaged apps. In desktop builds those requests target the app origin (app://.../api/...) and fail, so substantial parts of the app will not load data.
Useful? React with 👍 / 👎.
| const variant = import.meta.env.VITE_VARIANT || 'world'; | ||
| return DEFAULT_REMOTE_HOSTS[variant] ?? DEFAULT_REMOTE_HOSTS.world ?? 'https://worldmonitor.app'; |
There was a problem hiding this comment.
Allow Tauri origins before using remote API hosts
Desktop mode now rewrites API calls to https://worldmonitor.app / https://tech.worldmonitor.app, but the API CORS layer only allows https://*.worldmonitor.app, Vercel preview domains, and http://localhost (api/_cors.js), and handlers such as api/finnhub.js explicitly return 403 when isDisallowedOrigin(req) is true. Tauri WebView origins (for example tauri://localhost or app://localhost) are outside that allowlist, so rewritten desktop API requests will be blocked unless CORS is updated.
Useful? React with 👍 / 👎.
…llback (#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)
Codex generated this pull request, but encountered an unexpected error after generation. This is a placeholder PR message. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_698eb29a0bc48333b9bf8c07362391e5)
…el freshness badges (#48) ### Motivation - Ensure the app remains useful when cloud APIs are unreachable by providing durable local fallbacks and clearer UI indicators for stale/offline data. - Persist recent feed items, latest computed risk snapshots, and stale-tolerant map overlays for desktop builds so a packaged app can operate without network. - Surface data freshness and whether values are `live`, `cached`, or `unavailable` in panels so analysts understand what they are seeing. ### Description - Add a desktop-aware persistent cache service (`src/services/persistent-cache.ts`) that uses Tauri `invoke` commands (`read_cache_entry` / `write_cache_entry`) with `localStorage` as a fallback for non-desktop runtimes. - Extend the Tauri backend (`src-tauri/src/main.rs`) to provide file-backed JSON cache storage under app data and register `read_cache_entry` and `write_cache_entry` handlers. - Wire persistent fallbacks into runtime services: RSS feeds (`src/services/rss.ts`), cached risk scores (`src/services/cached-risk-scores.ts`), earthquake overlay data (`src/services/earthquakes.ts`), and the Insights world-brief snapshot (`src/components/InsightsPanel.ts`). - Enhance circuit-breaker semantics in `src/utils/circuit-breaker.ts` to track `BreakerDataState` (modes: `live` / `cached` / `unavailable`) and detect desktop offline mode so callers can show more precise status and use cached fallbacks. - Add panel-level data-state badges and helpers in `src/components/Panel.ts` and apply them to `NewsPanel`, `InsightsPanel`, and `StrategicRiskPanel`, plus styling in `src/styles/main.css`. - Include static resources in desktop bundle config by adding `../data` and `../src/config` to `src-tauri/tauri.conf.json` so pre-bundled datasets are available in production desktop builds. ### Testing - Ran `npm run typecheck` (`tsc --noEmit`) which completed successfully. - Started the dev server and exercised the UI; captured a screenshot demonstrating panel freshness badges (artifact recorded during the run). - `cargo check` could not complete in this environment due to network/crates.io access being blocked (error: CONNECT tunnel failed / 403), so native Rust/Tauri build verification was not possible here. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_698eb89d5b448333b14174125f76d3c4)
Codex generated this pull request, but encountered an unexpected error after generation. This is a placeholder PR message. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_698eecffdf0c833382ac8f5a79fd8090)
…on (#54) ### Motivation - Make Tauri/Rust dependency resolution reproducible in restricted-network CI or offline environments by providing a documented vendored source option. - Surface two supported packaging flows (online and restricted-network) in the release docs so packagers know how to provision offline inputs. - Improve validation reporting to distinguish external registry outages from failures caused by missing offline artifacts so QA results are actionable. - Allow committing `Cargo.lock` for `src-tauri` once generated by removing it from the local `.gitignore` so dependency graphs can be pinned. ### Description - Added `src-tauri/.cargo/config.toml` defining a `vendored-sources` replacement that points to `src-tauri/vendor/` and included inline instructions to `cargo vendor` for populating it. - Updated `docs/RELEASE_PACKAGING.md` with a new section describing two Rust dependency modes and example commands for (1) the standard online build and (2) a restricted-network build that uses vendored crates or an internal mirror. - Updated `docs/TAURI_VALIDATION_REPORT.md` to classify failures into **External environment outage** and **Expected failure: offline mode not provisioned**, with guidance for both. - Modified `src-tauri/.gitignore` to stop ignoring `Cargo.lock` so a lockfile can be generated and committed when network or vendored artifacts are available. ### Testing - Ran `cd src-tauri && cargo generate-lockfile`, which failed due to blocked access to `https://index.crates.io` with `403 CONNECT tunnel failed` (environmental network restriction). - Ran `cd src-tauri && cargo generate-lockfile --offline`, which failed as expected because `src-tauri/vendor/` was not provisioned (`no matching package named keyring found`). - No additional automated tests were run on the modified files; documentation and config changes were validated by applying the edits and confirming file contents. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_698ef3d2ac2c8333b576f1c85e6004a1)
### Motivation - Reduce main bundle pressure by splitting large third-party libraries into logical chunks to improve load/ caching behavior during production builds. - Keep documentation accurate and ensure assets referenced from `docs/` resolve correctly. ### Description - Replaced static `manualChunks` object in `vite.config.ts` with a function-based splitter that creates `ml` for ML deps (`@xenova/transformers`, `onnxruntime-web`), `map` for map/visualization deps (`@deck.gl`, `maplibre-gl`, `h3-js`), and preserves dedicated `d3` and `topojson` chunks. - Updated `docs/DOCUMENTATION.md` to bump the version badge to `2.1.4` and fixed the dashboard image path to `../new-world-monitor.png` so it loads when viewing files from the `docs/` folder. - Changes applied to `vite.config.ts` and `docs/DOCUMENTATION.md` and committed to the current branch. ### Testing - Ran `npm run typecheck` and it completed successfully. - Ran `npm run build` and the production build succeeded; rollup emitted warnings about `eval` in a dependency and some chunks >500 kB but build artifacts were produced. - Ran `npm run test:e2e:full` which failed in this environment because Playwright browser binaries are not installed (error: `Executable doesn't exist ... chromium_headless_shell`). ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_698f0083f99083338bf9ea2ebbefd191)
- koala73#34: Remove isProUser() guard from setupAuthWidget(). New users now see the sign-in button and can create accounts. The guard was intentionally deferred; removing it is the stated end-state. Close stale todos whose fixes already landed in prior PRs: - koala73#10: inferEntityClassFromName word-boundary regex (already in code) - koala73#11: entity key collision fix using candidateStateId (already in code) - koala73#12: priorWorldState threading to writeSimulationPackage (already in code) - koala73#13: sanitizeForPrompt on simulation builder strings (already in code) - koala73#14: allForecastIdSet Set-based lookup (already in code) - koala73#35: algorithms:['RS256'] in jwtVerify (already in auth-session.ts) - koala73#41: frameworkHash in deduct-situation cache key (already in code) - koala73#42: isCallerPremium server-side premium gate (already in code) - koala73#43: SSRF — ALLOWED_AGENTSKILLS_HOSTS + redirect:manual (already fixed) - koala73#44: sanitizeForPrompt on systemAppend before LLM (already in code) - koala73#45: systemAppend included in getCacheKey (already in code) - koala73#49: shippingStress/diseaseOutbreaks/socialVelocity in BOOTSTRAP_KEYS https://claude.ai/code/session_015fz1MvRuBJGYbgHubGEabA
Motivation
src/as the web frontend.deck.gl,maplibre-gl) to run inside the Tauri WebView by adding an appropriate CSP and mirroring it in the Tauri config.Description
src-tauri/includingCargo.toml,build.rs,src/main.rs,capabilities/default.json,.gitignore, andtauri.conf.jsonwithbuild.frontendDistset to../distandbuild.devUrlset tohttp://localhost:5173.desktop:dev,desktop:build:full, anddesktop:build:techinpackage.jsonto run Tauri vianpx @tauri-apps/cli(no dependency added to lockfile here due to environment constraints).src/services/runtime.tsto detect Tauri desktop runtime (isDesktopRuntime) and compute an API base URL per variant with safe fallbacks, and updatedsrc/utils/proxy.tsto use that runtime bridge (toRuntimeUrl) and adjustfetchWithProxybehavior.index.htmland mirrored the CSP insrc-tauri/tauri.conf.jsonto allowconnect-src,worker-src, WebSocket, blob/data sources, andwasm-unsafe-evalneeded by WebGL and worker-based libs.Testing
npm run build(TypeScript + Vite production build) which initially failed on a type error and was fixed insrc/services/runtime.ts, after whichnpm run buildcompleted successfully.npx @tauri-apps/cli --versionto validate the Tauri CLI, but this was blocked in the environment by npm registry policy (403 Forbidden).Codex Task