feat(nexus): OS notification + terminal bell when sub-agent finishes
This commit is contained in:
@@ -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}`,
|
||||
|
||||
Reference in New Issue
Block a user