Skip to content

Guard remaining unguarded Tauri calls for web deployments - #3190

Open
jefflitt1 wants to merge 2 commits into
block:mainfrom
jefflitt1:upstream-web-tauri-guards
Open

Guard remaining unguarded Tauri calls for web deployments#3190
jefflitt1 wants to merge 2 commits into
block:mainfrom
jefflitt1:upstream-web-tauri-guards

Conversation

@jefflitt1

@jefflitt1 jefflitt1 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • Several call sites into @tauri-apps/api still assume a native Tauri runtime and throw when the desktop chat UI is served as a plain web page instead (no window.__TAURI_INTERNALS__): "Cannot read properties of undefined (reading 'transformCallback'/'invoke')". Most of the codebase already guards this correctly with isTauri() before calling listen()/invoke() (e.g. audioWorklet.ts); this fixes the remaining gaps, found by exercising a web-served build end-to-end.
  • useAgentsDataRefresh, usePreventSleep, useNestNotifications, HuddleContext, HuddleBar, HuddleIndicator, MobilePairingCard: guard listen() registration with isTauri().
  • deep-link.ts: drainPendingCommunityDeepLinks() calls invoke() directly (not via the listen()-based subscription already guarded in this file) to read the Rust-side pending-deep-link queue, which only exists in the native shell — guard it the same way.
  • tauri.ts: isSharedIdentity() is called unconditionally at app boot, before any other Tauri-availability gate — guard it to resolve to false in a web runtime instead of throwing.
  • legacyCommunityStorage.ts: the legacy Sprout WebKit SQLite database read only exists in the native shell — skip it in a web runtime.

All of these failures were already caught (logged as console warnings, not uncaught exceptions), so this doesn't change behavior for native Tauri users — it just removes console noise and dead invoke attempts when the same bundle is served as a website.

Independent of #3189, but both were found while exercising the same web-served build.

Test plan

  • pnpm build (tsc + vite build) passes
  • pnpm test — 3662/3662 passing
  • pnpm exec biome check on all 10 touched files — clean
  • Manually verified in a browser: served the built bundle as a plain web page outside Tauri and confirmed the console is fully clean (previously showed 3 warnings on every load)

Related

Checked open PRs/issues for duplicates before submitting — no duplicate found. #3027 is open in an adjacent but different subsystem (relay-side SPA routing config, vs. this PR's desktop-client Tauri guards) for a similarly-motivated self-hosted deployment; not overlapping, noted for context.

Several call sites into @tauri-apps/api still assume a native Tauri
runtime and throw when the desktop chat UI is served as a plain web
page instead (no window.__TAURI_INTERNALS__): "Cannot read properties
of undefined (reading 'transformCallback'/'invoke')". Most of the
codebase already guards this correctly with isTauri() before calling
listen()/invoke() (e.g. audioWorklet.ts); these were the remaining
gaps, found by exercising a web-served build end-to-end:

- useAgentsDataRefresh, usePreventSleep, useNestNotifications,
  HuddleContext, HuddleBar, HuddleIndicator, MobilePairingCard: guard
  listen() registration with isTauri().
- deep-link.ts: drainPendingCommunityDeepLinks() calls invoke()
  directly (not via the listen()-based subscription already guarded
  in this file) to read the Rust-side pending-deep-link queue, which
  only exists in the native shell — guard it the same way.
- tauri.ts: isSharedIdentity() is called unconditionally at app boot,
  before any other Tauri-availability gate — guard it to resolve to
  `false` in a web runtime instead of throwing.
- legacyCommunityStorage.ts: the legacy Sprout WebKit SQLite database
  read only exists in the native shell — skip it in a web runtime.

All of these failures were already caught (logged as console warnings,
not uncaught exceptions), so this doesn't change behavior for native
Tauri users — it just removes console noise and dead invoke attempts
when the same bundle is served as a website.
@jefflitt1
jefflitt1 requested a review from a team as a code owner July 27, 2026 19:34
getDefaultRelayUrl/autoConnectDefaultRelayEnabled are called
unconditionally by useCommunityInit's "no active community yet" branch
on every boot, but that branch already wraps both calls in its own
try/catch and falls back to needsSetup:true — so this is a console-
noise reduction, not a behavior fix.

setPreventSleepActive is different: usePreventSleep.ts calls it
fire-and-forget (two call sites, both `void setPreventSleepActive(...)`)
with no .catch of its own, so reaching invokeTauri here was a genuine
unhandled promise rejection in a web (non-Tauri) runtime, not just
noise.
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