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.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Island: agents' approvals on their own pill, and the wording fixed
Claude7deafb10e80b
diff --git a/windows/src/core/state.ts b/windows/src/core/state.tsindex 4785897a..cb0d1557 100644--- a/windows/src/core/state.ts+++ b/windows/src/core/state.ts@@ -29,6 +29,8 @@ export interface AgentTask {export interface ApprovalInfo {requestId: string;sessionId: string;+ /** The pill the request belongs to: Claude Code's, or an agent's (Codex…). */+ pillId: string;tool: string;command: string;/** Set when Claude Code is asking a question rather than for a permission. */diff --git a/windows/src/island/agents.ts b/windows/src/island/agents.tsnew file mode 100644index 00000000..68ccc6ce--- /dev/null+++ b/windows/src/island/agents.ts@@ -0,0 +1,52 @@+// Agents other than Claude Code, as the island shows them. Ids, names and colours+// are PillCatalog.swift's (pill `agent_<id>`), so a pill looks the same on every+// platform.++export interface KnownAgent {+ name: string;+ color: string;+}++export const KNOWN_AGENTS: Record<string, KnownAgent> = {+ cursor: { name: "Cursor", color: "#C0C4CC" },+ antigravity: { name: "Antigravity", color: "#E879F9" },+ codex: { name: "Codex", color: "#2DD4BF" },+ gemini: { name: "Gemini CLI", color: "#8AB4F8" },+ copilot: { name: "Copilot CLI", color: "#818CF8" },+ muse: { name: "Muse Code", color: "#38BDF8" },+ opencode: { name: "OpenCode", color: "#4ADE80" },+ amp: { name: "Amp", color: "#F59E0B" },+ hermes: { name: "Hermes", color: "#C084FC" },+ "claude-desktop": { name: "Claude Desktop", color: "#D97757" },+};++/**+ * Agents whose permission requests get an Allow / Deny card, as on the Mac.+ * Must match `takes_decisions` in the relay (hook/src/reply.rs): any other+ * agent's request is handed straight back to its terminal.+ */+export const APPROVAL_AGENTS = new Set(["codex", "copilot", "muse"]);++/** Same rule as HookServer.validateAgent on macOS. "claude" is reserved. */+export function validateAgent(raw: string | undefined): string | null {+ if (!raw || raw.length > 24 || raw === "claude") return null;+ if (!/^[a-z0-9-]+$/.test(raw)) return null;+ return raw;+}++const FALLBACK_COLORS = ["#22C55E", "#EAB308", "#60A5FA", "#E879F9"];++export function agentColor(id: string): string {+ const known = KNOWN_AGENTS[id];+ if (known) return known.color;+ let h = 0;+ for (let i = 0; i < id.length; i++) {+ h = (Math.imul(31, h) + id.charCodeAt(i)) | 0;+ }+ return FALLBACK_COLORS[Math.abs(h) % FALLBACK_COLORS.length];+}++/** The pill label: the agent's own name when Coucou knows it, else its id. */+export function agentName(id: string): string {+ return KNOWN_AGENTS[id]?.name ?? id;+}diff --git a/windows/src/island/hooks.ts b/windows/src/island/hooks.tsindex bd87e3a6..fe580f88 100644--- a/windows/src/island/hooks.ts+++ b/windows/src/island/hooks.ts@@ -1,11 +1,14 @@-// Claude Code hook events → island state.+// Hook events from Claude Code and every other agent → island state.// Port of HookServer.processEvent / processPermissionRequest from the macOS app.// Difference from macOS: no terminal filter. On Windows the hook fires from any// terminal (Windows Terminal, VS Code, PowerShell…) and all of them are handled.+// The relay has already mapped every agent's events and fields onto Claude+// Code's (hook/src/normalize.rs), so one handler serves them all.import { Bridge, onEvent } from "../core/bridge";import { Sound } from "../core/sound";import { State, type AskedQuestion } from "../core/state";+import { APPROVAL_AGENTS, agentColor, agentName, validateAgent } from "./agents";import type { Island } from "./island";const CLAUDE_ID = "integration_claude";@@ -16,11 +19,12 @@ 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;+ const pill = State.pendingApproval.pillId;State.pendingApproval = null;State.isPinned = false;island.dropPin();- State.updateTask(CLAUDE_ID, "working");- State.setPillBadge(CLAUDE_ID, null);+ State.updateTask(pill, "working");+ State.setPillBadge(pill, null);if (State.view === "approval" || State.view === "question") {island.setView(State.defaultView());}@@ -38,12 +42,17 @@ function cancelStopTimer(id: string): boolean {return true;}+/** Events after which a pending permission request of the same session is moot. */+const TURN_OVER = new Set(["Stop", "StopFailure", "UserPromptSubmit", "SessionEnd", "Interrupt"]);+interface HookPayload {hook_event_name?: string;request_id?: string;session_id?: string;cwd?: string;message?: string;+ /** What an agent said last, on Stop (Hermes, Codex). */+ last_assistant_message?: string;/** UserPromptSubmit carries `prompt`; `message` belongs to Notification/Stop. */prompt?: string;tool_name?: string;@@ -52,44 +61,6 @@ interface HookPayload {coucou_agent?: string;}-/** Same rule as HookServer.validateAgent on macOS. "claude" is reserved. */-function validateAgent(raw: string | undefined): string | null {- if (!raw || raw.length > 24 || raw === "claude") return null;- if (!/^[a-z0-9-]+$/.test(raw)) return null;- return raw;-}--const FALLBACK_COLORS = ["#22C55E", "#EAB308", "#60A5FA", "#E879F9"];--const KNOWN_AGENT_COLORS: Record<string, string> = {- gemini: "#8AB4F8",- antigravity: "#E879F9",- cursor: "#C0C4CC",- codex: "#2DD4BF",- opencode: "#38BDF8",-};--const KNOWN_AGENT_NAMES: Record<string, string> = {- gemini: "Gemini CLI",- antigravity: "Antigravity",- cursor: "Cursor",- codex: "Codex",- opencode: "OpenCode",-};--function agentColor(name: string): string {- if (KNOWN_AGENT_COLORS[name]) return KNOWN_AGENT_COLORS[name];- let h = 0;- for (let i = 0; i < name.length; i++) {- h = (Math.imul(31, h) + name.charCodeAt(i)) | 0;- }- return FALLBACK_COLORS[Math.abs(h) % FALLBACK_COLORS.length];-}--function agentDisplayName(name: string): string {- return KNOWN_AGENT_NAMES[name] ?? name;-}-const PROJECT_ALIASES: Record<string, string> = {"notch-buddy": "Notch Buddy",notchbuddy: "Notch Buddy",@@ -245,7 +216,7 @@ function handleHook(island: Island, payload: HookPayload) {/** Ensure the agent pill exists (no-op for Claude Code). */const ensurePill = () => {if (isExternalAgent) {- State.upsertExternalAgent(agentId, agentDisplayName(validAgent!), agentColor(validAgent!));+ State.upsertExternalAgent(agentId, agentName(validAgent!), agentColor(validAgent!));} else {upsert(projectName, cwd);}@@ -260,6 +231,22 @@ function handleHook(island: Island, payload: HookPayload) {if (cancelStopTimer(agentId)) State.setPillBadge(agentId, null);};+ // The turn that asked for a permission is over — answered in the terminal,+ // interrupted, or a new prompt — so the card would be lying. It goes, and the+ // relay is released without a decision. Same rule as the Mac.+ const pending = State.pendingApproval;+ if (+ pending &&+ TURN_OVER.has(name) &&+ pending.pillId === agentId &&+ pending.sessionId === (payload.session_id ?? "")+ ) {+ if (pendingTimeout != null) window.clearTimeout(pendingTimeout);+ pendingTimeout = null;+ if (pending.requestId) void Bridge.approvalDecline(pending.requestId);+ dropPendingCard(island);+ }+switch (name) {case "SessionStart":ensurePill();@@ -324,9 +311,11 @@ function handleHook(island: Island, payload: HookPayload) {break;}- case "Stop":+ case "Stop": {State.updateTask(agentId, "finished");- if (payload.message) State.appendStep(agentId, payload.message.slice(0, 60));+ // Agents report their last words as `last_assistant_message` (Hermes, Codex).+ const said = payload.message ?? (isExternalAgent ? payload.last_assistant_message : undefined);+ if (said) State.appendStep(agentId, said.slice(0, 60));Sound.play("finish");if (focused) surface("finished", true);else State.setPillBadge(agentId, "finished");@@ -344,6 +333,14 @@ function handleHook(island: Island, payload: HookPayload) {}, 5200),);break;+ }++ case "Interrupt":+ // Codex: the user stopped the turn. Back to idle, nothing to celebrate.+ supersedeStop();+ State.updateTask(agentId, "idle");+ State.setPillBadge(agentId, null);+ break;case "StopFailure":supersedeStop();@@ -374,10 +371,10 @@ function handleHook(island: Island, payload: HookPayload) {break;case "PermissionRequest": {- // External agents do not get an approval card — showing one would look like- // a Claude Code request. Decline immediately so the agent re-asks in its- // terminal. Approval support for other agents will come with Codex support.- if (isExternalAgent) {+ // Only Claude Code and the agents the relay can answer for (Codex, Copilot+ // CLI, Muse Code — same as the Mac) get a card. Anyone else's request is+ // declined at once, so the agent asks in its own terminal.+ if (isExternalAgent && !APPROVAL_AGENTS.has(validAgent!)) {if (payload.request_id) void Bridge.approvalDecline(payload.request_id);break;}@@ -390,18 +387,20 @@ function handleHook(island: Island, payload: HookPayload) {if (requestId) void Bridge.approvalDecline(requestId);break;}- upsert(projectName, cwd);+ ensurePill();supersedeStop();if (pendingTimeout != null) window.clearTimeout(pendingTimeout);const tool = payload.tool_name ?? "Tool";const input = payload.tool_input ?? {};// Claude Code asking a question is not a permission to grant: the island- // shows the options and sends back the one that was picked.- const questions = askedQuestions(tool, input);+ // shows the options and sends back the one that was picked. Only Claude+ // Code asks questions this way.+ const questions = isExternalAgent ? null : askedQuestions(tool, input);const view = questions ? "question" : "approval";State.pendingApproval = {requestId,sessionId: payload.session_id ?? "",+ pillId: agentId,tool,command: approvalTarget(tool, input),...(questions ? { questions } : {}),@@ -409,16 +408,16 @@ function handleHook(island: Island, payload: HookPayload) {// 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.updateTask(agentId, view);State.isPinned = true;Sound.play(view);- if (focused) {+ if (State.focusId === agentId) {island.alert(view);} else {- // Another agent holds the view, so the card would yank it away. The badge+ // Another pill 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");+ // anything, hence the reveal. Clicking the pill brings the card up.+ State.setPillBadge(agentId, "approval");island.reveal();}// Coucou answers within 108 s or not at all; after that the terminal hasdiff --git a/windows/src/island/island.ts b/windows/src/island/island.tsindex 54dbf5f0..4f547d40 100644--- a/windows/src/island/island.ts+++ b/windows/src/island/island.ts@@ -104,11 +104,12 @@ export class Island {/** The request has its answer: the card goes and the session carries on. */private closeApproval() {+ const pill = State.pendingApproval?.pillId ?? "integration_claude";State.pendingApproval = null;State.isPinned = false;this.fsm.pinned = false;- State.updateTask("integration_claude", "working");- State.setPillBadge("integration_claude", null);+ State.updateTask(pill, "working");+ State.setPillBadge(pill, null);this.setView(State.defaultView());}@@ -122,6 +123,10 @@ export class Island {setFocus: (id) => {State.setFocus(id);Sound.play("blip");+ // A pill badged with a waiting request opens on its card: that is how a+ // request that arrived behind another pill gets answered.+ const req = State.pendingApproval;+ if (req?.pillId === id) this.setView(req.questions ? "question" : "approval");},openTerminal: () => {const cwd = State.focusTask?.sessionCwd ?? null;diff --git a/windows/src/views/views.ts b/windows/src/views/views.tsindex d87172f7..f49f714e 100644--- a/windows/src/views/views.ts+++ b/windows/src/views/views.ts@@ -180,10 +180,12 @@ function buildOverview(actions: ViewActions): ViewHost {mode = null;}- // Tasks with live steps or non-idle state keep the ticker; every other- // integration pill shows its own card, exactly like IntegrationCardView.+ // VS Code with a live Claude Code session keeps the ticker, and so does an+ // agent's pill (Gemini CLI, Codex…) — it only exists while its session+ // does. Every other pill shows its own card, exactly like IntegrationCardView.const sessionActive =- task && (!task.isIntegration || task.id === "integration_claude") && (task.state !== "idle" || task.steps.length > 0);+ (task?.id === "integration_claude" && (task.state !== "idle" || task.steps.length > 0)) ||+ (task != null && task.source === "agent" && !task.isIntegration);if (task && sessionActive) {if (mode !== "ticker") {@@ -193,7 +195,9 @@ function buildOverview(actions: ViewActions): ViewHost {cardKey = "";}clear(who);- const toolLabel = task.source === "claudeCode" ? "Claude Code" : task.source === "agent" ? task.name : "n8n";+ // The agent's name is already the pill's: the label says what kind of+ // pill it is, as on the Mac.+ const toolLabel = task.source === "claudeCode" ? "Claude Code" : task.source === "agent" ? "Agent" : "n8n";who.append(dot(task.color, 7),h("span", { class: "name", text: task.name }),@@ -452,7 +456,8 @@ function buildError(actions: ViewActions): ViewHost {sync() {const task = State.focusTask;clear(who);- const whoLabel = task?.source === "n8n" ? "n8n" : (task?.name ?? "Agent");+ // agentWho already shows an agent's name: its label is just the kind.+ const whoLabel = task?.source === "n8n" ? "n8n" : task?.source === "agent" ? "Agent" : "Claude Code";who.append(agentWho(task, whoLabel));title.textContent = task?.source === "n8n" ? "Workflow stopped." : "Session stopped on an error.";detail.textContent = task?.steps.at(-1) ?? "No detail available.";@@ -474,8 +479,8 @@ function buildFinished(actions: ViewActions): ViewHost {el,sync() {clear(who);- const name = State.focusTask?.name ?? "Agent";- who.append(agentWho(State.focusTask, `${name} finished`));+ const agent = State.focusTask?.source === "agent";+ who.append(agentWho(State.focusTask, agent ? "finished" : "Claude Code finished"));title.textContent = State.focusTask?.steps.at(-1) ?? "Session finished";},};diff --git a/windows/tests/agents.test.mjs b/windows/tests/agents.test.mjsnew file mode 100644index 00000000..3b210cab--- /dev/null+++ b/windows/tests/agents.test.mjs@@ -0,0 +1,38 @@+// Agents other than Claude Code (src/island/agents.ts): the pill names and+// colours of PillCatalog.swift, and who may get an approval card.++import { test } from "node:test";+import assert from "node:assert/strict";+import {+ APPROVAL_AGENTS, KNOWN_AGENTS, agentColor, agentName, validateAgent,+} from "../src/island/agents.ts";++test("known agents carry the Mac's names and colours", () => {+ assert.equal(agentName("gemini"), "Gemini CLI");+ assert.equal(agentColor("gemini"), "#8AB4F8");+ assert.equal(agentName("copilot"), "Copilot CLI");+ assert.equal(agentColor("codex"), "#2DD4BF");+ assert.equal(agentColor("cursor"), "#C0C4CC");+ for (const [id, { color }] of Object.entries(KNOWN_AGENTS)) {+ assert.equal(validateAgent(id), id, id);+ assert.match(color, /^#[0-9A-F]{6}$/, id);+ }+});++test("an unknown agent keeps its id and gets a stable colour", () => {+ assert.equal(agentName("my-tool"), "my-tool");+ assert.equal(agentColor("my-tool"), agentColor("my-tool"));+ assert.match(agentColor("my-tool"), /^#[0-9A-F]{6}$/);+});++test("the agent tag is checked the Mac's way, and claude is reserved", () => {+ for (const bad of ["claude", "Gemini", "has space", "a".repeat(25), "", undefined, "x_y"]) {+ assert.equal(validateAgent(bad), null, String(bad));+ }+ assert.equal(validateAgent("a".repeat(24)), "a".repeat(24));+});++test("approval cards are for the agents the relay answers, no one else", () => {+ // Must match takes_decisions() in hook/src/reply.rs.+ assert.deepEqual([...APPROVAL_AGENTS].sort(), ["codex", "copilot", "muse"]);+});diff --git a/windows/tests/hooks.test.mjs b/windows/tests/hooks.test.mjsindex d99862fb..e8d5356d 100644--- a/windows/tests/hooks.test.mjs+++ b/windows/tests/hooks.test.mjs@@ -242,10 +242,85 @@ test("an agent's pill goes away when its session ends, or 5.2 s after it stops",});test("an agent's permission request is declined, never shown as Claude Code's", () => {- hook({ hook_event_name: "PermissionRequest", request_id: "r1", coucou_agent: "gemini", tool_name: "Bash" });- assert.deepEqual(sent("approval_decline"), [{ requestId: "r1" }]);- assert.deepEqual(sent("approval_ack"), []);- assert.equal(State.pendingApproval, null);+ for (const agent of ["gemini", "antigravity", "cursor", "opencode", "amp", "hermes", "my-tool"]) {+ calls.length = 0;+ hook({ hook_event_name: "PermissionRequest", request_id: "r1", coucou_agent: agent, tool_name: "Bash" });+ assert.deepEqual(sent("approval_decline"), [{ requestId: "r1" }], agent);+ assert.deepEqual(sent("approval_ack"), [], agent);+ assert.equal(State.pendingApproval, null, agent);+ }+});++test("Codex, Copilot CLI and Muse Code get the card on their own pill", () => {+ for (const agent of ["codex", "copilot", "muse"]) {+ State.pendingApproval = null;+ State.focusId = CLAUDE;+ calls.length = 0;+ asked = [];+ hook({+ hook_event_name: "PermissionRequest", request_id: `r-${agent}`, session_id: "s1",+ coucou_agent: agent, tool_name: "Bash", tool_input: { command: "npm publish" },+ });+ const id = `agent_${agent}`;+ assert.deepEqual(State.pendingApproval, {+ requestId: `r-${agent}`, sessionId: "s1", pillId: id, tool: "Bash", command: "Bash · npm publish",+ });+ assert.deepEqual(sent("approval_ack"), [{ requestId: `r-${agent}` }]);+ assert.deepEqual(sent("approval_decline"), []);+ // Behind Claude Code's pill: badged and revealed, the view is not taken.+ assert.equal(task(id).state, "approval");+ assert.equal(task(id).pillBadge, "approval");+ assert.deepEqual(asked, ["reveal"]);+ // Claude Code's pill is untouched.+ assert.equal(task().state, "idle");+ assert.equal(task().pillBadge ?? null, null);+ }+});++test("an agent's card comes up at once when its pill has the focus", () => {+ hook({ hook_event_name: "SessionStart", session_id: "s1", coucou_agent: "codex" });+ State.setFocus("agent_codex");+ asked = [];+ hook({ hook_event_name: "PermissionRequest", request_id: "r1", session_id: "s1", coucou_agent: "codex", tool_name: "Bash" });+ assert.deepEqual(asked, ["alert:approval"]);+});++test("only Claude Code's questions become a question card", () => {+ hook({+ hook_event_name: "PermissionRequest", request_id: "r1", session_id: "s1", coucou_agent: "codex",+ tool_name: "AskUserQuestion",+ tool_input: { questions: [{ question: "Which?", options: [{ label: "A" }, { label: "B" }] }] },+ });+ assert.equal(State.pendingApproval.questions, undefined);+ assert.equal(task("agent_codex").state, "approval");+});++test("the end of the turn takes a waiting card down and releases the relay", () => {+ for (const end of ["Stop", "StopFailure", "UserPromptSubmit", "SessionEnd", "Interrupt"]) {+ State.pendingApproval = null;+ calls.length = 0;+ hook({ hook_event_name: "PermissionRequest", request_id: "r1", session_id: "s1", coucou_agent: "codex", tool_name: "Bash" });+ // Another session's turn ending changes nothing.+ hook({ hook_event_name: end, session_id: "other", coucou_agent: "codex" });+ assert.equal(State.pendingApproval?.requestId, "r1", end);+ hook({ hook_event_name: end, session_id: "s1", coucou_agent: "codex" });+ assert.equal(State.pendingApproval, null, end);+ assert.deepEqual(sent("approval_decline"), [{ requestId: "r1" }], end);+ mock.timers.runAll();+ }+});++test("Codex's Interrupt puts its pill back to idle", () => {+ hook({ hook_event_name: "UserPromptSubmit", session_id: "s1", coucou_agent: "codex", prompt: "go" });+ assert.equal(task("agent_codex").state, "thinking");+ hook({ hook_event_name: "Interrupt", session_id: "s1", coucou_agent: "codex" });+ assert.equal(task("agent_codex").state, "idle");+});++test("an agent's last words show when it stops", () => {+ hook({ hook_event_name: "SessionStart", coucou_agent: "hermes" });+ hook({ hook_event_name: "Stop", coucou_agent: "hermes", last_assistant_message: "All done, tests pass." });+ assert.deepEqual(task("agent_hermes").steps, ["All done, tests pass."]);});// ── Permission requests ───────────────────────────────────────────────────────@@ -266,6 +341,7 @@ test("a permission request puts the card up, says exactly what it authorises, anassert.deepEqual(State.pendingApproval, {requestId: "r1",sessionId: "s1",+ pillId: CLAUDE,tool: "Write",command: "Write · C:\\Users\\me\\proj\\.env",});