Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

feat(island): add alertsFromAllPills setting for unfocused agent finishes (#942)

unknown0d0da8e74260
diff --git a/windows/src-tauri/src/settings.rs b/windows/src-tauri/src/settings.rs
index e3048fbe..24fb4e86 100644
--- a/windows/src-tauri/src/settings.rs
+++ b/windows/src-tauri/src/settings.rs
@@ -19,6 +19,7 @@ pub struct Settings {
/// Hovering the island opens it all the way, and it folds again shortly
/// after the pointer leaves (the Mac's "Open on hover"). Off by default.
pub open_on_hover: bool,
+ pub alerts_from_all_pills: bool,
pub absence_interval: f64,
pub active_integrations: Vec<String>,
/// The always-on workspace pill (src/core/pills.ts checks it is one).
@@ -135,6 +136,7 @@ impl Default for Settings {
sound_volume: 0.12,
auto_close_interval: 15.0,
open_on_hover: false,
+ alerts_from_all_pills: false,
absence_interval: 180.0,
active_integrations: vec![
"integration_resend".into(),
@@ -439,6 +441,7 @@ mod tests {
"soundVolume": 0.5,
"autoCloseInterval": 30.0,
"openOnHover": true,
+ "alertsFromAllPills": true,
"absenceInterval": 60.0,
"activeIntegrations": ["integration_notion"],
"mainPill": "agent_cursor",
@@ -958,6 +961,7 @@ mod tests {
"soundVolume",
"autoCloseInterval",
"openOnHover",
+ "alertsFromAllPills",
"absenceInterval",
"activeIntegrations",
"mainPill",
diff --git a/windows/src/core/state.ts b/windows/src/core/state.ts
index bab28737..0cbf6b07 100644
--- a/windows/src/core/state.ts
+++ b/windows/src/core/state.ts
@@ -103,6 +103,8 @@ export interface Settings {
autoCloseInterval: number;
/** Hovering the island opens it all the way (off: hovering only peeks). */
openOnHover: boolean;
+ /** Open the island for a moment when any pill finishes or hits an error. */
+ alertsFromAllPills: boolean;
/** Date and time in the middle of the compact island. */
showClock: boolean;
absenceInterval: number;
@@ -173,6 +175,7 @@ export const DEFAULT_SETTINGS: Settings = {
soundVolume: 0.12,
autoCloseInterval: 15,
openOnHover: false,
+ alertsFromAllPills: false,
showClock: false,
absenceInterval: 180,
activeIntegrations: [
diff --git a/windows/src/island/hooks.ts b/windows/src/island/hooks.ts
index b96e82a5..6219ad19 100644
--- a/windows/src/island/hooks.ts
+++ b/windows/src/island/hooks.ts
@@ -44,6 +44,39 @@ function cancelStopTimer(id: string): boolean {
return true;
}
+/** The pill that was focused before another pill's alert borrowed the front. */
+let focusBeforeAlert: string | null = null;
+let alertPill: string | null = null;
+
+function showsAlert(pill: string, focused: boolean): boolean {
+ if (State.pendingApproval) return false;
+ if (focused) return true;
+ if (!State.settings.alertsFromAllPills) return false;
+ if (State.mode === "expanded" && !["overview", "finished", "error", "empty"].includes(State.view)) {
+ return false;
+ }
+ if (focusBeforeAlert == null) focusBeforeAlert = State.focusId;
+ alertPill = pill;
+ State.setFocus(pill);
+ return true;
+}
+
+export function restoreAlertFocus(): void {
+ if (!focusBeforeAlert) return;
+ const prev = focusBeforeAlert;
+ const borrowed = alertPill;
+ focusBeforeAlert = null;
+ alertPill = null;
+ if (
+ !State.pendingApproval &&
+ State.focusId === borrowed &&
+ borrowed !== prev &&
+ State.tasks.some((t) => t.id === prev)
+ ) {
+ State.setFocus(prev);
+ }
+}
+
/** Events after which a pending permission request of the same session is moot. */
const TURN_OVER = new Set(["Stop", "StopFailure", "UserPromptSubmit", "SessionEnd", "Interrupt"]);
@@ -430,13 +463,14 @@ function handleHook(island: Island, payload: HookPayload) {
}
Sound.play("finish");
// A card waiting for an answer is never covered by another alert.
- if (focused && !State.pendingApproval) surface("finished", true);
+ if (showsAlert(agentId, focused)) surface("finished", true);
else State.setPillBadge(agentId, "finished");
cancelStopTimer(agentId);
stopTimers.set(
agentId,
window.setTimeout(() => {
stopTimers.delete(agentId);
+ restoreAlertFocus();
if (isExternalAgent) {
State.removeTask(agentId);
} else {
@@ -459,7 +493,7 @@ function handleHook(island: Island, payload: HookPayload) {
supersedeStop();
State.updateTask(agentId, "error");
Sound.play("error");
- if (focused && !State.pendingApproval) surface("error", true);
+ if (showsAlert(agentId, focused)) surface("error", true);
else State.setPillBadge(agentId, "error");
break;
diff --git a/windows/src/island/island.ts b/windows/src/island/island.ts
index 090d2729..865556a9 100644
--- a/windows/src/island/island.ts
+++ b/windows/src/island/island.ts
@@ -24,6 +24,7 @@ import { buildHeader, buildViews, type ViewActions, type ViewHost } from "../vie
import { h } from "../views/dom";
import { IslandStateMachine } from "./fsm";
import { refreshHookPills } from "./integrations";
+import { restoreAlertFocus } from "./hooks";
import { DesktopLink } from "./desktop";
import type { ViewCommand } from "./shortcuts";
import { DRAG_THRESHOLD } from "../mochi/desktop-logic";
@@ -444,6 +445,7 @@ export class Island {
this.foldApproval();
return;
}
+ restoreAlertFocus();
State.isPinned = false;
this.fsm.pinned = false;
// Drive the state machine rather than the mode: setting the mode behind its
diff --git a/windows/src/settings/main.ts b/windows/src/settings/main.ts
index 04d9609f..930bcd0c 100644
--- a/windows/src/settings/main.ts
+++ b/windows/src/settings/main.ts
@@ -1063,6 +1063,11 @@ function generalSection(): HTMLElement {
toggle(settings.openOnHover, (v) => { settings.openOnHover = v; void save(); }),
),
h("div", { class: "hint", text: t("Hovering the island opens it; it folds again shortly after the pointer leaves. Click inside to keep it open.") }),
+ h("div", { class: "row" },
+ h("label", { text: t("Open for every pill’s alerts") }),
+ toggle(settings.alertsFromAllPills, (v) => { settings.alertsFromAllPills = v; void save(); }),
+ ),
+ h("div", { class: "hint", text: t("When a pill other than the one shown finishes or hits an error, the notch shows it for a moment, then the pill you had comes back.") }),
h("div", { class: "row" },
h("label", { text: t("Show clock in the island") }),
toggle(settings.showClock, (v) => { settings.showClock = v; void save(); }),
diff --git a/windows/tests/hooks.test.mjs b/windows/tests/hooks.test.mjs
index 552bbd5f..1dfe12a1 100644
--- a/windows/tests/hooks.test.mjs
+++ b/windows/tests/hooks.test.mjs
@@ -179,6 +179,17 @@ test("a session finishing behind another pill only badges its own, for 5.2 s", (
assert.equal(task().pillBadge, null);
});
+test("alertsFromAllPills: unfocused pill alert opens the island and restores focus after 5.2 s", () => {
+ State.settings.alertsFromAllPills = true;
+ State.setFocus("integration_n8n");
+ hook({ hook_event_name: "Stop" });
+ assert.equal(State.focusId, "integration_claude");
+ assert.deepEqual(asked, ["alert:finished"]);
+ seconds(5.2);
+ assert.equal(State.focusId, "integration_n8n");
+ State.settings.alertsFromAllPills = false;
+});
+
test("a failed stop shows the error view, or the error badge behind another pill", () => {
hook({ hook_event_name: "StopFailure" });
assert.equal(task().state, "error");