Skip to content

Commit b208c34

Browse files
Fix config patch restart-required notices
1 parent aeb3f0f commit b208c34

4 files changed

Lines changed: 9 additions & 40 deletions

File tree

‎src/gateway/server-restart-sentinel.test.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,8 @@ describe("scheduleRestartSentinelWake", () => {
458458
});
459459
expect(mocks.ackDelivery).toHaveBeenCalledWith("queue-1");
460460
expect(mocks.failDelivery).not.toHaveBeenCalled();
461-
expect(mocks.formatRestartSentinelMessage).toHaveBeenCalledWith(expect.anything(), {
462-
state: "completed",
463-
});
464-
expect(mocks.summarizeRestartSentinel).toHaveBeenCalledWith(expect.anything(), {
465-
state: "completed",
466-
});
461+
expect(mocks.formatRestartSentinelMessage).toHaveBeenCalledWith(expect.anything());
462+
expect(mocks.summarizeRestartSentinel).toHaveBeenCalledWith(expect.anything());
467463
expect(mockCallArg(mocks.enqueueSystemEvent)).toBe("restart message");
468464
expectNthSystemEventFields(0, {
469465
sessionKey: "agent:main:main",

‎src/gateway/server-restart-sentinel.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ async function loadRestartSentinelStartupTask(params: {
453453
recordLatestUpdateRestartSentinel(payload);
454454
}
455455
const sessionKey = payload.sessionKey?.trim();
456-
const message = formatRestartSentinelMessage(payload, { state: "completed" });
457-
const summary = summarizeRestartSentinel(payload, { state: "completed" });
456+
const message = formatRestartSentinelMessage(payload);
457+
const summary = summarizeRestartSentinel(payload);
458458
const wakeDeliveryContext = mergeDeliveryContext(
459459
payload.threadId != null
460460
? { ...payload.deliveryContext, threadId: payload.threadId }

‎src/infra/restart-sentinel.test.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ describe("restart sentinel", () => {
216216
expect(summarizeRestartSentinel(read.payload)).toBe(
217217
"Gateway restart config-patch ok (config.patch)",
218218
);
219-
expect(summarizeRestartSentinel(read.payload, { state: "completed" })).toBe(
220-
"Gateway restart config-patch ok (config.patch)",
221-
);
222219
expect(formatRestartSentinelMessage(read.payload)).toBe(
223220
["Gateway restart config-patch ok (config.patch)", "Config updated successfully"].join(
224221
"\n",
@@ -292,16 +289,7 @@ describe("restart sentinel", () => {
292289
"Run openclaw doctor --non-interactive",
293290
].join("\n"),
294291
);
295-
expect(formatRestartSentinelMessage(payload, { state: "completed" })).toBe(
296-
"Gateway restart completed (config.patch)",
297-
);
298292
expect(summarizeRestartSentinel(payload)).toBe("Gateway restart required (config.patch)");
299-
expect(summarizeRestartSentinel(payload, { state: "pending" })).toBe(
300-
"Gateway restart required (config.patch)",
301-
);
302-
expect(summarizeRestartSentinel(payload, { state: "completed" })).toBe(
303-
"Gateway restart completed (config.patch)",
304-
);
305293

306294
expect(
307295
summarizeRestartSentinel({

‎src/infra/restart-sentinel.ts‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ export type RestartSentinel = {
7676
payload: RestartSentinelPayload;
7777
};
7878

79-
export type RestartSentinelFormatOptions = {
80-
state?: "pending" | "completed";
81-
};
82-
8379
const RESTART_SENTINEL_KEY = "current";
8480
const LEGACY_RESTART_SENTINEL_FILENAME = "restart-sentinel.json";
8581
type GatewayRestartSentinelDatabase = Pick<OpenClawStateKyselyDatabase, "gateway_restart_sentinel">;
@@ -326,25 +322,20 @@ export async function hasRestartSentinel(env: NodeJS.ProcessEnv = process.env):
326322
}
327323
}
328324

329-
export function formatRestartSentinelMessage(
330-
payload: RestartSentinelPayload,
331-
options?: RestartSentinelFormatOptions,
332-
): string {
333-
const completedConfigRestart =
334-
isRestartRequiredConfigWriteSentinel(payload) && options?.state === "completed";
335-
const message = completedConfigRestart ? undefined : payload.message?.trim();
325+
export function formatRestartSentinelMessage(payload: RestartSentinelPayload): string {
326+
const message = payload.message?.trim();
336327
if (message && (!payload.stats || payload.kind === "config-auto-recovery")) {
337328
return message;
338329
}
339-
const lines: string[] = [summarizeRestartSentinel(payload, options)];
330+
const lines: string[] = [summarizeRestartSentinel(payload)];
340331
if (message) {
341332
lines.push(message);
342333
}
343334
const reason = payload.stats?.reason?.trim();
344335
if (reason && reason !== message) {
345336
lines.push(`Reason: ${reason}`);
346337
}
347-
if (!completedConfigRestart && payload.doctorHint?.trim()) {
338+
if (payload.doctorHint?.trim()) {
348339
lines.push(payload.doctorHint.trim());
349340
}
350341
return lines.join("\n");
@@ -358,18 +349,12 @@ function isRestartRequiredConfigWriteSentinel(payload: RestartSentinelPayload):
358349
);
359350
}
360351

361-
export function summarizeRestartSentinel(
362-
payload: RestartSentinelPayload,
363-
options?: RestartSentinelFormatOptions,
364-
): string {
352+
export function summarizeRestartSentinel(payload: RestartSentinelPayload): string {
365353
if (payload.kind === "config-auto-recovery") {
366354
return "Gateway auto-recovery";
367355
}
368356
if (isRestartRequiredConfigWriteSentinel(payload)) {
369357
const mode = payload.stats?.mode ? ` (${payload.stats.mode})` : "";
370-
if (options?.state === "completed") {
371-
return `Gateway restart completed${mode}`.trim();
372-
}
373358
return `Gateway restart required${mode}`.trim();
374359
}
375360
const kind = payload.kind;

0 commit comments

Comments
 (0)