fix(gemini): route LLM calls through Rust to stop 'Load failed'#2
Merged
Conversation
Gemini's generateContent call was the only external HTTP request made via the WebKit webview's fetch(). The webview drops large/slow requests with a generic 'Load failed' error — which surfaced as 'Fout op <datum>: Load failed' on heavy days. Every other API call (Simplicate) already goes through a Rust reqwest command via invoke() to avoid exactly this. Add a gemini_request Tauri command (reqwest) mirroring simplicate_request, with retry/backoff on transient failures (network errors, HTTP 429, 5xx) and an injectable Sleeper so the retry loop is unit-tested without waiting. GeminiRepository now calls it via invoke() instead of fetch(); the TS layer maps the surfaced error onto a user-facing message (quota / unreachable / API error). - 8 Rust unit tests cover success, 429+retryDelay, 5xx backoff, retry exhaustion, non-retryable 4xx, network retry/recovery. - GeminiRepository tests now mock invoke; retry assertions moved to Rust. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
It was only used by the test helpers, triggering an unused_imports warning in non-test builds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Probleem
Bij het classificeren van een dag verscheen "Fout op : Load failed" (bv.
2026-03-09). "Load failed" is de generieke fout die Tauri's WebKit-webview gooit als een browser-fetchmislukt.Oorzaak:
GeminiRepositorywas de énige externe HTTP-call die via de webview-fetchliep. De webview kapt grote/trage requests af (gemini-2.5-flash op een drukke dag duurt lang + grote prompt) → "Load failed". Elke andere call (Simplicate) gaat al via een Rustreqwest-command (invoke) en heeft dit probleem niet. Bovendien werd er niet geretried op netwerkfouten — alleen op 429.Fix (beide aanpakken, zoals besproken)
gemini_requestTauri-command (reqwest), spiegel vansimplicate_request.GeminiRepository.callGeminigebruikt nuinvoke()i.p.v.fetch(). Geen webview-fetch meer → geen "Load failed".retryDelay. Een injecteerbareSleepermaakt de retry-loop testbaar zonder echt te wachten.De TS-laag mapt de uiteindelijke fout op een nette melding (quota uitgeput / niet bereikbaar / API-fout).
Tests
cargo test→ 56 groen.GeminiRepository.test.tsmockt nuinvoke; retry-asserties verplaatst naar Rust. Volledige suite 808 groen, coverage 99.6% / 98.2% / 100%.🤖 Generated with Claude Code