fix(tiny): guard unsupportedReason access on const model-spec union (#3133 integration typecheck)

This commit is contained in:
can1357
2026-06-20 22:25:29 +02:00
parent ad31ef212b
commit d8ec46eee5
2 changed files with 11 additions and 4 deletions
@@ -38,7 +38,10 @@ export function resolveModels(model: string | undefined): TinyLocalModelKey[] {
if (!model) return [DEFAULT_TINY_TITLE_LOCAL_MODEL_KEY];
// `all` is a prefetch convenience: skip models that fail before load (unsupported
// runtime), so the bulk download stays green when every *usable* model succeeds.
if (model === "all") return TINY_LOCAL_MODELS.filter(spec => !spec.unsupportedReason).map(spec => spec.key);
if (model === "all")
return TINY_LOCAL_MODELS.filter(spec => !("unsupportedReason" in spec) || !spec.unsupportedReason).map(
spec => spec.key,
);
if (!isTinyLocalModelKey(model)) {
const values = TINY_LOCAL_MODELS.map(spec => spec.key).join(", ");
throw new Error(`Unknown tiny local model: ${model}. Expected one of: ${values}, all`);