From 8edb99f0e301cb58f4c60b06f1d78f284d359f13 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 29 Apr 2026 04:42:33 +0100 Subject: [PATCH] fix(update): preserve doctor repair writes in legacy handoff --- src/flows/doctor-health-contributions.test.ts | 15 +++++++++++++++ src/flows/doctor-health-contributions.ts | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/flows/doctor-health-contributions.test.ts b/src/flows/doctor-health-contributions.test.ts index c076143999d..c8a93a73db1 100644 --- a/src/flows/doctor-health-contributions.test.ts +++ b/src/flows/doctor-health-contributions.test.ts @@ -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({ diff --git a/src/flows/doctor-health-contributions.ts b/src/flows/doctor-health-contributions.ts index 12c61a14f87..dfbf24a8c03 100644 --- a/src/flows/doctor-health-contributions.ts +++ b/src/flows/doctor-health-contributions.ts @@ -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 if ( shouldSkipLegacyUpdateDoctorMetadataWrite({ env: ctx.env ?? process.env, + hasPendingConfigWrite: ctx.configResult.shouldWriteConfig === true, before: ctx.cfgForPersistence, after: ctx.cfg, })