feat(04-01): refactor all notify() call sites to use structured NotificationOptions

- Change ipc-support.ts notify() from (title, body) to (options: NotificationOptions)
- Wire createNotificationService in bootstrap-application.ts with lazy service graph refs
- Update all 12 call sites with entity context, urgency, navigation, and batch keys
- Update dependency interfaces in service-graph, worker, orchestration, automation, updater, desktop-shell
- No string-based notify() calls remain in src/main/

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 4.6 committed 2026-03-22 16:37:07 -04:00
1 parent 9ebb489644
commit 667ac48aa5
8 files changed
+113 -34

No files matched your search

+22 -10
View File
@@ -8,6 +8,7 @@ import type {
RunStatus,
} from "@shared/types";
import { dispatchAgentMessage } from "./message-dispatch";
import type { NotificationOptions } from "./notification-service";
const WORKFLOW_ACTIONS: ReadonlySet<AutomationAction> = new Set([
"assign_task",
@@ -59,7 +60,7 @@ interface AutomationDependencies {
};
emitEvent: (event: DesktopEvent) => void;
publishDomainChanged: () => void;
notify: (title: string, body: string) => void;
notify: (options: NotificationOptions) => void;
wakeAgentIfPossible: (agentId: string | null | undefined, companyId: string, trigger: string) => string | null;
dispatchBrowserAction: (actionId: string, companyId: string) => Promise<void>;
}
@@ -909,16 +910,21 @@ export function createAutomationService({
});
// Fire OS notification for budget threshold warning
const pct = Math.round(utilization * 100);
notify(
"Budget Alert",
`${agent.name} is at ${pct}% of monthly budget ($${agent.spentMonthlyUsd.toFixed(2)} / $${agent.budgetMonthlyUsd.toFixed(2)})`,
);
notify({
title: "Budget Warning",
body: `${agent.name} has used ${pct}% of monthly budget`,
urgency: "informational",
navigation: { section: "costs" },
batchKey: "budget_alerts",
});
if (utilization >= 1.0) {
// Fire OS notification for budget exhaustion (agent auto-paused by database)
notify(
"Budget Alert",
`${agent.name} paused -- monthly budget exhausted ($${agent.spentMonthlyUsd.toFixed(2)} / $${agent.budgetMonthlyUsd.toFixed(2)})`,
);
notify({
title: "Budget Exhausted",
body: `${agent.name} has reached 100% of monthly budget and is paused`,
urgency: "critical",
navigation: { section: "costs" },
});
}
}
}
@@ -957,7 +963,13 @@ export function createAutomationService({
});
wakeAgentIfPossible(agent.id, companyId, "assignment");
publishDomainChanged();
notify("New agent hired", `${agent.name} (${agent.role}) has joined the company.`);
notify({
title: "Agent Hired",
body: `${agent.name} joined as ${agent.role}`,
urgency: "informational",
navigation: { section: "orgchart", entityId: agent.id },
batchKey: "agent_hired",
});
}
} catch {
// Hire follow-up is best-effort; approval state is already committed in storage.