fix(web): find a keyless primary's provider from the model id (UF-054, UF-055)
A provider without its key lists no models, so Model Pilot could not tell the primary needed a key, and it compared a prefixed active id with a bare one. The provider now also comes from the id's prefix or family name, and prefixed and bare ids count as the same model. The account row's fallback initial is A for Account, not W.
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
import type { Provider } from '@/hooks/useProviders';
|
||||
import { HintTooltip } from '@/components/ui/hint-tooltip';
|
||||
import { formatModelLabel } from '@/lib/model-label';
|
||||
import { providerForModel, sameModel } from '@/lib/model-provider';
|
||||
|
||||
interface ModelPilotCardProps {
|
||||
defaultModel: string;
|
||||
@@ -187,10 +188,11 @@ 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. */
|
||||
/** True when the model's provider needs an API key that the vault lacks. A
|
||||
* keyless provider lists no models, so the provider comes from the id. */
|
||||
const needsKey = (modelId: string | null, providers: Provider[]): boolean => {
|
||||
if (!modelId) return false;
|
||||
const provider = providers.find(p => p.models.some(m => m.id === modelId));
|
||||
const provider = providerForModel(modelId, providers);
|
||||
return !!provider && provider.requiresKey && !provider.hasKey;
|
||||
};
|
||||
|
||||
@@ -296,7 +298,7 @@ const ModelPilotCard = ({
|
||||
// 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
|
||||
? activeModel && !sameModel(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;
|
||||
|
||||
@@ -242,7 +242,7 @@ const Sidebar = ({
|
||||
className="mt-1.5 flex items-center justify-center gap-2.5 border-t border-[var(--line-soft)] px-2.5 pb-0 pt-3.5 text-left lg:justify-start"
|
||||
>
|
||||
<span className="grid h-7 w-7 shrink-0 place-items-center rounded-full bg-[var(--honey)] text-[11px] font-bold text-[#1a1407]">
|
||||
{initialOf(userName, "W")}
|
||||
{initialOf(userName, "A")}
|
||||
</span>
|
||||
<span className="hidden min-w-0 flex-1 lg:block">
|
||||
<span className="block truncate text-[13px] font-semibold">
|
||||
|
||||
Reference in New Issue
Block a user