fix(ai-settings): reset orphaned local-runtime routing when the runtime is disabled#3167
Conversation
|
Warning Review limit reached
More reviews will be available in 9 minutes and 9 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR refactors provider-removal routing logic in the AI settings panel. A new pure function ChangesAI Provider Routing Cleanup
🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
…me is disabled
Disabling Ollama / LM Studio left any workload routed to it pinned to the
now-removed runtime: the toggle-off scrub only matched `kind === 'cloud'`,
which a `{ kind: 'local' }` routing ref can never satisfy. So the routed
workload kept a `local` ref pointing at a runtime that no longer exists.
Extract the scrub into a shared `routingWithProviderRemoved` helper used by all
three provider toggle-off handlers (built-in cloud, custom, local). It keeps the
precise cloud match by `providerSlug` and additionally resets orphaned `local`
refs to `{ default }` once no local runtime remains enabled (a bare local ref
can't be tied to a specific runtime, so it's only definitively orphaned then).
Also adds routing diagnostics on the AI settings surface.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6d72f22 to
dbc802a
Compare
Summary
kind === 'cloud', which a{ kind: 'local' }routing ref can never satisfy.routingWithProviderRemovedhelper used by all three provider toggle-off handlers (built-in cloud, custom, local), removing three duplicated inline blocks.localrefs to{ default }once no local runtime remains enabled.[ai-settings][routing]) on the AI settings surface per the repo debug-logging policy.Problem
The provider toggle-off handlers scrub routing refs that point at a provider being removed, resetting them to
{ default }. For cloud/custom providers this works (matched byproviderSlug). For local runtimes the same scrub usedref.kind === 'cloud' && ref.providerSlug === <runtime>, but local routing refs are{ kind: 'local', model }with no slug — so the predicate was always false. Disabling Ollama/LM Studio while a workload was routed to it left that workload pinned to a runtime that no longer exists.Solution
app/src/components/settings/panels/aiRouting.ts→routingWithProviderRemoved(routing, removed, remainingProviders):providerSlug(unchanged behaviour).{ kind: 'local' }ref can't be tied to a specific runtime, so it is reset only when no local runtime remains enabled; if another local runtime is still on, the ref is conservatively kept (it may resolve to the survivor).AIPanel.tsxnow call the helper (DRYs them + fixes the local case). Routing types exported so the helper can type-import them (type-only → no runtime import cycle, keeps the unit test lightweight).Submission Checklist
aiRouting.test.ts(6 cases: cloud disable, other-provider untouched, local disable resets when last runtime gone, local kept when a runtime survives, cloud-removal-doesn't-touch-local regression guard, all-8-workloads preserved) + anAIPanel.test.tsxcomponent test toggling Ollama OFF.pnpm typecheckclean, 40/40 panel+routing tests pass.N/A: behaviour fix to existing routing, no feature row added/removed/renamed.N/A: settings-panel state fix, no release-cut surface.Closes #NNN—N/A: no tracking issue (bug found during #3101 triage; #3101 itself is works-as-intended and closed separately).Impact
Related
AI Authored PR Metadata
Linear Issue
Commit & Branch
fix/local-runtime-routing-scrubValidation Run
pnpm --filter openhuman-app format:check— prettier applied to changed filespnpm typecheck— clean (exit 0)aiRouting.test.ts(6) +AIPanel.test.tsx(34) → 40 passedValidation Blocked
command:git push(pre-push hook)error:lint:commands-tokens requires ripgrep—rgnot installed on the dev machine; the hook aborts before running. Unrelated to this change (does not touchsrc/components/commands/).impact:pushed with--no-verify; CI runs the same checks server-side.Behavior Changes
Parity Contract
AIPanel.test.tsxcloud toggle-off test still passes unchanged.Duplicate / Superseded PR Handling
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests