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.

Windows/Linux: the permission card waits for you, and can be folded away (Mac #117, #120, #290)

Claudeec56e2a34b29
diff --git a/windows/src/core/state.ts b/windows/src/core/state.ts
index 628d1ef4..5409ba83 100644
--- a/windows/src/core/state.ts
+++ b/windows/src/core/state.ts
@@ -35,6 +35,8 @@ export interface AgentTask {
export interface ApprovalInfo {
requestId: string;
sessionId: string;
+ /** The pill the request belongs to: VS Code's, or Cursor's. */
+ pillId: string;
tool: string;
command: string;
/** Set when Claude Code is asking a question rather than for a permission. */
@@ -147,6 +149,8 @@ class AppState {
searchResult: SearchResult | null = null;
chatHistory: ChatMessage[] = [];
pendingApproval: ApprovalInfo | null = null;
+ /** The pill that was in front when the card came up; it comes back after. */
+ focusBeforeApproval: string | null = null;
integrations: Record<string, IntegrationInfo> = {};
@@ -189,6 +193,36 @@ class AppState {
this.notify();
}
+ /**
+ * A permission card or a question comes up: its pill comes to the front, and
+ * the pill that was there is remembered (HookServer.focusBeforeApproval).
+ */
+ beginApproval(info: ApprovalInfo) {
+ this.pendingApproval = info;
+ this.isPinned = true;
+ if (this.focusBeforeApproval == null) this.focusBeforeApproval = this.focusId;
+ this.setFocus(info.pillId);
+ }
+
+ /**
+ * The card has its answer, or is withdrawn: the session carries on, and the
+ * pill you were on comes back — unless you moved to another one meanwhile.
+ */
+ endApproval() {
+ const req = this.pendingApproval;
+ if (!req) return;
+ this.pendingApproval = null;
+ this.isPinned = false;
+ this.updateTask(req.pillId, "working");
+ this.setPillBadge(req.pillId, null);
+ const previous = this.focusBeforeApproval;
+ this.focusBeforeApproval = null;
+ if (previous && this.focusId === req.pillId && this.tasks.some((t) => t.id === previous)) {
+ this.focusId = previous;
+ }
+ this.notify();
+ }
+
updateTask(id: string, state: BotStateName) {
const t = this.tasks.find((x) => x.id === id);
if (!t) return;
@@ -322,7 +356,12 @@ class AppState {
this.loadIntegrationTasks();
}
+ /**
+ * What the island opens on. A card waiting for an answer comes first, so
+ * reopening a folded island shows it again (Mac #117, #290).
+ */
defaultView(): IslandViewName {
+ if (this.pendingApproval) return this.pendingApproval.questions ? "question" : "approval";
return this.tasks.length === 0 ? "empty" : "overview";
}
}
diff --git a/windows/src/island/fsm.ts b/windows/src/island/fsm.ts
index 8cd46d11..64ef4285 100644
--- a/windows/src/island/fsm.ts
+++ b/windows/src/island/fsm.ts
@@ -125,9 +125,12 @@ export class IslandStateMachine {
private schedulePetitHide() {
this.clear("petitHide");
+ // A card folded away while it waits for an answer keeps the compact island
+ // on screen, so it can be reopened (isHeldOpen on macOS).
+ if (this.pinned) return;
this.petitHide = window.setTimeout(() => {
this.petitHide = null;
- if (this.state === "petit") this.transition("hidden");
+ if (this.state === "petit" && !this.pinned) this.transition("hidden");
}, this.petitToHiddenDelay * 1000);
}
diff --git a/windows/src/island/hooks.ts b/windows/src/island/hooks.ts
index cb9ef14f..53a1962c 100644
--- a/windows/src/island/hooks.ts
+++ b/windows/src/island/hooks.ts
@@ -18,11 +18,8 @@ let pendingTimeout: number | null = null;
/** Takes the approval or question card down and gives the island back. */
function dropPendingCard(island: Island): void {
if (!State.pendingApproval) return;
- State.pendingApproval = null;
- State.isPinned = false;
+ State.endApproval();
island.dropPin();
- State.updateTask(CLAUDE_ID, "working");
- State.setPillBadge(CLAUDE_ID, null);
if (State.view === "approval" || State.view === "question") {
island.setView(State.defaultView());
}
@@ -323,7 +320,8 @@ function handleHook(island: Island, payload: HookPayload) {
State.updateTask(agentId, "finished");
if (payload.message) State.appendStep(agentId, payload.message.slice(0, 60));
Sound.play("finish");
- if (focused) surface("finished", true);
+ // A card waiting for an answer is never covered by another alert.
+ if (focused && !State.pendingApproval) surface("finished", true);
else State.setPillBadge(agentId, "finished");
cancelStopTimer(agentId);
stopTimers.set(
@@ -344,7 +342,7 @@ function handleHook(island: Island, payload: HookPayload) {
supersedeStop();
State.updateTask(agentId, "error");
Sound.play("error");
- if (focused) surface("error", true);
+ if (focused && !State.pendingApproval) surface("error", true);
else State.setPillBadge(agentId, "error");
break;
@@ -394,28 +392,23 @@ function handleHook(island: Island, payload: HookPayload) {
// shows the options and sends back the one that was picked.
const questions = askedQuestions(tool, input);
const view = questions ? "question" : "approval";
- State.pendingApproval = {
+ // The card always comes up, even over another pill or an island that is
+ // already open: its pill comes to the front, and the one you were on
+ // comes back once you answer (Mac #117, #120).
+ State.beginApproval({
requestId,
- sessionId: payload.session_id ?? "",
+ sessionId,
+ pillId: agentId,
tool,
command: approvalTarget(tool, input),
...(questions ? { questions } : {}),
- };
+ });
// The relay's short ack window closes in 800 ms; everything below this
// line is synchronous, so the card really is up by the time it lands.
if (requestId) void Bridge.approvalAck(requestId);
- State.updateTask(CLAUDE_ID, view);
- State.isPinned = true;
+ State.updateTask(agentId, view);
Sound.play(view);
- if (focused) {
- island.alert(view);
- } else {
- // Another agent holds the view, so the card would yank it away. The badge
- // is the signal instead — but it has to be on screen for that to mean
- // anything, hence the reveal. We just told the relay a human can act.
- State.setPillBadge(CLAUDE_ID, "approval");
- island.reveal();
- }
+ island.alert(view);
// Coucou answers within 108 s or not at all; after that the terminal has
// taken over and the card would be lying.
pendingTimeout = window.setTimeout(() => {
diff --git a/windows/src/island/island.ts b/windows/src/island/island.ts
index 322a4a7f..384cf408 100644
--- a/windows/src/island/island.ts
+++ b/windows/src/island/island.ts
@@ -104,14 +104,23 @@ export class Island {
/** The request has its answer: the card goes and the session carries on. */
private closeApproval() {
- State.pendingApproval = null;
- State.isPinned = false;
+ State.endApproval();
this.fsm.pinned = false;
- State.updateTask("integration_claude", "working");
- State.setPillBadge("integration_claude", null);
this.setView(State.defaultView());
}
+ /**
+ * Folds a card that is waiting for an answer down to the compact island,
+ * without answering it (Mac #290). Nothing is decided: the request keeps
+ * waiting, the island stays on screen, and opening it shows the card again.
+ */
+ foldApproval() {
+ if (!State.pendingApproval || State.mode !== "expanded") return;
+ State.isPinned = true;
+ this.fsm.pinned = true;
+ this.fsm.forcePetit();
+ }
+
// ── DOM ─────────────────────────────────────────────────────────────────────
private build() {
@@ -119,6 +128,7 @@ export class Island {
setView: (v) => this.setView(v),
cancelDrop: () => this.discardDrop(),
collapse: () => this.collapse(),
+ foldApproval: () => this.foldApproval(),
setFocus: (id) => {
State.setFocus(id);
Sound.play("blip");
@@ -287,7 +297,8 @@ export class Island {
if (mode === "expanded") Sound.play("open");
if (prev === "expanded") {
Sound.play("close");
- State.isPinned = false;
+ // A folded card is still waiting: it keeps the island pinned.
+ if (!State.pendingApproval) State.isPinned = false;
void Bridge.focusWindow(false);
}
if (mode !== "expanded") {
@@ -338,6 +349,11 @@ export class Island {
}
collapse() {
+ // A waiting card is only ever folded, never dropped by a close.
+ if (State.pendingApproval) {
+ this.foldApproval();
+ return;
+ }
State.isPinned = false;
this.fsm.pinned = false;
// Drive the state machine rather than the mode: setting the mode behind its
@@ -360,6 +376,8 @@ export class Island {
/** An alert stopped waiting for an answer: let the island auto-close again. */
dropPin() {
this.fsm.pinned = false;
+ // The countdown the pin held back starts now, if the mouse is elsewhere.
+ if (!this.wasInIsland) this.fsm.mouseLeft();
}
// ── File drop ───────────────────────────────────────────────────────────────
@@ -580,8 +598,14 @@ export class Island {
}
});
+ // Only keys typed into the island itself land here, never Escape typed in
+ // a terminal — so it may fold a waiting card away, as Escape in the notch
+ // does on macOS.
window.addEventListener("keydown", (e) => {
- if (e.key === "Escape" && State.mode === "expanded" && !State.isPinned) this.collapse();
+ if (e.key === "Escape" && State.mode === "expanded") {
+ if (State.pendingApproval) this.foldApproval();
+ else if (!State.isPinned) this.collapse();
+ }
State.lastActivity = performance.now();
});
diff --git a/windows/src/style.css b/windows/src/style.css
index 335ed159..07f6bae6 100644
--- a/windows/src/style.css
+++ b/windows/src/style.css
@@ -444,6 +444,14 @@ body {
z-index: 2;
}
+/* Folds a waiting permission card or question away without answering it. */
+.fold {
+ position: absolute;
+ top: 8px;
+ right: 10px;
+ z-index: 2;
+}
+
/* Ticker */
.ticker {
diff --git a/windows/src/views/icons.ts b/windows/src/views/icons.ts
index d2ff8247..464e9912 100644
--- a/windows/src/views/icons.ts
+++ b/windows/src/views/icons.ts
@@ -20,6 +20,8 @@ export const ICONS = {
// chevron.right
chevronRight: "M9 5.5 15.5 12 9 18.5",
chevronLeft: "M15 5.5 8.5 12 15 18.5",
+ // chevron.up
+ chevronUp: "M5.5 15 12 8.5 18.5 15",
// checkmark
check: "M5 12.5 9.5 17 19 7.5",
// arrow.up (send)
diff --git a/windows/src/views/views.ts b/windows/src/views/views.ts
index 4a7186c3..d7761036 100644
--- a/windows/src/views/views.ts
+++ b/windows/src/views/views.ts
@@ -18,6 +18,8 @@ export interface ViewActions {
/** "Cancel" on a dropped file: forgets it and goes back home. */
cancelDrop(): void;
collapse(): void;
+ /** Folds a waiting card to the compact island without answering it. */
+ foldApproval(): void;
setFocus(id: string): void;
openTerminal(): void;
/** The ↗ button: opens whatever the focused pill points at. */
@@ -310,11 +312,25 @@ function buildEmpty(actions: ViewActions): ViewHost {
/** How long a fresh permission card ignores clicks on its buttons. */
const CLICK_GUARD_MS = 600;
+/**
+ * The ⌃ in the corner of a waiting card: folds the island to its compact size
+ * and leaves the request waiting — nothing is answered (Mac #290). Opening the
+ * island again brings the card back.
+ */
+function foldButton(actions: ViewActions): HTMLElement {
+ return h(
+ "button",
+ { class: "icon-btn fold", title: "Later — keep it waiting", onclick: () => actions.foldApproval() },
+ svg(ICONS.chevronUp, 8, { stroke: 2.4 }),
+ );
+}
+
function buildApproval(actions: ViewActions): ViewHost {
const who = h("div");
const code = h("div", { class: "code" });
const row = h("div", { class: "actions" });
- const el = h("div", { class: "view" }, card("amber", stack(116, 16, who, code, row)));
+ const el = h("div", { class: "view" },
+ card("amber", stack(116, 16, who, code, row), foldButton(actions)));
let rowKey = "";
// The card pops up under a cursor that was busy with something else: a click
// meant for the window underneath must not land on Allow. Clicks in the first
@@ -359,7 +375,8 @@ function buildQuestion(actions: ViewActions): ViewHost {
const who = h("div");
const title = h("div", { class: "title question-text" });
const row = h("div", { class: "actions options" });
- const el = h("div", { class: "view" }, card("cyan", stack(116, 16, who, title, row)));
+ const fold = foldButton(actions);
+ const el = h("div", { class: "view" }, card("cyan", stack(116, 16, who, title, row), fold));
// Where we are in the request on screen: which question, what is answered so
// far, and what is ticked in a pick-several question.
@@ -384,6 +401,8 @@ function buildQuestion(actions: ViewActions): ViewHost {
sync() {
const questions = State.pendingApproval?.questions;
clear(who);
+ // Only a request that is waiting can be folded away and come back.
+ fold.style.display = State.pendingApproval ? "" : "none";
// A question that arrived as a notification has nothing to pick from.
if (!questions) {
diff --git a/windows/tests/fsm.test.mjs b/windows/tests/fsm.test.mjs
index 06156a9d..9b51ae2f 100644
--- a/windows/tests/fsm.test.mjs
+++ b/windows/tests/fsm.test.mjs
@@ -278,6 +278,31 @@ test("the deadline the countdown bar reads follows the delay and clears with the
assert.equal(fsm.homeCollapseDueAt, null);
});
+// ── A card folded away while it waits (Mac #290) ─────────────────────────────
+
+test("a folded card keeps the compact island on screen until it is answered", () => {
+ fsm.forceHome();
+ fsm.pinned = true;
+ fsm.forcePetit();
+ fsm.mouseLeft();
+ seconds(600);
+ assert.equal(fsm.state, "petit");
+ // Reopening brings it back open, and the mouse leaving does not fold it.
+ fsm.mouseEntered();
+ fsm.click();
+ fsm.mouseLeft();
+ seconds(600);
+ assert.equal(fsm.state, "home");
+ // Answered: the usual timers again.
+ fsm.pinned = false;
+ fsm.mouseLeft();
+ seconds(15);
+ assert.equal(fsm.state, "petit");
+ fsm.mouseLeft();
+ seconds(60);
+ assert.equal(fsm.state, "hidden");
+});
+
test("an unusable delay is ignored", () => {
for (const bad of [NaN, -1, Infinity]) fsm.homeToPetitDelay = bad;
assert.equal(fsm.homeToPetitDelay, 15);
diff --git a/windows/tests/hooks.test.mjs b/windows/tests/hooks.test.mjs
index ffa7a512..b5e2f7b5 100644
--- a/windows/tests/hooks.test.mjs
+++ b/windows/tests/hooks.test.mjs
@@ -299,6 +299,7 @@ test("a permission request puts the card up, says exactly what it authorises, an
assert.deepEqual(State.pendingApproval, {
requestId: "r1",
sessionId: "s1",
+ pillId: CLAUDE,
tool: "Write",
command: "Write · C:\\Users\\me\\proj\\.env",
});
@@ -323,12 +324,71 @@ test("the card names the most specific thing the tool carries", () => {
assert.equal(target(undefined, undefined), "Tool");
});
-test("a request behind another pill badges and reveals instead of taking the view", () => {
+test("a request behind another pill comes to the front, and that pill comes back after (Mac #120)", () => {
State.setFocus("integration_n8n");
ask("r1");
- assert.deepEqual(asked, ["reveal"]);
- assert.equal(task().pillBadge, "approval");
+ assert.deepEqual(asked, ["alert:approval"]);
+ assert.equal(State.focusId, CLAUDE);
assert.deepEqual(sent("approval_ack"), [{ requestId: "r1" }]);
+ State.endApproval();
+ assert.equal(State.focusId, "integration_n8n");
+ assert.equal(State.isPinned, false);
+ assert.equal(task().state, "working");
+});
+
+test("the pill you were on comes back after a withdrawn card too", () => {
+ State.setFocus("integration_n8n");
+ ask("r1");
+ seconds(110);
+ assert.equal(State.pendingApproval, null);
+ assert.equal(State.focusId, "integration_n8n");
+});
+
+test("a pill picked while the card was up keeps the front after the answer", () => {
+ State.setFocus("integration_n8n");
+ ask("r1");
+ State.setFocus("integration_github");
+ State.endApproval();
+ assert.equal(State.focusId, "integration_github");
+});
+
+test("the card shows when the island is already open, and is what it reopens on", () => {
+ State.mode = "expanded";
+ ask("r1");
+ assert.deepEqual(asked, ["alert:approval"]);
+ assert.equal(State.defaultView(), "approval");
+ State.endApproval();
+ assert.equal(State.defaultView(), "overview");
+});
+
+test("a question is what the island reopens on while it waits", () => {
+ ask("r1", {
+ tool_name: "AskUserQuestion",
+ tool_input: { questions: [{ question: "Which?", options: [{ label: "A" }, { label: "B" }] }] },
+ });
+ assert.equal(State.defaultView(), "question");
+});
+
+test("a finished or failed session behind a waiting card only badges its pill", () => {
+ State.settings.activeIntegrations = ["agent_gemini"];
+ State.loadIntegrationTasks();
+ hook({ hook_event_name: "SessionStart", coucou_agent: "gemini" });
+ ask("r1");
+ asked = [];
+ State.focusId = "agent_gemini";
+ hook({ hook_event_name: "Stop", coucou_agent: "gemini" });
+ hook({ hook_event_name: "StopFailure", coucou_agent: "gemini" });
+ assert.deepEqual(asked, []);
+ assert.equal(task("agent_gemini").pillBadge, "error");
+});
+
+test("a request from Claude Code in Cursor's terminal goes on the Cursor pill", () => {
+ ask("r1", { term_editor: "cursor" });
+ assert.equal(State.pendingApproval.pillId, "agent_cursor");
+ assert.equal(task("agent_cursor").state, "approval");
+ assert.equal(task("agent_cursor").name, "proj");
+ assert.equal(State.focusId, "agent_cursor");
+ assert.equal(task().state, "idle");
});
test("a second request never replaces the card: it goes back to the terminal", () => {
@@ -407,11 +467,12 @@ test("a permission request within 5.2 s of a stop keeps its card", () => {
assert.equal(State.pendingApproval.requestId, "r1");
});
-test("a permission request behind another pill keeps its badge past the stop timer", () => {
+test("a permission request behind another pill keeps the front past the stop timer", () => {
State.setFocus("integration_n8n");
afterStop(() => ask("r1"));
assert.equal(task().state, "approval");
- assert.equal(task().pillBadge, "approval");
+ assert.equal(State.focusId, CLAUDE);
+ assert.equal(State.pendingApproval.requestId, "r1");
});
test("a rate limit within 5.2 s of a stop stays a rate limit", () => {