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.
This commit is contained in:
@@ -22,6 +22,9 @@ interface ModelPilotCardProps {
|
|||||||
budgetThreshold: number;
|
budgetThreshold: number;
|
||||||
dailyBudget: number | null;
|
dailyBudget: number | null;
|
||||||
providers: Provider[];
|
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: {
|
onUpdate: (fields: {
|
||||||
defaultModel?: string;
|
defaultModel?: string;
|
||||||
fallbackModel?: string | null;
|
fallbackModel?: string | null;
|
||||||
@@ -184,6 +187,13 @@ const LaneDropdown = ({
|
|||||||
const resolveModelName = (modelId: string | null, providers: Provider[]): string =>
|
const resolveModelName = (modelId: string | null, providers: Provider[]): string =>
|
||||||
modelId ? formatModelLabel(modelId, providers) : 'Not set';
|
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 */
|
/** Resolve cost tier for a model id */
|
||||||
const resolveModelCost = (modelId: string | null, providers: Provider[]): string | null => {
|
const resolveModelCost = (modelId: string | null, providers: Provider[]): string | null => {
|
||||||
if (!modelId) return null;
|
if (!modelId) return null;
|
||||||
@@ -240,6 +250,7 @@ const ModelPilotCard = ({
|
|||||||
budgetThreshold,
|
budgetThreshold,
|
||||||
dailyBudget,
|
dailyBudget,
|
||||||
providers,
|
providers,
|
||||||
|
activeModel = null,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
}: ModelPilotCardProps) => {
|
}: ModelPilotCardProps) => {
|
||||||
const [singleMode, setSingleMode] = useState(false);
|
const [singleMode, setSingleMode] = useState(false);
|
||||||
@@ -281,6 +292,15 @@ const ModelPilotCard = ({
|
|||||||
|
|
||||||
const visibleLanes = singleMode ? LANES.slice(0, 1) : LANES;
|
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
|
// 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
|
// one-click switch to a strictly-cheaper usable model — only if one really
|
||||||
// exists in the catalog. Null hides the suggestion (no invented models).
|
// exists in the catalog. Null hides the suggestion (no invented models).
|
||||||
@@ -359,6 +379,11 @@ const ModelPilotCard = ({
|
|||||||
{lane.label}
|
{lane.label}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-[11px] text-muted-foreground truncate">{lane.description}</p>
|
<p className="text-[11px] text-muted-foreground truncate">{lane.description}</p>
|
||||||
|
{lane.key === 'primary' && primaryNote && (
|
||||||
|
<p className="mt-0.5 text-[11px] text-[var(--attention)]" data-testid="model-pilot-primary-note">
|
||||||
|
{primaryNote}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,16 @@ const SettingsApp = () => {
|
|||||||
const [fallbackModel, setFallbackModel] = useState<string | null>(null);
|
const [fallbackModel, setFallbackModel] = useState<string | null>(null);
|
||||||
const [budgetModel, setBudgetModel] = useState<string | null>(null);
|
const [budgetModel, setBudgetModel] = useState<string | null>(null);
|
||||||
const [budgetThreshold, setBudgetThreshold] = useState(0.8);
|
const [budgetThreshold, setBudgetThreshold] = useState(0.8);
|
||||||
|
// The model new chats run on after the server's usable-model fallback.
|
||||||
|
const [activeModel, setActiveModel] = useState<string | null>(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<string>('');
|
const [dailyBudget, setDailyBudget] = useState<string>('');
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [saveMsg, setSaveMsg] = useState('');
|
const [saveMsg, setSaveMsg] = useState('');
|
||||||
@@ -602,6 +612,7 @@ const SettingsApp = () => {
|
|||||||
budgetThreshold={budgetThreshold}
|
budgetThreshold={budgetThreshold}
|
||||||
dailyBudget={dailyBudget ? parseFloat(dailyBudget) : null}
|
dailyBudget={dailyBudget ? parseFloat(dailyBudget) : null}
|
||||||
providers={providers}
|
providers={providers}
|
||||||
|
activeModel={activeModel}
|
||||||
onUpdate={(fields) => {
|
onUpdate={(fields) => {
|
||||||
if (fields.defaultModel !== undefined) setDefaultModel(fields.defaultModel);
|
if (fields.defaultModel !== undefined) setDefaultModel(fields.defaultModel);
|
||||||
if (fields.fallbackModel !== undefined) setFallbackModel(fields.fallbackModel);
|
if (fields.fallbackModel !== undefined) setFallbackModel(fields.fallbackModel);
|
||||||
|
|||||||
61
apps/web/src/test/model-pilot-primary-note.test.tsx
Normal file
61
apps/web/src/test/model-pilot-primary-note.test.tsx
Normal file
@@ -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(
|
||||||
|
<TooltipProvider>
|
||||||
|
<ModelPilotCard
|
||||||
|
defaultModel="claude-sonnet-4-6"
|
||||||
|
fallbackModel={null}
|
||||||
|
budgetModel={null}
|
||||||
|
budgetThreshold={0.8}
|
||||||
|
dailyBudget={null}
|
||||||
|
providers={providers(anthropicHasKey)}
|
||||||
|
activeModel={activeModel}
|
||||||
|
onUpdate={() => {}}
|
||||||
|
/>
|
||||||
|
</TooltipProvider>,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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-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-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-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
|
## 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.
|
- 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.
|
- 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.
|
- 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.
|
||||||
|
|||||||
Reference in New Issue
Block a user