feat(nexus): OS notification + terminal bell when sub-agent finishes

This commit is contained in:
Azreen Jamal
2026-03-10 01:34:46 +08:00
parent 9bc94b0bab
commit 1f642c6b66
+18
View File
@@ -514,6 +514,18 @@ export default function nexus(pi: ExtensionAPI) {
});
}
function notifyOS(title: string, message: string) {
// macOS notification via osascript
try {
cpSpawn("osascript", [
"-e",
`display notification "${message.replace(/"/g, '\\"')}" with title "${title.replace(/"/g, '\\"')}" sound name "Glass"`,
], { stdio: "ignore", detached: true }).unref();
} catch {}
// Also ring the terminal bell as fallback
process.stdout.write("\x07");
}
function spawnAndDeliver(a: SubAgent, prompt: string, ctx: ExtensionContext, isCont: boolean) {
spawnProcess(a, prompt, ctx, isCont).then(({ output, exitCode }) => {
const status = exitCode === 0 ? "✓" : "✗";
@@ -523,6 +535,12 @@ export default function nexus(pi: ExtensionAPI) {
ctx.ui.notify(`#${a.id} [${a.role}] ${status} ${elapsed}s`, exitCode === 0 ? "info" : "error");
// 🔔 OS notification so user is alerted even when away from terminal
notifyOS(
`Nexus #${a.id} [${a.role}] ${status}`,
`${elapsed}s · ${a.toolCount} tools · ${a.task.slice(0, 60)}`,
);
pi.sendMessage({
customType: "nexus-result",
content: `**Sub-agent #${a.id}** [${a.role}]${turn}${status} ${elapsed}s | ${a.toolCount} tools | $${a.cost.toFixed(4)}\n\n${truncated}`,