From c2998f1a6b836c3455d3e5f7ec2959a2d5b1dfbf Mon Sep 17 00:00:00 2001 From: "shumeiko.it" Date: Tue, 27 Oct 2026 14:20:05 +0100 Subject: [PATCH] fix(web): say when the primary model has no key and which model chats use (UF-054) Settings showed the configured primary while the status bar showed the model new chats fall back to, so the two screens disagreed. Model Pilot now says the primary needs a key and names the model in use. --- apps/web/src/components/os/ModelPilotCard.tsx | 25 ++++++++ .../src/components/os/apps/SettingsApp.tsx | 11 ++++ .../test/model-pilot-primary-note.test.tsx | 61 +++++++++++++++++++ docs/oss/upstream-fixes.md | 10 +++ 4 files changed, 107 insertions(+) create mode 100644 apps/web/src/test/model-pilot-primary-note.test.tsx diff --git a/apps/web/src/components/os/ModelPilotCard.tsx b/apps/web/src/components/os/ModelPilotCard.tsx index 4e91559..df2c17b 100644 --- a/apps/web/src/components/os/ModelPilotCard.tsx +++ b/apps/web/src/components/os/ModelPilotCard.tsx @@ -22,6 +22,9 @@ interface ModelPilotCardProps { budgetThreshold: number; dailyBudget: number | null; providers: Provider[]; + /** The model new chats actually run on (the server falls back from a primary + * it cannot use). Shown when it differs from an unusable primary. */ + activeModel?: string | null; onUpdate: (fields: { defaultModel?: string; fallbackModel?: string | null; @@ -184,6 +187,13 @@ const LaneDropdown = ({ const resolveModelName = (modelId: string | null, providers: Provider[]): string => modelId ? formatModelLabel(modelId, providers) : 'Not set'; +/** True when the model's provider needs an API key that the vault lacks. */ +const needsKey = (modelId: string | null, providers: Provider[]): boolean => { + if (!modelId) return false; + const provider = providers.find(p => p.models.some(m => m.id === modelId)); + return !!provider && provider.requiresKey && !provider.hasKey; +}; + /** Resolve cost tier for a model id */ const resolveModelCost = (modelId: string | null, providers: Provider[]): string | null => { if (!modelId) return null; @@ -240,6 +250,7 @@ const ModelPilotCard = ({ budgetThreshold, dailyBudget, providers, + activeModel = null, onUpdate, }: ModelPilotCardProps) => { const [singleMode, setSingleMode] = useState(false); @@ -281,6 +292,15 @@ const ModelPilotCard = ({ const visibleLanes = singleMode ? LANES.slice(0, 1) : LANES; + // A primary without its key never answers: the server routes new chats to a + // usable model instead, which the status bar shows. Say so here, or the two + // screens name different "default" models (UF-054). + const primaryNote = needsKey(defaultModel || null, providers) + ? activeModel && activeModel !== defaultModel + ? `Needs an API key. New chats use ${formatModelLabel(activeModel, providers)} until you add one.` + : 'Needs an API key before it can answer.' + : null; + // kw (Wave S): when the fallback can never fire (== primary), offer a // one-click switch to a strictly-cheaper usable model — only if one really // exists in the catalog. Null hides the suggestion (no invented models). @@ -359,6 +379,11 @@ const ModelPilotCard = ({ {lane.label}

{lane.description}

+ {lane.key === 'primary' && primaryNote && ( +

+ {primaryNote} +

+ )} diff --git a/apps/web/src/components/os/apps/SettingsApp.tsx b/apps/web/src/components/os/apps/SettingsApp.tsx index 321fe75..721989c 100644 --- a/apps/web/src/components/os/apps/SettingsApp.tsx +++ b/apps/web/src/components/os/apps/SettingsApp.tsx @@ -72,6 +72,16 @@ const SettingsApp = () => { const [fallbackModel, setFallbackModel] = useState(null); const [budgetModel, setBudgetModel] = useState(null); const [budgetThreshold, setBudgetThreshold] = useState(0.8); + // The model new chats run on after the server's usable-model fallback. + const [activeModel, setActiveModel] = useState(null); + useEffect(() => { + let cancelled = false; + Promise.resolve() + .then(() => adapter.getModel()) + .then(model => { if (!cancelled) setActiveModel(model || null); }) + .catch(() => { /* the note under Primary is optional */ }); + return () => { cancelled = true; }; + }, [defaultModel]); const [dailyBudget, setDailyBudget] = useState(''); const [saving, setSaving] = useState(false); const [saveMsg, setSaveMsg] = useState(''); @@ -602,6 +612,7 @@ const SettingsApp = () => { budgetThreshold={budgetThreshold} dailyBudget={dailyBudget ? parseFloat(dailyBudget) : null} providers={providers} + activeModel={activeModel} onUpdate={(fields) => { if (fields.defaultModel !== undefined) setDefaultModel(fields.defaultModel); if (fields.fallbackModel !== undefined) setFallbackModel(fields.fallbackModel); diff --git a/apps/web/src/test/model-pilot-primary-note.test.tsx b/apps/web/src/test/model-pilot-primary-note.test.tsx new file mode 100644 index 0000000..16ba090 --- /dev/null +++ b/apps/web/src/test/model-pilot-primary-note.test.tsx @@ -0,0 +1,61 @@ +/** + * UF-054: Settings named Claude Sonnet as the primary model while the status bar + * said new chats use Llama. Both were true: the primary had no key, so the + * server fell back to a usable model. Model Pilot now says so under Primary. + */ +import { describe, it, expect, afterEach } from 'vitest'; +import { render, screen, cleanup } from '@testing-library/react'; +import ModelPilotCard from '@/components/os/ModelPilotCard'; +import { TooltipProvider } from '@/components/ui/tooltip'; +import type { Provider } from '@/hooks/useProviders'; + +afterEach(cleanup); + +function providers(anthropicHasKey: boolean): Provider[] { + return [ + { + id: 'anthropic', name: 'Anthropic', hasKey: anthropicHasKey, badge: null, keyUrl: null, requiresKey: true, + models: [{ id: 'claude-sonnet-4-6', name: 'Claude Sonnet 4.6', cost: '$$', speed: 'fast' }], + }, + { + id: 'ollama', name: 'Ollama', hasKey: false, badge: null, keyUrl: null, requiresKey: false, + models: [{ id: 'ollama/llama3.1:8b', name: 'Llama3.1 (8b)', cost: 'FREE', speed: 'medium' }], + }, + ]; +} + +function renderCard(anthropicHasKey: boolean, activeModel: string | null) { + render( + + {}} + /> + , + ); +} + +describe('Model Pilot primary note (UF-054)', () => { + it('names the model new chats use when the primary has no key', () => { + renderCard(false, 'ollama/llama3.1:8b'); + expect(screen.getByTestId('model-pilot-primary-note')).toHaveTextContent( + 'Needs an API key. New chats use Llama3.1 (8b) until you add one.', + ); + }); + + it('still flags a keyless primary when the active model is unknown', () => { + renderCard(false, null); + expect(screen.getByTestId('model-pilot-primary-note')).toHaveTextContent('Needs an API key before it can answer.'); + }); + + it('says nothing when the primary has its key', () => { + renderCard(true, 'claude-sonnet-4-6'); + expect(screen.queryByTestId('model-pilot-primary-note')).not.toBeInTheDocument(); + }); +}); diff --git a/docs/oss/upstream-fixes.md b/docs/oss/upstream-fixes.md index ba39b47..7dc498b 100644 --- a/docs/oss/upstream-fixes.md +++ b/docs/oss/upstream-fixes.md @@ -82,6 +82,7 @@ Baseline: commit `b20b138` of `git.os-dev.tech/oleg.m/waggle-os`. | UF-051 | The memory recall step looks unfinished after the answer | Fixed | Sidecar, chat, memory | | UF-052 | Home offers the same workspace twice | Fixed | Web UI | | UF-053 | The user's chat bubble is squared on the wrong corner | Fixed | Web UI, chat | +| UF-054 | Settings and the status bar name different default models | Fixed | Web UI, models | ## Entries @@ -535,3 +536,12 @@ Entries UF-010 to UF-019 come from the UI audit `anti-slop/audit-001-2026-10-14. - Cause: the four-value radius puts the 4px corner first, which is the top left. - What we did: the radius is `rounded-[14px_4px_14px_14px]`, so the square corner is the top right. A chat test checks it. - Recommendation: apply the same change in the main project. + +### UF-054. Settings and the status bar name different default models +- Status: Fixed +- Found: 2026-10-26 +- Where: at commit `b20b138`, `apps/web/src/components/os/ModelPilotCard.tsx:361` (the Primary lane) and `apps/web/src/components/os/StatusBar.tsx:160` ("Default model:") +- Symptom: Settings → Models shows Claude Sonnet 4.6 as the primary model, while the status bar says "Default model: Llama3.1 (8b)". +- Cause: both are true. The primary has no API key, so the server's usable-model check routes new chats to the local model, and the status bar shows that model. Model Pilot only shows the configured primary and never says it cannot answer. +- What we did: when the primary's provider needs a key the vault lacks, Model Pilot says so under Primary and names the model new chats use until a key is added. Settings reads that model from the server. A test covers the keyless, unknown and keyed cases. +- Recommendation: apply the same change in the main project.