diff --git a/src/components/providers/forms/OpenCodeFormFields.tsx b/src/components/providers/forms/OpenCodeFormFields.tsx index c07e2a077..5b1efd62a 100644 --- a/src/components/providers/forms/OpenCodeFormFields.tsx +++ b/src/components/providers/forms/OpenCodeFormFields.tsx @@ -1054,31 +1054,33 @@ export function OpenCodeFormFields({ /> )} - {modelDialect === "dsh" && isPlainObject(model.compat) && ( - { - const { compat: _previous, ...rest } = model; - updateModel( - key, - Object.keys(compat).length > 0 - ? { ...rest, compat } - : (rest as OpenCodeModel), - ); - }} - className="sm:col-span-2" - /> - )} + {modelDialect === "dsh" && + (model.compat === undefined || + isPlainObject(model.compat)) && ( + { + const { compat: _previous, ...rest } = model; + updateModel( + key, + Object.keys(compat).length > 0 + ? { ...rest, compat } + : (rest as OpenCodeModel), + ); + }} + className="sm:col-span-2" + /> + )} {/* Model Properties (extra fields like variants, cost) */}
diff --git a/tests/components/OpenCodeFormFields.test.tsx b/tests/components/OpenCodeFormFields.test.tsx index e2a074d27..8b8280328 100644 --- a/tests/components/OpenCodeFormFields.test.tsx +++ b/tests/components/OpenCodeFormFields.test.tsx @@ -939,4 +939,41 @@ describe("OpenCodeFormFields", () => { "mimo-v2.6-pro": { ...model, reasoning: false, reasoningEfforts: false }, }); }); + + // 自定义 DSH 模型也要能填兼容性(百炼兼容模式不认 developer 角色,#9330) + it("offers DeepSeek Harness compatibility for models that have none yet", () => { + const onModelsChange = vi.fn(); + const model = { name: "DeepSeek V4.1 Flash", reasoning: true }; + renderOpenCodeForm({ + modelDialect: "dsh", + onModelsChange, + models: { "deepseek-v4.1-flash": model }, + }); + + expandFirstModel(); + expect( + screen.getByText("pi.form.noCompatibilityOptions"), + ).toBeInTheDocument(); + fireEvent.click( + screen.getByRole("button", { name: "pi.form.addCompatibilityOption" }), + ); + fireEvent.change(screen.getByPlaceholderText("supportsDeveloperRole"), { + target: { value: "supportsDeveloperRole" }, + }); + const value = screen.getByPlaceholderText("false"); + fireEvent.change(value, { target: { value: "false" } }); + fireEvent.keyDown(value, { key: "Enter" }); + expect(onModelsChange).toHaveBeenLastCalledWith({ + "deepseek-v4.1-flash": { + ...model, + compat: { supportsDeveloperRole: false }, + }, + }); + }); + + it("keeps compatibility out of OpenCode models", () => { + renderOpenCodeForm(); + expandFirstModel(); + expect(screen.queryByText("pi.form.compatibility")).not.toBeInTheDocument(); + }); });