fix: place OpenCode model variants at top level instead of inside options (#1317)

Split the expanded model panel into two editing areas:
- "Model Properties" for top-level fields (variants, cost, etc.)
- "SDK Options" for model.options fields (provider routing, etc.)

Also guard against renaming extra fields to reserved keys (name, limit,
options) or duplicate names, and fix ModelOptionKeyInput blur desync when
a rename is rejected by the parent handler.
This commit is contained in:
Jason
2026-03-15 16:37:37 +08:00
parent f38facd430
commit bb23ab918b
5 changed files with 195 additions and 22 deletions
@@ -109,6 +109,26 @@ export function parseOpencodeConfigStrict(
};
}
export const OPENCODE_KNOWN_MODEL_KEYS = ["name", "limit", "options"] as const;
export function isKnownModelKey(key: string): boolean {
return OPENCODE_KNOWN_MODEL_KEYS.includes(
key as (typeof OPENCODE_KNOWN_MODEL_KEYS)[number],
);
}
export function getModelExtraFields(
model: OpenCodeModel,
): Record<string, string> {
const extra: Record<string, string> = {};
for (const [k, v] of Object.entries(model)) {
if (!isKnownModelKey(k)) {
extra[k] = typeof v === "string" ? v : JSON.stringify(v);
}
}
return extra;
}
export function toOpencodeExtraOptions(
options: OpenCodeProviderConfig["options"],
): Record<string, string> {