Skip to content

Commit d1c48ce

Browse files
fix(settings): preserve local model resets with disabled providers
1 parent e2b5532 commit d1c48ce

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

‎apps/web/src/hooks/useSettings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ function useUpdateSettingsTarget(environmentId: EnvironmentId | null) {
467467
target?.serverConfig?.environment.capabilities,
468468
target?.serverConfig?.settings,
469469
sourceSettings,
470+
targetId === environmentId,
470471
);
471472
if (Object.keys(targetPatch).length === 0) continue;
472473
wroteToTarget = true;

‎packages/client-runtime/src/state/sharedSettings.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,40 @@ describe("pickSharedServerSettings", () => {
122122
});
123123

124124
describe("filterSharedServerPatch", () => {
125+
it.each([true, false])(
126+
"resets a disabled default provider only on the originating environment (%s)",
127+
(targetIsSource) => {
128+
const settings = {
129+
...DEFAULT_SERVER_SETTINGS,
130+
providerInstances: {
131+
codex: { driver: ProviderDriverKind.make("codex"), enabled: false, config: {} },
132+
claudeAgent: {
133+
driver: ProviderDriverKind.make("claudeAgent"),
134+
enabled: true,
135+
config: {},
136+
},
137+
},
138+
textGenerationModelSelection: {
139+
instanceId: ProviderInstanceId.make("claudeAgent"),
140+
model: "claude-opus-4-6",
141+
},
142+
};
143+
const patch = {
144+
textGenerationModelSelection: DEFAULT_SERVER_SETTINGS.textGenerationModelSelection,
145+
continueThreadsAfterServerUpdate: true,
146+
sidebarAutoSettleAfterDays: 7,
147+
};
148+
expect(filterSharedServerPatch(patch, undefined, settings, settings, targetIsSource)).toEqual(
149+
{
150+
...(targetIsSource
151+
? { textGenerationModelSelection: DEFAULT_SERVER_SETTINGS.textGenerationModelSelection }
152+
: {}),
153+
sidebarAutoSettleAfterDays: 7,
154+
},
155+
);
156+
},
157+
);
158+
125159
it.each(["missing", "disabled", "different-driver", "enabled"] as const)(
126160
"shares a custom model only when its target provider is enabled (%s)",
127161
(availability) => {

‎packages/client-runtime/src/state/sharedSettings.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,19 @@ export function splitSharedServerPatch(patch: ServerSettingsPatch): {
5454
};
5555
}
5656

57-
/** Omit restart recovery on servers that cannot persist its preference. */
57+
/** Filter unsupported preferences; direct model writes retain the server's fallback behavior. */
5858
export function filterSharedServerPatch(
5959
patch: ServerSettingsPatch,
6060
capabilities: Pick<ExecutionEnvironmentCapabilities, "threadRestartContinuation"> | undefined,
6161
settings?: ServerSettings,
6262
sourceSettings = settings,
63+
targetIsSource = false,
6364
): ServerSettingsPatch {
6465
const instanceId =
6566
patch.textGenerationModelSelection?.instanceId ??
6667
sourceSettings?.textGenerationModelSelection.instanceId;
6768
if (
69+
!targetIsSource &&
6870
patch.textGenerationModelSelection &&
6971
(!settings ||
7072
(instanceId !== undefined &&

0 commit comments

Comments
 (0)