refactor(heartbeat): centralize [Heartbeat] prefix as a shared constant
P2-36: Multiple subsystems were string-coupled via the magic '[Heartbeat]' prefix. Introduce src/main/orchestration/heartbeat-task.ts as the single source of truth and replace scattered literals in heartbeat dispatch, automation actions, and run completion. P3-52: Collapse 5-deep ternary in automation-actions' wake-trigger selection into lookup helpers (deriveHeartbeatWakeTrigger, deriveEscalationWakeTrigger).
This commit is contained in:
1 parent
4838750009
commit
bb397dff02
4 files changed
+48
-26
No files matched your search
@@ -3,6 +3,7 @@ import type { RunRecord, SectionId } from "@shared/types";
|
||||
import type { NotificationOptions } from "../notification-service";
|
||||
import type { AutomationEventContext, RunFinishedEvent } from "./types";
|
||||
import { IMPORTANT_DOCUMENT_TYPES } from "./types";
|
||||
import { isHeartbeatTaskTitle } from "../orchestration/heartbeat-task";
|
||||
|
||||
function localizeNotification(locale: string | null | undefined, en: string, zh: string): string {
|
||||
return locale === "zh" ? zh : en;
|
||||
@@ -290,7 +291,7 @@ export function processRunCompletion(
|
||||
}
|
||||
}
|
||||
|
||||
if (isSuccess && task.title.startsWith("[Heartbeat]") && effectiveStatus !== "done") {
|
||||
if (isSuccess && isHeartbeatTaskTitle(task.title) && effectiveStatus !== "done") {
|
||||
db.advanceTaskStatus(task.id, "done", "Heartbeat check completed.");
|
||||
handleTaskStatusChange(task.id, run.companyId, effectiveStatus, "done");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user