Skip to content

fix: clear llmConfig when all LLM presets are deactivated#490

Merged
nashsu merged 1 commit into
nashsu:mainfrom
AndrewDongminYoo:fix/clear-llm-config-on-preset-deactivate
Jun 28, 2026
Merged

fix: clear llmConfig when all LLM presets are deactivated#490
nashsu merged 1 commit into
nashsu:mainfrom
AndrewDongminYoo:fix/clear-llm-config-on-preset-deactivate

Conversation

@AndrewDongminYoo

Copy link
Copy Markdown
Contributor

Problem

When the user toggles off the last active LLM preset, toggleActive() sets activePresetId to null and calls persist(providerConfigs, null). Inside persist(), the if (newActive) block is skipped, so setLlmConfig() and saveLlmConfig() are never called.

The result: llmConfig in the store still holds the previous provider's config. Background queues (ingest-queue, dedup-queue, sweep-reviews, clip-watcher) all guard themselves with hasUsableLlm(llmConfig), which reads from the un-updated llmConfig and continues to return true — so processing carries on even though the user explicitly disabled all providers.

This is most visible with keyless providers (Claude Code CLI, Codex CLI, Ollama): turning them off has no observable effect on ingest.

Fix

Add an else branch to persist() that, when newActive === null, writes llmConfig to a state where hasUsableLlm() returns false:

} else {
  const cleared: LlmConfig = { ...llmConfig, provider: "openai", apiKey: "" }
  setLlmConfig(cleared)
  await saveLlmConfig(cleared)
}

Setting provider to "openai" (a keyed provider) and clearing apiKey makes hasUsableLlm() return false regardless of what the previous provider was — including keyless local CLI providers that hasUsableLlm would otherwise always pass.

resolveConfig() is safe: on re-enable it reads provider and apiKey from providerConfigs[newActive] (the user's saved per-preset settings), not from llmConfig, so the cleared values here do not affect the user's stored configuration.

Testing

  1. Configure any LLM preset (including a keyless one like Claude Code CLI).
  2. Start an ingest run.
  3. Toggle the active preset off — the toggle turns grey and activePresetId becomes null.
  4. Observe that in-progress tasks complete but no new tasks are picked up from the queue.
  5. Toggle the same preset back on — processing resumes with the correct config.

When the last active preset is toggled off, persist() only saved
activePresetId=null but never updated llmConfig. Background queues
(ingest, dedup, sweep) call hasUsableLlm(llmConfig), which still
saw the previous provider's config and continued running.

Add an else branch that resets provider/apiKey to a state where
hasUsableLlm() returns false, pausing all queue processing.
resolveConfig() on re-enable reads from providerConfigs[], so the
cleared values do not corrupt the user's saved per-provider settings.
@nashsu nashsu merged commit 5a55600 into nashsu:main Jun 28, 2026
3 checks passed
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.

2 participants