Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

feat(main): fire desktop notifications on agent idle/waiting lifecycle events

Chaitanya Giria9e8d8575e13
diff --git a/src/main/config.ts b/src/main/config.ts
index d4df2874..8f53f5cd 100644
--- a/src/main/config.ts
+++ b/src/main/config.ts
@@ -19,6 +19,8 @@ export interface HarnessConfig {
semanticMemory: boolean;
/** Embedding model for the palace: lightweight 'minilm' or multilingual 'embeddinggemma'. */
embeddingModel: 'minilm' | 'embeddinggemma';
+ /** Fire native desktop notifications on agent lifecycle events (idle finish / waiting for input). */
+ notifications?: boolean;
}
const DEFAULTS: HarnessConfig = {
@@ -28,7 +30,8 @@ const DEFAULTS: HarnessConfig = {
autoMode: true,
defaultCommand: 'claude',
semanticMemory: true,
- embeddingModel: 'minilm'
+ embeddingModel: 'minilm',
+ notifications: false
};
function configPath(): string {
diff --git a/src/main/hooks.ts b/src/main/hooks.ts
index 71ae6ebf..e75f6fd0 100644
--- a/src/main/hooks.ts
+++ b/src/main/hooks.ts
@@ -13,8 +13,9 @@
*/
import { createServer, type Server } from 'node:net';
import { existsSync, rmSync } from 'node:fs';
-import type { WebContents } from 'electron';
+import { Notification, type WebContents } from 'electron';
import type { HiveManager } from './hive';
+import type { HarnessConfig } from './config';
interface HookPayload {
hook_event_name?: string;
@@ -37,7 +38,8 @@ export class HookServer {
constructor(
private hive: HiveManager,
- private getWebContents: () => WebContents | null
+ private getWebContents: () => WebContents | null,
+ private getConfig: () => HarnessConfig
) {}
start(): void {
@@ -87,16 +89,39 @@ export class HookServer {
this.emit(agentId, event, p, true);
return { decision: 'block', reason: drain.reason };
}
- // A genuine stop with nothing queued → idle.
+ // A genuine stop with nothing queued → idle. Surface it as a desktop toast.
+ this.notify(agentId ?? 'Agent', 'finished — idle');
this.emit(agentId, event, p);
return {};
}
+ // A Notification hook that means "the agent is blocked waiting for the user"
+ // (idle prompt) deserves a desktop toast too — distinct from a permission
+ // request, which we leave to the in-app approvals UI.
+ if (
+ event === 'Notification' &&
+ (p.notification_type === 'idle' ||
+ (p.message ?? '').toLowerCase().includes('waiting for your input'))
+ ) {
+ this.notify(agentId ?? 'Agent', p.message ?? 'needs your attention');
+ }
+
// Forward everything else to the renderer so avatars reflect real activity.
this.emit(agentId, event, p);
return {};
}
+ /** Fire a native desktop notification — gated on the user's `notifications`
+ * setting. Only the OS toast is gated; the hive:hookEvent emit is always sent
+ * so avatars/UI stay live regardless. Best-effort: never throw into the hook. */
+ private notify(title: string, body: string): void {
+ if (!this.getConfig().notifications) return;
+ try {
+ if (!Notification.isSupported()) return;
+ new Notification({ title, body }).show();
+ } catch { /* notifications unsupported on this platform — ignore */ }
+ }
+
private emit(agentId: string | undefined, event: string, p: HookPayload, blocked = false): void {
this.getWebContents()?.send('hive:hookEvent', {
agentId,
diff --git a/src/main/index.ts b/src/main/index.ts
index b8771c77..7fa33621 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -22,7 +22,7 @@ const hive = new HiveManager(
() => readConfig().harnessHome,
(channel, payload) => { try { liveWebContents()?.send(channel, payload); } catch { /* window tore down */ } }
);
-const hookServer = new HookServer(hive, () => liveWebContents());
+const hookServer = new HookServer(hive, () => liveWebContents(), () => readConfig());
const memory = new MemoryManager(
() => readConfig().harnessHome,
() => { const c = readConfig(); return { enabled: c.semanticMemory !== false, model: c.embeddingModel ?? 'minilm' }; }
@@ -302,6 +302,9 @@ ipcMain.handle('app:resetAll', () => {
app.exit(0);
});
+// ─── IPC: desktop notifications toggle ──────────────────────────────────────
+ipcMain.handle('app:setNotifications', (_evt, val) => writeConfig({ notifications: val === true }));
+
app.whenReady().then(() => {
// Bootstrap the hive (if harnessHome is configured) and start the message router.
if (hive.enabled()) {