Skip to content

fix(app): run local API calls while the browser reports offline - #1208

Open
vincentfranstyo wants to merge 2 commits into
jamiepine:mainfrom
vincentfranstyo:fix/local-api-offline-networkmode
Open

vincentfranstyo wants to merge 2 commits into
jamiepine:mainfrom
vincentfranstyo:fix/local-api-offline-networkmode

Conversation

@vincentfranstyo

@vincentfranstyo vincentfranstyo commented Oct 18, 2026 •

Copy link
Copy Markdown

With Wi-Fi off, pressing Generate spun forever and the backend never received POST /generate; the request went out the moment the network came back. TanStack Query pauses every new request while the browser reports offline, but Voicebox's backend is a local sidecar that never needed the network. Local API calls now run regardless of that flag.

Fixes #1085

Before (upstream/main) After
Generate button stuck spinning with "Generating…" tooltip, no request sent Generate button idle again, request sent and form reset

Red box: the Generate button after one click while the page reports offline. Before: stuck spinner and no POST /generate. After: the request was sent and the form reset.

Try it: 1. Start the app with a cached model. 2. Turn Wi-Fi off (or run window.dispatchEvent(new Event('offline')) in the devtools console). 3. Click Generate. The generation starts instead of spinning.

Note: The Tauri and web entry points each built their own QueryClient with a copy of the app's defaults, so a fix to the shared client alone would not have reached the desktop app. Both now import the shared one. Side effect: the server-URL change handler already invalidated the shared client; in the desktop and web builds that was a different instance from the one rendering, so it was a no-op there. It now works.

Trade-off for remote-server mode (a non-loopback server URL, or the Docker web UI): with networkMode: 'always' a request made while the browser reports offline is sent at once and fails with a fetch error (then one retry) instead of pausing and resuming when the network returns, and TanStack's refetchOnReconnect is off, so a query that failed offline waits for its stale time or interval rather than refetching on reconnect. Fail-fast with a visible error seemed better than a silent spinner in both modes; scoping the mode per server URL is possible if you would rather keep the pause for remote servers.

Tests and plan check
  • Unit: n/a, the repo has no frontend test runner. Standalone check against the installed @tanstack/react-query 5.90.20:
    default client      : status=pending isPaused=true requestSent=false
    networkMode 'always': status=success isPaused=false requestSent=true
    
  • Integration: n/a, no backend change.
  • End-to-end: Playwright drove the web build against a stub backend, dispatched the offline event, clicked Generate:
    before-fix: POST /generate sent=0 spinner=true
    after-fix:  POST /generate sent=1 spinner=false
    
    Chromium's own offline emulation was not used because it also blocks loopback; the offline event alone is what flips TanStack's online manager, matching the reporter's situation.
  • tsc for app and web: clean. vite build for the Tauri frontend: clean. Biome clean on the three touched files (the two entry points had pre-existing import-order errors that the second commit fixes, since this PR rewrote those blocks).
  • Each acceptance criterion from the plan is met; proof: AC1 diff, AC2 screenshots and logs above, AC3 command runs above, AC4 grep 'new QueryClient' finds one site.
  • Plan was challenged by an independent reviewer before building, and the open PR was reviewed again by a second one; the E2E method, the remote-mode trade-off note and the import fix came from those reviews.
  • Not verified here: that macOS WKWebView fires offline on Wi-Fi off (the reporter's symptom implies it does). Linux host, no Tauri desktop run.

🤖 Generated with Claude Code using the ship-pr workflow

vincentfranstyo and others added 2 commits October 18, 2026 14:49
TanStack Query's default networkMode ('online') pauses every new fetch and
mutation while navigator.onLine is false. The backend is a local sidecar on
127.0.0.1, so with Wi-Fi off the Generate button spun forever and POST
/generate was only sent once the network came back (jamiepine#1085).

Set networkMode: 'always' for queries and mutations on the shared
QueryClient, and make the Tauri and web entry points use that client
instead of their own copies. As a side effect, serverStore's
invalidateQueries() on server-URL change now hits the client the app
actually renders with in those builds.

Fixes jamiepine#1085

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Biome's organizeImports flagged these blocks; the previous commit rewrote
them, so fix the ordering here instead of leaving a known failure behind.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
doublesharp added a commit to doublesharp/voicebox-ds that referenced this pull request Oct 29, 2026
Use the shared QueryClient for offline requests, preserve custom server URLs through startup and migration, retain capture decode diagnostics, preserve refinement language, accept supported STT languages, and explain LuxTTS short-input errors. Adapt upstream PRs jamiepine#1208, jamiepine#1204, jamiepine#1219, jamiepine#1218, jamiepine#1198, jamiepine#1199, jamiepine#1220 and jamiepine#1180; retain remote reconnect refreshes and correctly migrate the legacy bundled port.

Wait for the preview output context to resume before playing. Cancel superseded starts and release preview nodes/object URLs on replacement, completion, failure and unmount. Add CI regressions for the upstream integration and preview lifecycle.

Validation: 292 frontend tests on this candidate; 414 frontend tests with the working UI changes; 53 backend tests; app/web/Tauri frontend typechecks and both frontend builds. Independent review accepted the playback change. Native first-click/autoplay, acoustic output, packaging and model quality remain unverified.

Co-authored-by: vincentfranstyo <66989751+vincentfranstyo@users.noreply.github.com>
Co-authored-by: maxazure <405711+maxazure@users.noreply.github.com>
Co-authored-by: FelixKruger <262215022+FelixKruger@users.noreply.github.com>
Co-authored-by: Tony25032 <141424750+Tony25032@users.noreply.github.com>
Co-authored-by: mvoloch <274143174+mvoloch@users.noreply.github.com>
Co-authored-by: Lvigentini <11659311+Lvigentini@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

Offline generation stuck in spinner: POST /generate is paused until Wi-Fi returns

1 participant