Skip to content

Commit 559eab9

Browse files
fix(settings): keep a reset script override and an aggregate model through the fold
A project whose scripts had been reset to inherit (a stored null override) regained its aggregate scripts during the fold; the reset now wins. The auto-bootstrap thread honours a project's aggregate default model, still written by older clients, after the override and before the environment.
1 parent 445b96e commit 559eab9

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎apps/server/src/serverRuntimeStartup.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,11 @@ export const resolveAutoBootstrapWelcomeTargets = Effect.gen(function* () {
229229
} else {
230230
nextProjectId = existingProject.value.id;
231231
bootstrapProjectId = nextProjectId;
232+
// The aggregate field is still written by older clients; honour it
233+
// after the override so their choice keeps applying until they update.
232234
nextThreadModelSelection =
233235
resolveProjectSettings(settings, nextProjectId).settings.defaultModelSelection ??
236+
existingProject.value.defaultModelSelection ??
234237
defaultModelSelection;
235238
}
236239

‎apps/server/src/serverSettings.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,9 @@ it.layer(NodeServices.layer)("server settings", (it) => {
13041304
Schema.fromJsonString(Schema.Array(ProjectScript)),
13051305
)([script]);
13061306
for (const [projectId, modelColumn, envMode, autoPull, scripts] of [
1307-
[legacyProject, modelJson, "worktree", 1, "[]"],
1307+
// The legacy project also carries aggregate scripts, but its stored
1308+
// null override reset them; the fold must not bring them back.
1309+
[legacyProject, modelJson, "worktree", 1, scriptsJson],
13081310
[scriptedProject, null, null, 0, scriptsJson],
13091311
] as const) {
13101312
yield* sql`

‎apps/server/src/serverSettings.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,12 @@ function foldLegacyProjectSettings(
460460
for (const [projectId, value] of Object.entries(settings.projectAutoPullOverrides)) {
461461
set(projectId, "defaultAutoPull", value);
462462
}
463+
// A stored null meant "reset to machine defaults", which is now plain
464+
// inheritance; the project's own aggregate scripts must not resurface.
465+
const resetScripts = new Set<string>();
463466
for (const [projectId, value] of Object.entries(settings.projectScriptOverrides)) {
464-
// A stored null meant "reset to machine defaults", which is now plain inheritance.
465-
if (value !== null) set(projectId, "defaultProjectScripts", value);
467+
if (value === null) resetScripts.add(projectId);
468+
else set(projectId, "defaultProjectScripts", value);
466469
}
467470
for (const row of rows) {
468471
const model = decodeModelSelectionJson(row.defaultModelSelection ?? "null");
@@ -474,7 +477,7 @@ function foldLegacyProjectSettings(
474477
}
475478
if (row.autoPull === 1) set(row.projectId, "defaultAutoPull", true);
476479
const scripts = decodeProjectScriptsJson(row.scripts);
477-
if (Option.isSome(scripts) && scripts.value.length > 0) {
480+
if (Option.isSome(scripts) && scripts.value.length > 0 && !resetScripts.has(row.projectId)) {
478481
set(row.projectId, "defaultProjectScripts", scripts.value);
479482
}
480483
}

0 commit comments

Comments
 (0)