fix: pass API key for gemini/openai/openrouter in generate_candidates - #26
Open
looksg00d wants to merge 1 commit into
Open
Conversation
The activeKey resolution in confirmImport() and moments() only handled the "claude" and "deepseek" llmEngine cases, falling through to an empty string for "gemini", "openai", and "openrouter". As a result, selecting one of those providers and entering its API key in Settings had no effect: generate_candidates always received apiKey: null, and the backend fell back to the OPENROUTER_API_KEY/GEMINI_API_KEY/etc. env var, failing with e.g. "Set OPENROUTER_API_KEY or supply OpenRouter API Key to generate candidates." even though the key was set in the UI. runAutoPipeline() already has the correct per-provider key mapping a few lines above; this mirrors that same mapping in both call sites of generate_candidates.
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.
Bug
Selecting Gemini, OpenAI, or OpenRouter as the LLM provider in Settings and entering an API key there has no effect on moment detection — it still fails with:
(or the equivalent for
GEMINI_API_KEY/OPENAI_API_KEY), even though the key is set in the UI, and even though the.envvar isn't set at all.Root cause
In
src/main.tsx, both call sites ofgenerate_candidates(inconfirmImport()andmoments()) resolve the outgoingapiKeywith:This only handles
claudeanddeepseek; forgemini,openai, andopenrouterit silently falls through to""→ sent asapiKey: null→ the Rust side (lib.rs,generate_candidates) then only has the env var to fall back on, and errors if it isn't set.Note
runAutoPipeline()already has the correct full mapping a few lines above (used just for the pre-flight "is a key configured" check), it just was never mirrored into the two actualinvoke("generate_candidates", ...)calls.Fix
Mirror the same per-provider key mapping used in
runAutoPipeline()into bothgenerate_candidatescall sites:Test plan
Ran into this myself with an OpenRouter key set only in Settings (no
.env) — reading through the code confirmedactiveKeywas resolving to""for theopenroutercase, which matched the symptom exactly. The fix just mirrors the mapping already used (and working) inrunAutoPipeline()a few lines above onto the two call sites that were missing it, so the logic itself isn't new/untested, just newly applied in these two spots. I have not personally re-run the full pipeline end-to-end against Gemini/OpenAI/OpenRouter after applying the fix to confirm candidate generation succeeds — flagging that in case a maintainer wants to verify before merging.