koala73 / koala73/worldmonitor
fix(desktop): two runtime detectors disagree — converge raw __TAURI__ checks on isDesktopRuntime()
- Dominant language
- TypeScript
- Stars
- 86.6k
- Forks
- 13.1k
- Avg merge
- 8h 4m
- Merged PRs (30d)
- 825
Description
## Summary
Two desktop-runtime detectors coexist and disagree:
- `isDesktopRuntime()` (`src/services/runtime.ts:97-113`) — used by ~130 call sites; true on `VITE_DESKTOP_RUNTIME === '1'`, Tauri globals, UA, `tauri:`/`asset:` protocols, `*.tauri.localhost`, or any `https://localhost`/`https://127.0.0.1` origin.
- Raw `'__TAURI_INTERNALS__' in window || '__TAURI__' in window` checks in `src/config/variant.ts:20`, `src/config/basemap.ts:9`, `src/main.ts:487,496`, `src/services/push-notifications.ts:42`, `src/utils/circuit-breaker.ts:55`.
The raw-globals sites behave as *web* during early boot under `npm run desktop:dev` (before the bridge attaches) and in `VITE_DESKTOP_RUNTIME=1` browser builds. Concrete split-brain: `SITE_VARIANT` resolves on the strict check (`variant.ts:20`) while the variant switcher writes the stored variant on the loose check (`src/app/event-handlers.ts:1594`).
## Ask
Converge the raw-globals call sites on `isDesktopRuntime()` (or a deliberate, documented strict variant for the few places that truly need "Tauri IPC available now"), and add a regression test for the desktop:dev early-boot path.
Found during the #5902 parity baseline audit (see `docs/desktop-parity-matrix.md`). Part of #5902.
Contributor guide
Research direction
Start with isDesktopRuntime() in src/services/runtime.ts:97-113, then inspect the raw-global checks in src/config/variant.ts, src/config/basemap.ts, src/main.ts, src/services/push-notifications.ts, and src/utils/circuit-breaker.ts. Add the requested regression coverage for the desktop:dev early-boot path, and consider the work done when these sites consistently use the intended detector without breaking the variant behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- tauri, typescript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100