fix(update): preserve doctor repair writes in legacy handoff

This commit is contained in:
Peter Steinberger
2026-04-29 04:42:33 +01:00
parent aa1bccfe80
commit 8edb99f0e3
2 changed files with 20 additions and 0 deletions

View File

@@ -54,6 +54,21 @@ describe("doctor health contributions", () => {
).toBe(false);
});
it("keeps repair writes from doctor config preflight writable during legacy update", () => {
expect(
shouldSkipLegacyUpdateDoctorMetadataWrite({
env: { OPENCLAW_UPDATE_IN_PROGRESS: "1" },
hasPendingConfigWrite: true,
before: { gateway: { mode: "remote" } },
after: {
gateway: { mode: "remote" },
meta: { lastTouchedVersion: "2026.4.27" },
wizard: { lastRunCommand: "doctor" },
},
}),
).toBe(false);
});
it("keeps current update parents writable", () => {
expect(
shouldSkipLegacyUpdateDoctorMetadataWrite({

View File

@@ -59,6 +59,7 @@ function omitDoctorWriteMetadata(cfg: OpenClawConfig): OpenClawConfig {
export function shouldSkipLegacyUpdateDoctorMetadataWrite(params: {
env: NodeJS.ProcessEnv;
hasPendingConfigWrite?: boolean;
before: OpenClawConfig;
after: OpenClawConfig;
}): boolean {
@@ -68,6 +69,9 @@ export function shouldSkipLegacyUpdateDoctorMetadataWrite(params: {
if (isTruthyEnvValue(params.env[UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV])) {
return false;
}
if (params.hasPendingConfigWrite === true) {
return false;
}
return isDeepStrictEqual(
omitDoctorWriteMetadata(params.before),
omitDoctorWriteMetadata(params.after),
@@ -533,6 +537,7 @@ async function runWriteConfigHealth(ctx: DoctorHealthFlowContext): Promise<void>
if (
shouldSkipLegacyUpdateDoctorMetadataWrite({
env: ctx.env ?? process.env,
hasPendingConfigWrite: ctx.configResult.shouldWriteConfig === true,
before: ctx.cfgForPersistence,
after: ctx.cfg,
})