mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-29 09:37:37 +08:00
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:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user