The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 01:45 UTC
fix(web): changing a project's model no longer keeps the old model's options (#16581)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
yaacovcorcos committed
Oct 19, 2026 at 20:41 UTC
f298bd4f9c51dfab70bd6e522ca4e7c01e009035
2 files changed
+71
-2
apps/web/src/components/settings/scopedSettings.test.ts
+56
@@ -764,3 +764,59 @@ it("routes legacy model preference keys exclusively to the selected environment"
764
},
765
]);
766
});
767
+
768
+describe("model selection patches at project scope", () => {
769
+ const codex = ProviderInstanceId.make("codex");
770
+ const claude = ProviderInstanceId.make("claudeAgent");
771
+ const saved = {
772
+ instanceId: codex,
773
+ model: "gpt-5.6",
774
+ options: [{ id: "reasoningEffort", value: "high" }],
775
+ };
776
+ const customized = environment("Server", {
777
+ settings: {
778
+ projectSettingsOverrides: {
779
+ [projectId]: {
780
+ defaultModelSelection: saved,
781
+ sourceControlWriterModelSelection: saved,
782
+ reviewGuideModelSelection: saved,
783
+ textGenerationModelSelection: saved,
784
+ },
785
+ },
786
+ },
787
+ });
788
+
789
+ it("replaces old options when changing model selections", () => {
790
+ const plan = planScopedSettingsPatch(checkout, [customized], {
791
+ defaultModelSelection: { instanceId: claude, model: "claude-opus-4-8" },
792
+ sourceControlWriterModelSelection: { instanceId: codex, model: "gpt-5.6-mini" },
793
+ reviewGuideModelSelection: { instanceId: codex, model: "gpt-5.6-mini" },
794
+ textGenerationModelSelection: { instanceId: claude, model: "claude-sonnet-4-6" },
795
+ });
796
+ expect(plan.serverWrites[0]?.patch.projectSettingsOverrides?.[projectId]).toEqual({
797
+ defaultModelSelection: { instanceId: claude, model: "claude-opus-4-8" },
798
+ sourceControlWriterModelSelection: { instanceId: codex, model: "gpt-5.6-mini" },
799
+ reviewGuideModelSelection: { instanceId: codex, model: "gpt-5.6-mini" },
800
+ textGenerationModelSelection: { instanceId: claude, model: "claude-sonnet-4-6" },
801
+ });
802
+ });
803
+
804
+ it("completes partial text-generation selections without retaining old options", () => {
805
+ const modelPlan = planScopedSettingsPatch(checkout, [customized], {
806
+ textGenerationModelSelection: { model: "gpt-5.6-mini" },
807
+ });
808
+ expect(
809
+ modelPlan.serverWrites[0]?.patch.projectSettingsOverrides?.[projectId]
810
+ ?.textGenerationModelSelection,
811
+ ).toEqual({ instanceId: codex, model: "gpt-5.6-mini" });
812
+
813
+ const options = [{ id: "reasoningEffort", value: "low" }];
814
+ const optionsPlan = planScopedSettingsPatch(checkout, [customized], {
815
+ textGenerationModelSelection: { options },
816
+ });
817
+ expect(
818
+ optionsPlan.serverWrites[0]?.patch.projectSettingsOverrides?.[projectId]
819
+ ?.textGenerationModelSelection,
820
+ ).toEqual({ ...saved, options });
821
+ });
822
+});
apps/web/src/components/settings/scopedSettings.ts
+15
-2
@@ -227,7 +227,7 @@ export function planScopedSettingsPatch(
227
// so complete the patch from the target's effective value.
228
const effective = resolveProjectSettings(settings, projectId).settings;
229
const next: Record<string, unknown> = { ...current };
230
- for (const [key, value] of Object.entries(serverPatch)) {
230
+ for (const [key, value] of Object.entries<unknown>(serverPatch)) {
231
if (key === "worktreeCleanup" && serverPatch.worktreeCleanup?.mode === "custom") {
232
next[key] = {
233
mode: "custom",
@@ -247,7 +247,20 @@ export function planScopedSettingsPatch(
247
delete next[key];
248
continue;
249
}
250
- const base = effective[key as keyof ServerSettings];
250
+ const base: unknown = effective[key as keyof ServerSettings];
251
+ // A new model must not inherit the previous model's options.
252
+ if (
253
+ isPlainObject(value) &&
254
+ isPlainObject(base) &&
255
+ (key === "defaultModelSelection" ||
256
+ key === "sourceControlWriterModelSelection" ||
257
+ key === "reviewGuideModelSelection" ||
258
+ key === "textGenerationModelSelection") &&
259
+ (value.instanceId !== undefined || value.model !== undefined)
260
+ ) {
261
+ next[key] = { instanceId: base.instanceId, model: base.model, ...value };
262
+ continue;
263
+ }
264
next[key] =
265
isPlainObject(value) && isPlainObject(base) ? { ...base, ...value } : value;
266
}