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 pill catalog, your main tool and declared pills (Mac 0.1.1, #120, #183)

Claudea9c57d7b89ba
diff --git a/windows/src-tauri/src/settings.rs b/windows/src-tauri/src/settings.rs
index 17f63e1c..05a09cf4 100644
--- a/windows/src-tauri/src/settings.rs
+++ b/windows/src-tauri/src/settings.rs
@@ -17,6 +17,8 @@ pub struct Settings {
pub auto_close_interval: f64,
pub absence_interval: f64,
pub active_integrations: Vec<String>,
+ /// The always-on workspace pill (src/core/pills.ts checks it is one).
+ pub main_pill: String,
/// "primary" = the main display, "cursor" = whichever display the mouse is on.
pub screen: String,
pub autostart: bool,
@@ -42,6 +44,7 @@ impl Default for Settings {
"integration_vercel".into(),
"integration_github".into(),
],
+ main_pill: "integration_claude".into(),
screen: "primary".into(),
autostart: false,
hooks_installed: false,
@@ -303,6 +306,7 @@ mod tests {
"autoCloseInterval": 30.0,
"absenceInterval": 60.0,
"activeIntegrations": ["integration_notion"],
+ "mainPill": "agent_cursor",
"screen": "cursor",
"autostart": true,
"hooksInstalled": true,
@@ -413,6 +417,7 @@ mod tests {
("soundVolume", json!("loud")),
("soundEnabled", json!(1)),
("activeIntegrations", json!("integration_n8n")),
+ ("mainPill", json!(["agent_cursor"])),
("screen", Value::Null),
] {
let loaded = parse(&custom_with(key, Some(wrong)))
@@ -628,6 +633,7 @@ mod tests {
"autoCloseInterval",
"absenceInterval",
"activeIntegrations",
+ "mainPill",
"screen",
"autostart",
"hooksInstalled",
diff --git a/windows/src/core/pills.ts b/windows/src/core/pills.ts
new file mode 100644
index 00000000..efb797cf
--- /dev/null
+++ b/windows/src/core/pills.ts
@@ -0,0 +1,237 @@
+// Every pill the island can show — port of PillCatalog.swift, the single source
+// of truth on macOS. IDs, names, colours, categories and subtitles are the Mac's,
+// in the Mac's order: they are contract values (settings, hook routing), so an
+// ID here never changes once shipped.
+//
+// What is added for Windows and Linux is `support` — not every Mac pill has
+// something behind it here — and `connect`, which says what makes the pill
+// "connected": its hooks being installed, a key in the OS credential store, or
+// nothing at all.
+
+import type { AgentSource } from "./state";
+
+export type PillCategory = "workspace" | "agent" | "ai" | "service";
+
+/** Section titles, in display order. */
+export const PILL_CATEGORIES: { id: PillCategory; title: string }[] = [
+ { id: "workspace", title: "Where you code" },
+ { id: "agent", title: "Agents" },
+ { id: "ai", title: "AI for the chat" },
+ { id: "service", title: "Services" },
+];
+
+/**
+ * Whether the pill does anything on this build:
+ * - `yes`: works on Windows and Linux;
+ * - `windows`: Windows only (the app behind it has no Linux build);
+ * - `soon`: can be declared, shows "Coming soon" (macOS has it, this build not yet);
+ * - `no`: macOS only, never offered here.
+ */
+export type PillSupport = "yes" | "windows" | "soon" | "no";
+
+/** What makes the pill connected. */
+export type PillConnect =
+ /** Hook events: connected once the hooks are installed (Mac #183). */
+ | { kind: "hooks" }
+ /** A key in the credential store. */
+ | { kind: "key"; key: string }
+ /** Nothing to set up. */
+ | { kind: "none" };
+
+export interface PillDefinition {
+ id: string;
+ name: string;
+ color: string;
+ category: PillCategory;
+ /** Label next to the pill name in the idle card header. */
+ subtitle: string;
+ source: AgentSource;
+ support: PillSupport;
+ connect: PillConnect;
+}
+
+export type HostOs = "windows" | "linux";
+
+const hooks: PillConnect = { kind: "hooks" };
+const key = (k: string): PillConnect => ({ kind: "key", key: k });
+const none: PillConnect = { kind: "none" };
+
+/** ChatProvider.accentHex on macOS. */
+const ACCENT = {
+ anthropic: "#E07950",
+ google: "#4285F4",
+ openai: "#10A37F",
+ ollama: "#FACC15",
+ lmstudio: "#A3E635",
+};
+
+export const PILL_CATALOG: readonly PillDefinition[] = [
+ // ── Where you code ─────────────────────────────────────────────────────────
+ { id: "integration_claude", name: "VS Code", color: "#F5F6F8", category: "workspace",
+ subtitle: "Integration", source: "claudeCode", support: "yes", connect: hooks },
+ // Claude Code in Cursor's terminal: the same hooks as Claude Code.
+ { id: "agent_cursor", name: "Cursor", color: "#C0C4CC", category: "workspace",
+ subtitle: "Integration", source: "agent", support: "yes", connect: hooks },
+ { id: "agent_antigravity", name: "Antigravity", color: "#E879F9", category: "workspace",
+ subtitle: "Integration", source: "agent", support: "yes", connect: hooks },
+ { id: "agent_codex", name: "Codex", color: "#2DD4BF", category: "workspace",
+ subtitle: "Integration", source: "agent", support: "yes", connect: hooks },
+ // ── Agents ─────────────────────────────────────────────────────────────────
+ { id: "agent_gemini", name: "Gemini CLI", color: "#8AB4F8", category: "agent",
+ subtitle: "Agent", source: "agent", support: "yes", connect: hooks },
+ { id: "agent_copilot", name: "Copilot CLI", color: "#818CF8", category: "agent",
+ subtitle: "Agent", source: "agent", support: "yes", connect: hooks },
+ { id: "agent_muse", name: "Muse Code", color: "#38BDF8", category: "agent",
+ subtitle: "Agent", source: "agent", support: "yes", connect: hooks },
+ // Their integration is a plugin with macOS paths, installed by the Mac app only.
+ { id: "agent_opencode", name: "OpenCode", color: "#4ADE80", category: "agent",
+ subtitle: "Agent", source: "agent", support: "no", connect: hooks },
+ { id: "agent_amp", name: "Amp", color: "#F59E0B", category: "agent",
+ subtitle: "Agent", source: "agent", support: "no", connect: hooks },
+ { id: "agent_hermes", name: "Hermes", color: "#C084FC", category: "agent",
+ subtitle: "Agent", source: "agent", support: "no", connect: hooks },
+ // Claude Code sessions run from the Claude desktop app: the relay tags them
+ // from CLAUDE_CODE_ENTRYPOINT, so there is nothing to install. The app has no
+ // Linux build.
+ { id: "agent_claude-desktop", name: "Claude Desktop", color: "#D97757", category: "agent",
+ subtitle: "Agent", source: "agent", support: "windows", connect: none },
+ // ── AI for the chat ────────────────────────────────────────────────────────
+ { id: "ai_anthropic", name: "Anthropic", color: ACCENT.anthropic, category: "ai",
+ subtitle: "Chat", source: "n8n", support: "yes", connect: key("anthropic-api-key") },
+ // The chat here only talks to Anthropic so far.
+ { id: "ai_google", name: "Google AI", color: ACCENT.google, category: "ai",
+ subtitle: "Chat", source: "n8n", support: "soon", connect: key("google-api-key") },
+ { id: "ai_openai", name: "OpenAI", color: ACCENT.openai, category: "ai",
+ subtitle: "Chat", source: "n8n", support: "soon", connect: key("openai-api-key") },
+ { id: "ai_ollama", name: "Ollama", color: ACCENT.ollama, category: "ai",
+ subtitle: "Chat", source: "n8n", support: "no", connect: none },
+ { id: "ai_lmstudio", name: "LM Studio", color: ACCENT.lmstudio, category: "ai",
+ subtitle: "Chat", source: "n8n", support: "no", connect: none },
+ // ── Services ───────────────────────────────────────────────────────────────
+ { id: "integration_resend", name: "Resend", color: "#22C55E", category: "service",
+ subtitle: "Integration", source: "n8n", support: "yes", connect: key("resend-api-key") },
+ { id: "integration_n8n", name: "n8n", color: "#F29B38", category: "service",
+ subtitle: "Integration", source: "n8n", support: "yes", connect: key("n8n-api-key") },
+ { id: "integration_vercel", name: "Vercel", color: "#7C5CFF", category: "service",
+ subtitle: "Integration", source: "n8n", support: "yes", connect: key("vercel-token") },
+ { id: "integration_github", name: "GitHub", color: "#F4505E", category: "service",
+ subtitle: "Integration", source: "n8n", support: "yes", connect: key("github-token") },
+ { id: "integration_notion", name: "Notion", color: "#8C8C8C", category: "service",
+ subtitle: "Integration", source: "n8n", support: "yes", connect: key("notion-api-key") },
+ { id: "integration_calcom", name: "Cal.com", color: "#C9956A", category: "service",
+ subtitle: "Integration", source: "n8n", support: "yes", connect: key("calcom-api-key") },
+ { id: "integration_stripe", name: "Stripe", color: "#0570DE", category: "service",
+ subtitle: "Integration", source: "n8n", support: "yes", connect: key("stripe-api-key") },
+ { id: "integration_music", name: "Apple Music", color: "#FA2D48", category: "service",
+ subtitle: "Integration", source: "n8n", support: "no", connect: none },
+];
+
+/** The always-on pill unless the user picks another workspace tool. */
+export const DEFAULT_MAIN_PILL = "integration_claude";
+
+/** How many declared pills may sit next to the main one. */
+export const MAX_DECLARED = 4;
+
+/** The OS this page runs on. Only the Windows webview says "Windows". */
+export const HOST_OS: HostOs =
+ typeof navigator !== "undefined" && /Windows/.test(navigator.userAgent ?? "") ? "windows" : "linux";
+
+export function pillDefinition(id: string): PillDefinition | undefined {
+ return PILL_CATALOG.find((p) => p.id === id);
+}
+
+function offeredOn(def: PillDefinition, os: HostOs): boolean {
+ return def.support === "yes" || def.support === "soon" || (def.support === "windows" && os === "windows");
+}
+
+/** The pills this build offers, in catalog order. */
+export function availablePills(os: HostOs = HOST_OS): PillDefinition[] {
+ return PILL_CATALOG.filter((p) => offeredOn(p, os));
+}
+
+export function isComingSoon(id: string): boolean {
+ return pillDefinition(id)?.support === "soon";
+}
+
+/** True for pills whose sessions arrive as hook events (Mac #183). */
+export function isHookPill(id: string): boolean {
+ return pillDefinition(id)?.connect.kind === "hooks";
+}
+
+/** Workspace tools that can be the main pill. */
+export function mainPillChoices(os: HostOs = HOST_OS): PillDefinition[] {
+ return availablePills(os).filter((p) => p.category === "workspace" && p.support !== "soon");
+}
+
+/** PillDefinition.sessionSubtitle — next to the name in a live session's card. */
+export function sessionSubtitle(id: string): string {
+ switch (id) {
+ case "integration_claude": return "Claude Code";
+ case "agent_cursor": return "Cursor";
+ case "agent_codex": return "Codex";
+ case "agent_hermes": return "Hermes";
+ case "agent_claude-desktop": return "Claude Desktop";
+ default: return "Agent";
+ }
+}
+
+export interface Declared {
+ mainPill: string;
+ activeIntegrations: string[];
+}
+
+/**
+ * The declaration as it may be used: a main pill this build can run (else the
+ * default), and declared pills this build offers, without duplicates and
+ * without the main pill, which never takes a slot. Same rules as
+ * AppState.loadIntegrationTasks on macOS.
+ */
+export function sanitizeDeclared(d: Declared, os: HostOs = HOST_OS): Declared {
+ const mains = new Set(mainPillChoices(os).map((p) => p.id));
+ const mainPill = mains.has(d.mainPill) ? d.mainPill : DEFAULT_MAIN_PILL;
+ const offered = new Set(availablePills(os).map((p) => p.id));
+ const activeIntegrations: string[] = [];
+ for (const id of d.activeIntegrations ?? []) {
+ if (id !== mainPill && offered.has(id) && !activeIntegrations.includes(id)) {
+ activeIntegrations.push(id);
+ }
+ }
+ return { mainPill, activeIntegrations };
+}
+
+/**
+ * Declares or undeclares a pill. Returns the new list, or null when the click
+ * changes nothing: the main pill is never toggled, an unknown pill never
+ * declared, and a fifth pill never added.
+ */
+export function toggleDeclared(d: Declared, id: string, os: HostOs = HOST_OS): string[] | null {
+ if (id === d.mainPill) return null;
+ if (!availablePills(os).some((p) => p.id === id)) return null;
+ if (d.activeIntegrations.includes(id)) return d.activeIntegrations.filter((x) => x !== id);
+ if (d.activeIntegrations.length >= MAX_DECLARED) return null;
+ return [...d.activeIntegrations, id];
+}
+
+/**
+ * Picks a new main pill. The old main pill is not declared on its own, and the
+ * new one leaves the declared list so it does not take a slot twice.
+ */
+export function chooseMainPill(d: Declared, id: string, os: HostOs = HOST_OS): Declared | null {
+ if (!mainPillChoices(os).some((p) => p.id === id)) return null;
+ return { mainPill: id, activeIntegrations: d.activeIntegrations.filter((x) => x !== id) };
+}
+
+/**
+ * Pill order: the main pill first, then pills from outside the catalog (any
+ * other tagged agent), then the catalog's pills in catalog order. Pills of equal
+ * rank keep their order. Mirrors sortTasksByCatalog on macOS, with the main
+ * pill (not always VS Code here) leading.
+ */
+export function orderPills<T extends { id: string }>(tasks: T[], mainPill: string): T[] {
+ const index = new Map(PILL_CATALOG.map((p, i) => [p.id, i]));
+ const rank = (t: T) => (t.id === mainPill ? -2 : index.has(t.id) ? index.get(t.id)! : -1);
+ return tasks
+ .map((t, i) => ({ t, i }))
+ .sort((a, b) => rank(a.t) - rank(b.t) || a.i - b.i)
+ .map(({ t }) => t);
+}
diff --git a/windows/src/core/state.ts b/windows/src/core/state.ts
index 4785897a..628d1ef4 100644
--- a/windows/src/core/state.ts
+++ b/windows/src/core/state.ts
@@ -2,6 +2,10 @@
import type { BotEmoteName, BotStateName, IslandMode, IslandViewName } from "./layout";
import type { EyeShape } from "../mochi/engine";
+import {
+ DEFAULT_MAIN_PILL, HOST_OS, availablePills, orderPills, pillDefinition, sanitizeDeclared,
+ toggleDeclared, type HostOs, type PillDefinition,
+} from "./pills";
export type AgentSource = "claudeCode" | "n8n" | "agent";
export type PillBadge = "approval" | "finished" | "error";
@@ -24,6 +28,8 @@ export interface AgentTask {
miniEye?: EyeShape | null;
pillBadge?: PillBadge | null;
sessionCwd?: string | null;
+ /** Claude Code's session, so "Open terminal" can find the window it runs in. */
+ sessionId?: string | null;
}
export interface ApprovalInfo {
@@ -64,28 +70,13 @@ export interface SearchResult {
note?: string;
}
-const task = (
- id: string, name: string, color: string, source: AgentSource,
-): AgentTask => ({
- id, name, color, state: "idle", stepIndex: 0, steps: [], source, isIntegration: true,
-});
-
-/** AgentTask.integrationAgents — same ids, names and colours as macOS. */
-export const INTEGRATION_AGENTS: AgentTask[] = [
- task("integration_claude", "VS Code", "#F5F6F8", "claudeCode"),
- task("integration_resend", "Resend", "#22C55E", "n8n"),
- task("integration_n8n", "n8n", "#F29B38", "n8n"),
- task("integration_vercel", "Vercel", "#7C5CFF", "n8n"),
- task("integration_github", "GitHub", "#F4505E", "n8n"),
- task("integration_notion", "Notion", "#8C8C8C", "n8n"),
- task("integration_calcom", "Cal.com", "#C9956A", "n8n"),
- task("integration_stripe", "Stripe", "#0570DE", "n8n"),
-];
-
-export const TOGGLEABLE_INTEGRATION_IDS = [
- "integration_resend", "integration_n8n", "integration_vercel", "integration_github",
- "integration_notion", "integration_calcom", "integration_stripe",
-];
+/** A fresh, idle task for a catalog pill. */
+function taskFor(def: PillDefinition, name = def.name): AgentTask {
+ return {
+ id: def.id, name, color: def.color, state: "idle", stepIndex: 0, steps: [],
+ source: def.source, isIntegration: true,
+ };
+}
/** What an integration poller last reported. */
export interface IntegrationInfo {
@@ -100,7 +91,10 @@ export interface Settings {
soundVolume: number;
autoCloseInterval: number;
absenceInterval: number;
+ /** Declared pills next to the main one (at most 4), in the order they were added. */
activeIntegrations: string[];
+ /** The always-on workspace pill: VS Code, Cursor, Codex or Antigravity. */
+ mainPill: string;
/** "primary", "cursor", or `at:<x>,<y>` for one display (logical origin). */
screen: string;
autostart: boolean;
@@ -117,6 +111,7 @@ export const DEFAULT_SETTINGS: Settings = {
activeIntegrations: [
"integration_resend", "integration_n8n", "integration_vercel", "integration_github",
],
+ mainPill: DEFAULT_MAIN_PILL,
screen: "primary",
autostart: false,
hooksInstalled: false,
@@ -159,6 +154,9 @@ class AppState {
settings: Settings = { ...DEFAULT_SETTINGS };
+ /** Which pills this build offers depends on it (Claude Desktop is Windows only). */
+ os: HostOs = HOST_OS;
+
private listeners = new Set<Listener>();
subscribe(fn: Listener): () => void {
@@ -216,67 +214,111 @@ class AppState {
this.notify();
}
- /** loadIntegrationTasks() — VS Code always on, the rest opt-in (max 4). */
+ /** The always-on workspace pill, once the setting has been checked. */
+ get mainPillId(): string {
+ return sanitizeDeclared(this.settings, this.os).mainPill;
+ }
+
+ /**
+ * True for a pill that stays when its session ends: the main pill and the
+ * declared ones go back to idle instead of going away.
+ */
+ isKept(id: string): boolean {
+ const d = sanitizeDeclared(this.settings, this.os);
+ return id === d.mainPill || d.activeIntegrations.includes(id);
+ }
+
+ /**
+ * Loads the catalog pills: the main pill always, the declared ones, and none
+ * of the others — a pill that is mid-session stays until its session ends.
+ * Safe to call any number of times. AppState.loadIntegrationTasks on macOS.
+ */
loadIntegrationTasks() {
- for (const proto of INTEGRATION_AGENTS) {
- const shouldLoad =
- proto.id === "integration_claude" || this.settings.activeIntegrations.includes(proto.id);
- const idx = this.tasks.findIndex((t) => t.id === proto.id);
- if (shouldLoad && idx < 0) this.tasks.push({ ...proto, steps: [] });
- if (!shouldLoad && idx >= 0) this.tasks.splice(idx, 1);
+ const d = sanitizeDeclared(this.settings, this.os);
+ this.settings.mainPill = d.mainPill;
+ this.settings.activeIntegrations = d.activeIntegrations;
+ for (const def of availablePills(this.os)) {
+ const shouldLoad = def.id === d.mainPill || d.activeIntegrations.includes(def.id);
+ const idx = this.tasks.findIndex((t) => t.id === def.id);
+ if (shouldLoad && idx < 0) this.tasks.push(taskFor(def));
+ const busy = idx >= 0 && (this.tasks[idx].state !== "idle" || this.tasks[idx].steps.length > 0);
+ if (!shouldLoad && idx >= 0 && !busy) this.tasks.splice(idx, 1);
}
- // Order: integration_claude first, then agent_* pills (visible in slice(0,4)),
- // then other integrations in declaration order.
- const order = INTEGRATION_AGENTS.map((t) => t.id);
- this.tasks.sort((a, b) => {
- const isAgentA = a.id.startsWith("agent_");
- const isAgentB = b.id.startsWith("agent_");
- // integration_claude always first
- if (a.id === "integration_claude") return -1;
- if (b.id === "integration_claude") return 1;
- // agent_* before other integrations; preserve insertion order among themselves
- if (isAgentA && !isAgentB) return -1;
- if (isAgentB && !isAgentA) return 1;
- if (isAgentA && isAgentB) return 0;
- // both known integrations → declaration order
- return order.indexOf(a.id) - order.indexOf(b.id);
- });
- if (!this.focusId) this.focusId = "integration_claude";
+ this.tasks = orderPills(this.tasks, d.mainPill);
+ if (!this.focusId || !this.tasks.some((t) => t.id === this.focusId)) this.focusId = d.mainPill;
this.notify();
}
+ /**
+ * A session is over. The main and declared pills are put back as they were;
+ * any other pill goes away (AppState.removeTask on macOS).
+ */
removeTask(id: string) {
const idx = this.tasks.findIndex((t) => t.id === id);
if (idx < 0) return;
+ if (this.isKept(id)) {
+ const t = this.tasks[idx];
+ t.state = "idle";
+ t.steps = [];
+ t.stepIndex = 0;
+ delete t.stepSeq;
+ t.pillBadge = null;
+ const def = pillDefinition(id);
+ if (def) t.name = def.name;
+ this.notify();
+ return;
+ }
this.tasks.splice(idx, 1);
- if (this.focusId === id) this.focusId = this.tasks[0]?.id ?? "integration_claude";
+ if (this.focusId === id) this.focusId = this.tasks[0]?.id ?? this.mainPillId;
this.notify();
}
- /** Creates a dynamic agent_ pill on first event; no-ops if it already exists.
- * Inserted right after integration_claude so it appears in the visible slice(0,4). */
+ /**
+ * Creates the pill of a tagged agent on its first event; no-op if it exists.
+ * Inserted right after the main pill so it is in the visible slice(0,4). A
+ * catalog agent wears its catalog colour, as on macOS.
+ */
upsertExternalAgent(id: string, name: string, color: string) {
if (this.tasks.some((t) => t.id === id)) return;
- const at = this.tasks.findIndex((t) => t.id === "integration_claude") + 1;
- this.tasks.splice(at, 0, {
- id, name, color,
+ const def = pillDefinition(id);
+ this.insertAfterMain({
+ id, name, color: def?.color ?? color,
state: "idle", stepIndex: 0, steps: [],
source: "agent", isIntegration: false,
});
- if (!this.focusId) this.focusId = id;
+ }
+
+ /**
+ * The pill a Claude Code session belongs to (VS Code or Cursor). It is made
+ * for the session when it is neither the main pill nor declared, as
+ * upsertWorkspaceTask does on macOS.
+ */
+ upsertWorkspacePill(id: string, name: string, cwd: string): AgentTask | null {
+ let t = this.tasks.find((x) => x.id === id);
+ if (!t) {
+ const def = pillDefinition(id);
+ if (!def) return null;
+ t = taskFor(def, name);
+ this.insertAfterMain(t);
+ }
+ t.name = name;
+ if (cwd) t.sessionCwd = cwd;
+ return t;
+ }
+
+ private insertAfterMain(t: AgentTask) {
+ const at = this.tasks.findIndex((x) => x.id === this.mainPillId) + 1;
+ this.tasks.splice(at, 0, t);
+ if (!this.focusId) this.focusId = t.id;
this.notify();
}
+ /** Declares or undeclares a pill (max 4 next to the main one). */
toggleIntegration(id: string) {
- if (id === "integration_claude") return;
- const active = this.settings.activeIntegrations;
- if (active.includes(id)) {
- this.settings.activeIntegrations = active.filter((x) => x !== id);
- if (this.focusId === id) this.focusId = "integration_claude";
- } else {
- if (active.length >= 4) return;
- this.settings.activeIntegrations = [...active, id];
- }
+ const next = toggleDeclared(sanitizeDeclared(this.settings, this.os), id, this.os);
+ if (!next) return;
+ this.settings.activeIntegrations = next;
+ if (!next.includes(id) && this.focusId === id) this.focusId = this.mainPillId;
this.loadIntegrationTasks();
}
diff --git a/windows/src/island/hooks.ts b/windows/src/island/hooks.ts
index ff03a72f..cb9ef14f 100644
--- a/windows/src/island/hooks.ts
+++ b/windows/src/island/hooks.ts
@@ -6,9 +6,11 @@
import { Bridge, onEvent } from "../core/bridge";
import { Sound } from "../core/sound";
import { State, type AskedQuestion } from "../core/state";
+import { pillDefinition } from "../core/pills";
import type { Island } from "./island";
const CLAUDE_ID = "integration_claude";
+const CURSOR_ID = "agent_cursor";
/** Clears the approval card if no decision was made before the hook gave up. */
let pendingTimeout: number | null = null;
@@ -50,6 +52,8 @@ interface HookPayload {
tool_input?: Record<string, unknown>;
/** Optional agent tag: lowercase, digits and hyphens, ≤ 24 chars. */
coucou_agent?: string;
+ /** "cursor" when Claude Code runs in Cursor's terminal (set by the relay). */
+ term_editor?: string;
}
/** Same rule as HookServer.validateAgent on macOS. "claude" is reserved. */
@@ -167,21 +171,27 @@ function askedQuestions(tool: string, input: Record<string, unknown>): AskedQues
return out.length > 0 ? out : null;
}
-function upsert(projectName: string, cwd: string) {
- const t = State.tasks.find((x) => x.id === CLAUDE_ID);
- if (!t) return;
- t.name = projectName;
- if (cwd) t.sessionCwd = cwd;
+/** The Claude Code session's pill, named after its project for the session. */
+function upsert(id: string, projectName: string, cwd: string, sessionId: string) {
+ const t = State.upsertWorkspacePill(id, projectName, cwd);
+ if (t && sessionId) t.sessionId = sessionId;
}
-function clearSession() {
- const t = State.tasks.find((x) => x.id === CLAUDE_ID);
+/** The session is over: the pill goes back as it was, or away if it was only there for it. */
+function clearSession(id: string) {
+ const t = State.tasks.find((x) => x.id === id);
if (!t) return;
+ if (!State.isKept(id)) {
+ State.removeTask(id);
+ return;
+ }
+ t.state = "idle";
t.steps = [];
t.stepIndex = 0;
delete t.stepSeq;
- t.name = "VS Code";
+ t.name = pillDefinition(id)?.name ?? t.name;
t.pillBadge = null;
+ t.sessionId = null;
}
export function registerHookHandlers(island: Island) {
@@ -203,10 +213,13 @@ function handleHook(island: Island, payload: HookPayload) {
const projectName = aliasProjectName(raw || "Session");
// Route to the right pill. Valid coucou_agent → dynamic "agent_<name>" pill.
- // "claude" is reserved; absent or invalid → Claude Code pill unchanged.
+ // "claude" is reserved; absent or invalid → Claude Code's own pill: Cursor's
+ // when it runs in Cursor's terminal (Mac #120), VS Code's otherwise.
const validAgent = validateAgent(payload.coucou_agent);
- const agentId = validAgent ? `agent_${validAgent}` : CLAUDE_ID;
+ const workspaceId = payload.term_editor === "cursor" ? CURSOR_ID : CLAUDE_ID;
+ const agentId = validAgent ? `agent_${validAgent}` : workspaceId;
const isExternalAgent = validAgent !== null;
+ const sessionId = payload.session_id ?? "";
const focused = State.focusId === agentId;
@@ -225,8 +238,11 @@ function handleHook(island: Island, payload: HookPayload) {
const ensurePill = () => {
if (isExternalAgent) {
State.upsertExternalAgent(agentId, validAgent!, agentColor(validAgent!));
+ const t = State.tasks.find((x) => x.id === agentId);
+ if (t && cwd) t.sessionCwd = cwd;
+ if (t && sessionId) t.sessionId = sessionId;
} else {
- upsert(projectName, cwd);
+ upsert(agentId, projectName, cwd, sessionId);
}
};
@@ -340,7 +356,7 @@ function handleHook(island: Island, payload: HookPayload) {
State.removeTask(agentId);
} else {
State.updateTask(agentId, "idle");
- clearSession();
+ clearSession(agentId);
}
break;
@@ -369,7 +385,7 @@ function handleHook(island: Island, payload: HookPayload) {
if (requestId) void Bridge.approvalDecline(requestId);
break;
}
- upsert(projectName, cwd);
+ upsert(agentId, projectName, cwd, sessionId);
supersedeStop();
if (pendingTimeout != null) window.clearTimeout(pendingTimeout);
const tool = payload.tool_name ?? "Tool";
diff --git a/windows/src/island/integrations.ts b/windows/src/island/integrations.ts
index 862ffb14..10817291 100644
--- a/windows/src/island/integrations.ts
+++ b/windows/src/island/integrations.ts
@@ -3,21 +3,11 @@
// the pill isn't focused, plays a sound, and clears itself after 60 s.
import { onEvent, Bridge, type IntegrationUpdate } from "../core/bridge";
+import { availablePills } from "../core/pills";
import { Sound } from "../core/sound";
import { State } from "../core/state";
import type { Island } from "./island";
-/** Which Credential Manager key backs each pill. */
-const KEY_FOR: Record<string, string> = {
- integration_stripe: "stripe-api-key",
- integration_github: "github-token",
- integration_vercel: "vercel-token",
- integration_n8n: "n8n-api-key",
- integration_resend: "resend-api-key",
- integration_notion: "notion-api-key",
- integration_calcom: "calcom-api-key",
-};
-
const clearTimers = new Map<string, number>();
export function registerIntegrationHandlers(island: Island) {
@@ -25,18 +15,43 @@ export function registerIntegrationHandlers(island: Island) {
void refreshConfigured();
}
-/** Asks Rust which keys exist so the idle cards can say so. */
+/**
+ * Whether each pill is connected, so its idle card can say so: a key in the
+ * credential store for a service or a chat provider, the hooks in place for a
+ * pill fed by hook events (Mac #183), nothing at all for Claude Desktop.
+ */
export async function refreshConfigured() {
- for (const [id, key] of Object.entries(KEY_FOR)) {
- const present = (await Bridge.secretPresent(key)) ?? false;
+ const hooks = (await Bridge.agentHooksStatus()) ?? null;
+ for (const def of availablePills(State.os)) {
+ let configured: boolean;
+ switch (def.connect.kind) {
+ case "key":
+ configured = (await Bridge.secretPresent(def.connect.key)) ?? false;
+ break;
+ case "hooks":
+ // Without an answer from Rust (a plain browser), the Claude Code pill
+ // falls back to what the settings say about its hooks.
+ configured = hooks?.[def.id] ??
+ (def.id === "integration_claude" ? State.settings.hooksInstalled : false);
+ break;
+ case "none":
+ configured = true;
+ break;
+ }
+ const info = State.integrations[def.id] ?? { data: {}, error: null, loaded: false, configured: false };
+ State.integrations[def.id] = { ...info, configured };
+ }
+ State.notify();
+}
+
+/** Only the hook-driven pills, for when the island opens: a few small file reads. */
+export async function refreshHookPills() {
+ const hooks = await Bridge.agentHooksStatus();
+ if (!hooks) return;
+ for (const [id, present] of Object.entries(hooks)) {
const info = State.integrations[id] ?? { data: {}, error: null, loaded: false, configured: false };
State.integrations[id] = { ...info, configured: present };
}
- const hooks = State.settings.hooksInstalled;
- const claude = State.integrations.integration_claude ?? {
- data: {}, error: null, loaded: false, configured: false,
- };
- State.integrations.integration_claude = { ...claude, configured: hooks };
State.notify();
}
diff --git a/windows/src/island/island.ts b/windows/src/island/island.ts
index 07bd4183..322a4a7f 100644
--- a/windows/src/island/island.ts
+++ b/windows/src/island/island.ts
@@ -20,6 +20,7 @@ import { USC, UploadSeq } from "../upload/sequence";
import { buildHeader, buildViews, type ViewActions, type ViewHost } from "../views/views";
import { h } from "../views/dom";
import { IslandStateMachine } from "./fsm";
+import { refreshHookPills } from "./integrations";
const BOT_OVERHANG = 40;
/** Same margin as the Rust hit test (src-tauri/src/island.rs). */
@@ -260,6 +261,9 @@ export class Island {
case "home":
this.expand(State.defaultView());
if (!this.wasInIsland) this.fsm.mouseLeft();
+ // Hooks may have been installed in a terminal since: the idle cards
+ // say so on the next open, without polling while the island is shut.
+ void refreshHookPills();
break;
case "coucou":
this.expand("greeting");
diff --git a/windows/src/main.ts b/windows/src/main.ts
index d71525e6..98d297b2 100644
--- a/windows/src/main.ts
+++ b/windows/src/main.ts
@@ -56,9 +56,12 @@ async function main() {
// The settings window writes preferences; apply them here without a restart.
await onEvent<Settings>("settings-changed", (s) => {
+ const previousMain = State.mainPillId;
State.settings = { ...State.settings, ...s };
island.applySettings();
State.loadIntegrationTasks();
+ // A new main tool comes to the front, as on macOS.
+ if (State.mainPillId !== previousMain) State.setFocus(State.mainPillId);
void refreshConfigured();
});
diff --git a/windows/src/settings/main.ts b/windows/src/settings/main.ts
index ccc1b77f..9f3cd188 100644
--- a/windows/src/settings/main.ts
+++ b/windows/src/settings/main.ts
@@ -5,6 +5,10 @@
import "./settings.css";
import { Bridge, onEvent, type HookStatus } from "../core/bridge";
import { DEFAULT_SETTINGS, type Settings } from "../core/state";
+import {
+ MAX_DECLARED, PILL_CATEGORIES, availablePills, chooseMainPill, isComingSoon, mainPillChoices,
+ sanitizeDeclared, toggleDeclared, type PillDefinition,
+} from "../core/pills";
import { h, clear } from "../views/dom";
/** Where secrets.rs keeps the keys on this OS. */
@@ -259,6 +263,87 @@ function apiSection(hasKey: boolean): HTMLElement {
);
}
+// ── Active pills section ──────────────────────────────────────────────────────
+
+/**
+ * The tools you use (Mac 0.1.1–0.1.2): pick the main workspace tool, which is
+ * always on and takes no slot, and declare the agents and chat providers you
+ * want as pills. Services are declared in Integrations below, next to their keys.
+ */
+function activePillsSection(connected: Record<string, boolean>): HTMLElement {
+ const slots = h("div", { class: "hint" });
+ const main = h("select", {}) as HTMLSelectElement;
+ for (const def of mainPillChoices()) main.append(h("option", { value: def.id, text: def.name }));
+ main.addEventListener("change", () => {
+ const next = chooseMainPill(settings, main.value);
+ if (!next) return;
+ settings.mainPill = next.mainPill;
+ settings.activeIntegrations = next.activeIntegrations;
+ declaredChanged();
+ });
+ const groups = h("div", { style: "display:flex;flex-direction:column;gap:12px" });
+
+ /** Why a pill would show nothing yet, as on the Mac's row. */
+ function hint(def: PillDefinition): string | null {
+ if (isComingSoon(def.id)) return "Coming soon";
+ if (def.connect.kind === "hooks" && !connected[def.id]) return "Hooks not installed";
+ if (def.connect.kind === "key" && !connected[def.id]) return "Key not configured";
+ return null;
+ }
+
+ function row(def: PillDefinition): HTMLElement {
+ const isMain = def.id === settings.mainPill;
+ const on = settings.activeIntegrations.includes(def.id);
+ const full = !isMain && !on && settings.activeIntegrations.length >= MAX_ACTIVE;
+ const el = h("div", { class: full ? "pill-row full" : "pill-row" },
+ h("i", { class: "dot", style: `background:${def.color};width:10px;height:10px` }),
+ h("span", { class: "name", text: def.name }),
+ );
+ if (isMain) {
+ el.append(h("span", { class: "state", text: "Main" }));
+ return el;
+ }
+ const why = hint(def);
+ el.append(h("span", { class: "state", text: why ?? "" }));
+ const sw = h("button", { class: on ? "switch on" : "switch" }) as HTMLButtonElement;
+ sw.disabled = full;
+ sw.addEventListener("click", () => {
+ const next = toggleDeclared(settings, def.id);
+ if (!next) return;
+ settings.activeIntegrations = next;
+ declaredChanged();
+ });
+ el.append(sw);
+ return el;
+ }
+
+ function draw() {
+ const used = settings.activeIntegrations.length;
+ slots.textContent = `${used}/${MAX_ACTIVE} slots in use — the main tool doesn't take one.`;
+ slots.classList.toggle("full", used >= MAX_ACTIVE);
+ main.value = settings.mainPill;
+ clear(groups);
+ for (const cat of PILL_CATEGORIES) {
+ if (cat.id === "service") continue;
+ const pills = availablePills().filter((p) => p.category === cat.id);
+ if (pills.length === 0) continue;
+ groups.append(h("div", { class: "pill-group" }, h("h3", { text: cat.title }), ...pills.map(row)));
+ }
+ }
+ declaredViews.push(draw);
+ draw();
+
+ return h(
+ "section",
+ {},
+ h("h2", {}, h("span", { text: "Active pills" })),
+ h("div", { class: "hint", text: "Choose the tools you use. Coucou only shows what you declare here." }),
+ slots,
+ h("div", { class: "row" }, h("label", { text: "Main tool" }), main),
+ groups,
+ );
+}
+
// ── Integrations section ──────────────────────────────────────────────────────
interface IntegrationDef {
@@ -289,7 +374,15 @@ const INTEGRATIONS: IntegrationDef[] = [
fields: [{ key: "calcom-api-key", label: "API key", placeholder: "cal_…", secret: true }] },
];
-const MAX_ACTIVE = 4;
+const MAX_ACTIVE = MAX_DECLARED;
+
+/** Everything that shows the declared pills, redrawn when any of them changes. */
+const declaredViews: (() => void)[] = [];
+
+function declaredChanged() {
+ for (const redraw of declaredViews) redraw();
+ void save();
+}
function integrationsSection(present: Record<string, boolean>): HTMLElement {
const note = h("div", { class: "hint" });
@@ -299,6 +392,7 @@ function integrationsSection(present: Record<string, boolean>): HTMLElement {
const used = settings.activeIntegrations.length;
note.textContent = `Pick up to ${MAX_ACTIVE} pills to show next to Mochi — ${used}/${MAX_ACTIVE} in use. Keys are stored in the ${KEY_STORE}, never on disk.`;
}
+ declaredViews.push(updateNote);
for (const def of INTEGRATIONS) {
const active = settings.activeIntegrations.includes(def.id);
@@ -312,8 +406,7 @@ function integrationsSection(present: Record<string, boolean>): HTMLElement {
settings.activeIntegrations = [...settings.activeIntegrations, def.id];
}
sw.classList.toggle("on", !on);
- updateNote();
- void save();
+ declaredChanged();
});
const rows = h("div", { style: "display:flex;flex-direction:column;gap:6px;flex:1 1 auto;min-width:0" });
@@ -458,11 +551,21 @@ async function main() {
const present: Record<string, boolean> = {};
for (const k of keys) present[k] = (await Bridge.secretPresent(k)) ?? false;
+ // A main pill this build can run, and no pill declared twice.
+ settings = { ...settings, ...sanitizeDeclared(settings) };
+ const connected: Record<string, boolean> = { ...((await Bridge.agentHooksStatus()) ?? {}) };
+ for (const def of availablePills()) {
+ if (def.connect.kind === "key") {
+ connected[def.id] = present[def.connect.key] ?? (await Bridge.secretPresent(def.connect.key)) ?? false;
+ }
+ }
+
clear(root);
root.append(
h("h1", {}, h("span", { text: "Coucou" }), h("span", { class: "version", text: version })),
claudeSection(status),
apiSection(hasKey),
+ activePillsSection(connected),
integrationsSection(present),
generalSection(),
h("div", {
@@ -473,6 +576,7 @@ async function main() {
void onEvent<Settings>("settings-changed", (s) => {
settings = { ...settings, ...s };
+ for (const redraw of declaredViews) redraw();
});
}
diff --git a/windows/src/settings/settings.css b/windows/src/settings/settings.css
index 605b8202..cc2517f1 100644
--- a/windows/src/settings/settings.css
+++ b/windows/src/settings/settings.css
@@ -265,3 +265,43 @@ select option {
background: rgba(245, 165, 36, 0.13);
color: #fbc06a;
}
+
+/* Active pills — one group per catalog category, one row per pill. */
+
+.pill-group {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ padding-top: 10px;
+ border-top: 1px solid var(--hairline);
+}
+
+.pill-group > h3 {
+ font: 600 11px var(--font);
+ color: var(--dim);
+}
+
+.pill-row {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-height: 24px;
+}
+
+.pill-row .name {
+ font-size: 12.5px;
+}
+
+.pill-row.full .name {
+ color: var(--dim-2);
+}
+
+.pill-row .state {
+ margin-left: auto;
+ font: 400 11.5px var(--font);
+ color: var(--dim);
+}
+
+.hint.full {
+ color: var(--amber);
+}
diff --git a/windows/src/views/integrations.ts b/windows/src/views/integrations.ts
index b8ad73c8..cf2564a3 100644
--- a/windows/src/views/integrations.ts
+++ b/windows/src/views/integrations.ts
@@ -8,6 +8,8 @@ import { h, svg, clear, dot } from "./dom";
import { ICONS } from "./icons";
import { State, type AgentTask } from "../core/state";
import { Bridge } from "../core/bridge";
+import { isComingSoon, pillDefinition } from "../core/pills";
+import { refreshHookPills } from "../island/integrations";
/** Same shape as the Swift `timeAgo` computed properties. */
export function timeAgo(value: unknown): string {
@@ -53,15 +55,34 @@ const OPEN_URLS: Record<string, string> = {
integration_calcom: "https://app.cal.com/bookings",
};
+/** IntegrationCardView.statusLabel on macOS. */
+export function idleStatus(
+ id: string,
+ info: { configured: boolean; error: string | null } | undefined,
+ chatModel: string,
+): { label: string; color: string } {
+ if (isComingSoon(id)) return { label: "Coming soon", color: "#6B7079" };
+ if (info?.error) return { label: info.error, color: "#F4505E" };
+ const configured = info?.configured ?? false;
+ const def = pillDefinition(id);
+ const ok = (label: string) => ({ label, color: "#22C55E" });
+ const missing = (label: string) => ({ label, color: "#F4505E" });
+ // Pills driven by hooks never have a key: they are connected once the hooks
+ // are in place (Mac #183). A session replaces this card; nothing is loading.
+ if (def?.connect.kind === "hooks") return configured ? ok("Hooks installed") : missing("Hooks not installed");
+ if (def?.connect.kind === "none") return ok("Ready · no setup needed");
+ if (def?.category === "ai") {
+ if (!configured) return missing("Key not configured");
+ return ok(id === "ai_anthropic" ? `Key configured · ${chatModel}` : "Key configured");
+ }
+ return configured ? ok("Connected · loading…") : missing("Key not configured");
+}
+
function idleCard(task: AgentTask, openSettings: () => void): HTMLElement {
const info = State.integrations[task.id];
const configured = info?.configured ?? false;
- const error = info?.error ?? null;
- // The Claude Code pill is about hooks, not a key — the macOS wording would be
- // misleading here.
- const missing = task.id === "integration_claude" ? "Hooks not installed" : "Key not configured";
- const label = error ?? (configured ? "Connected · loading…" : missing);
- const statusColor = error || !configured ? "#F4505E" : "#22C55E";
+ const def = pillDefinition(task.id);
+ const status = idleStatus(task.id, info, State.settings.model);
const actions = h("div", { class: "int-actions" });
if (task.id === "integration_claude") {
@@ -92,16 +113,20 @@ function idleCard(task: AgentTask, openSettings: () => void): HTMLElement {
}),
);
}
- if (configured) {
+ const hookPill = def?.connect.kind === "hooks";
+ if (isComingSoon(task.id) || def?.connect.kind === "none") {
+ // Nothing to set up, and nothing to refresh.
+ } else if (configured && (hookPill || def?.category !== "ai")) {
actions.append(
h("button", {
class: "link-btn",
style: `color:${task.color}d9`,
text: "Refresh",
- onclick: () => void Bridge.refreshIntegration(task.id),
+ // A hook pill has nothing to poll: look at its hooks again instead.
+ onclick: () => void (hookPill ? refreshHookPills() : Bridge.refreshIntegration(task.id)),
}),
);
- } else {
+ } else if (!configured) {
actions.append(
h("button", { class: "link-btn", style: "color:#8e939c", text: "Settings…", onclick: openSettings }),
);
@@ -110,8 +135,12 @@ function idleCard(task: AgentTask, openSettings: () => void): HTMLElement {
return h(
"div",
{ class: "int-card" },
- header(task.color, task.id === "integration_claude" ? "VS Code" : task.name, "Integration"),
- h("div", { class: "int-status" }, dot(statusColor, 5), h("span", { text: label })),
+ header(
+ task.color,
+ task.id === "integration_claude" ? "VS Code" : task.name,
+ def?.subtitle ?? "Integration",
+ ),
+ h("div", { class: "int-status" }, dot(status.color, 5), h("span", { text: status.label })),
actions,
);
}
diff --git a/windows/src/views/views.ts b/windows/src/views/views.ts
index e433651d..4a7186c3 100644
--- a/windows/src/views/views.ts
+++ b/windows/src/views/views.ts
@@ -11,6 +11,7 @@ import { createMiniBot, pruneMiniBots } from "../mochi/minibots";
import { buildPrompt } from "./chat";
import { buildChoose, buildUpload, buildUploading } from "./upload";
import { renderIntegrationCard, type IntegrationCardHooks } from "./integrations";
+import { pillDefinition, sessionSubtitle } from "../core/pills";
export interface ViewActions {
setView(v: IslandViewName): void;
@@ -180,10 +181,9 @@ function buildOverview(actions: ViewActions): ViewHost {
mode = null;
}
- // VS Code with a live Claude Code session keeps the ticker; every other
- // pill shows its own card, exactly like IntegrationCardView.
- const sessionActive =
- task?.id === "integration_claude" && (task.state !== "idle" || task.steps.length > 0);
+ // A workspace or agent pill with a live session keeps the ticker; every
+ // other pill shows its own card, exactly like IntegrationCardView.
+ const sessionActive = task != null && hasSessionTicker(task);
if (task && sessionActive) {
if (mode !== "ticker") {
@@ -196,7 +196,7 @@ function buildOverview(actions: ViewActions): ViewHost {
who.append(
dot(task.color, 7),
h("span", { class: "name", text: task.name }),
- h("span", { class: "tool", text: task.source === "claudeCode" ? "Claude Code" : "n8n" }),
+ h("span", { class: "tool", text: sessionSubtitle(task.id) }),
);
if (task.steps.length > 1) {
who.append(h("span", {
@@ -234,6 +234,17 @@ function buildOverview(actions: ViewActions): ViewHost {
};
}
+/**
+ * IntegrationCardView.agentSessionActive: a workspace tool or an agent — or
+ * any other tagged agent — with something going on.
+ */
+export function hasSessionTicker(task: AgentTask): boolean {
+ const category = pillDefinition(task.id)?.category;
+ const isSession = category === "workspace" || category === "agent" ||
+ (category == null && task.id.startsWith("agent_"));
+ return isSession && (task.state !== "idle" || task.steps.length > 0);
+}
+
function buildPill(task: AgentTask, actions: ViewActions): HTMLElement {
const label = task.id === "integration_claude" ? "VS Code" : task.name;
const canvas = createMiniBot(task, 24);
diff --git a/windows/tests/hooks.test.mjs b/windows/tests/hooks.test.mjs
index 93eaa2fb..ffa7a512 100644
--- a/windows/tests/hooks.test.mjs
+++ b/windows/tests/hooks.test.mjs
@@ -248,6 +248,39 @@ test("an agent's permission request is declined, never shown as Claude Code's",
assert.equal(State.pendingApproval, null);
});
+// ── Main tool and Cursor ──────────────────────────────────────────────────────
+
+test("Claude Code in Cursor's terminal works on the Cursor pill, made for the session", () => {
+ hook({ hook_event_name: "SessionStart", cwd: "/p/proj", session_id: "s9", term_editor: "cursor" });
+ hook({ hook_event_name: "PreToolUse", cwd: "/p/proj", term_editor: "cursor", tool_name: "Bash", tool_input: { command: "ls" } });
+ assert.equal(task("agent_cursor").state, "working");
+ assert.equal(task("agent_cursor").sessionId, "s9");
+ assert.equal(task().state, "idle");
+ hook({ hook_event_name: "SessionEnd", term_editor: "cursor" });
+ assert.equal(task("agent_cursor"), undefined);
+});
+
+test("with another main tool, Claude Code's pill comes for the session and goes after", () => {
+ State.settings.mainPill = "agent_codex";
+ State.loadIntegrationTasks();
+ assert.equal(task(), undefined);
+ hook({ hook_event_name: "SessionStart", cwd: "/p/proj" });
+ assert.equal(task().name, "proj");
+ assert.equal(State.tasks[0].id, "agent_codex");
+ hook({ hook_event_name: "SessionEnd" });
+ assert.equal(task(), undefined);
+});
+
+test("the main tool's agent sessions put it back as it was, never take it away", () => {
+ State.settings.mainPill = "agent_codex";
+ State.loadIntegrationTasks();
+ hook({ hook_event_name: "SessionStart", coucou_agent: "codex" });
+ hook({ hook_event_name: "Stop", coucou_agent: "codex" });
+ seconds(5.2);
+ assert.equal(task("agent_codex").state, "idle");
+ assert.equal(task("agent_codex").name, "Codex");
+});
+
// ── Permission requests ───────────────────────────────────────────────────────
const ask = (request_id, extra = {}) =>
diff --git a/windows/tests/pills.test.mjs b/windows/tests/pills.test.mjs
new file mode 100644
index 00000000..143347b1
--- /dev/null
+++ b/windows/tests/pills.test.mjs
@@ -0,0 +1,260 @@
+// The pill catalog (src/core/pills.ts) and the declared pills in the app state.
+
+import { beforeEach, test } from "node:test";
+import assert from "node:assert/strict";
+import {
+ DEFAULT_MAIN_PILL, MAX_DECLARED, PILL_CATALOG, PILL_CATEGORIES, availablePills, chooseMainPill,
+ isHookPill, mainPillChoices, orderPills, pillDefinition, sanitizeDeclared, sessionSubtitle,
+ toggleDeclared,
+} from "../src/core/pills.ts";
+import { DEFAULT_SETTINGS, State } from "../src/core/state.ts";
+
+// ── The catalog itself ────────────────────────────────────────────────────────
+
+test("the catalog holds the Mac's pills, in the Mac's order, with the Mac's values", () => {
+ // Copied from NotchBuddy/Sources/CoucouKit/PillCatalog.swift: an ID is a
+ // contract value, and a colour or subtitle that drifts is a visible bug.
+ const mac = [
+ ["integration_claude", "VS Code", "#F5F6F8", "workspace", "Integration"],
+ ["agent_cursor", "Cursor", "#C0C4CC", "workspace", "Integration"],
+ ["agent_antigravity", "Antigravity", "#E879F9", "workspace", "Integration"],
+ ["agent_codex", "Codex", "#2DD4BF", "workspace", "Integration"],
+ ["agent_gemini", "Gemini CLI", "#8AB4F8", "agent", "Agent"],
+ ["agent_copilot", "Copilot CLI", "#818CF8", "agent", "Agent"],
+ ["agent_muse", "Muse Code", "#38BDF8", "agent", "Agent"],
+ ["agent_opencode", "OpenCode", "#4ADE80", "agent", "Agent"],
+ ["agent_amp", "Amp", "#F59E0B", "agent", "Agent"],
+ ["agent_hermes", "Hermes", "#C084FC", "agent", "Agent"],
+ ["agent_claude-desktop", "Claude Desktop", "#D97757", "agent", "Agent"],
+ ["ai_anthropic", "Anthropic", "#E07950", "ai", "Chat"],
+ ["ai_google", "Google AI", "#4285F4", "ai", "Chat"],
+ ["ai_openai", "OpenAI", "#10A37F", "ai", "Chat"],
+ ["ai_ollama", "Ollama", "#FACC15", "ai", "Chat"],
+ ["ai_lmstudio", "LM Studio", "#A3E635", "ai", "Chat"],
+ ["integration_resend", "Resend", "#22C55E", "service", "Integration"],
+ ["integration_n8n", "n8n", "#F29B38", "service", "Integration"],
+ ["integration_vercel", "Vercel", "#7C5CFF", "service", "Integration"],
+ ["integration_github", "GitHub", "#F4505E", "service", "Integration"],
+ ["integration_notion", "Notion", "#8C8C8C", "service", "Integration"],
+ ["integration_calcom", "Cal.com", "#C9956A", "service", "Integration"],
+ ["integration_stripe", "Stripe", "#0570DE", "service", "Integration"],
+ ["integration_music", "Apple Music", "#FA2D48", "service", "Integration"],
+ ];
+ assert.deepEqual(
+ PILL_CATALOG.map((p) => [p.id, p.name, p.color, p.category, p.subtitle]),
+ mac,
+ );
+ assert.deepEqual(PILL_CATEGORIES.map((c) => c.title), [
+ "Where you code", "Agents", "AI for the chat", "Services",
+ ]);
+});
+
+test("the pills Windows always had keep their IDs, names, colours and sources", () => {
+ const shipped = [
+ ["integration_claude", "VS Code", "#F5F6F8", "claudeCode"],
+ ["integration_resend", "Resend", "#22C55E", "n8n"],
+ ["integration_n8n", "n8n", "#F29B38", "n8n"],
+ ["integration_vercel", "Vercel", "#7C5CFF", "n8n"],
+ ["integration_github", "GitHub", "#F4505E", "n8n"],
+ ["integration_notion", "Notion", "#8C8C8C", "n8n"],
+ ["integration_calcom", "Cal.com", "#C9956A", "n8n"],
+ ["integration_stripe", "Stripe", "#0570DE", "n8n"],
+ ];
+ for (const [id, name, color, source] of shipped) {
+ const def = pillDefinition(id);
+ assert.deepEqual([def.id, def.name, def.color, def.source], [id, name, color, source]);
+ assert.equal(def.support, "yes");
+ }
+});
+
+test("IDs are unique", () => {
+ const ids = PILL_CATALOG.map((p) => p.id);
+ assert.equal(new Set(ids).size, ids.length);
+});
+
+test("this build leaves out what only macOS has, and Claude Desktop on Linux", () => {
+ const windows = availablePills("windows").map((p) => p.id);
+ const linux = availablePills("linux").map((p) => p.id);
+ for (const id of ["agent_opencode", "agent_amp", "agent_hermes", "ai_ollama", "ai_lmstudio", "integration_music"]) {
+ assert.ok(!windows.includes(id), id);
+ assert.ok(!linux.includes(id), id);
+ }
+ assert.ok(windows.includes("agent_claude-desktop"));
+ assert.ok(!linux.includes("agent_claude-desktop"));
+ assert.deepEqual(linux, windows.filter((id) => id !== "agent_claude-desktop"));
+});
+
+test("the main pill is a workspace tool that works here", () => {
+ assert.deepEqual(mainPillChoices("linux").map((p) => p.id), [
+ "integration_claude", "agent_cursor", "agent_antigravity", "agent_codex",
+ ]);
+ assert.equal(DEFAULT_MAIN_PILL, "integration_claude");
+});
+
+test("hook-driven pills are the workspace tools and the agents with hooks", () => {
+ for (const id of ["integration_claude", "agent_cursor", "agent_codex", "agent_gemini", "agent_copilot", "agent_muse", "agent_antigravity"]) {
+ assert.ok(isHookPill(id), id);
+ }
+ for (const id of ["agent_claude-desktop", "ai_anthropic", "integration_stripe", "agent_unknown"]) {
+ assert.ok(!isHookPill(id), id);
+ }
+});
+
+test("a live session names its tool next to the project", () => {
+ assert.equal(sessionSubtitle("integration_claude"), "Claude Code");
+ assert.equal(sessionSubtitle("agent_cursor"), "Cursor");
+ assert.equal(sessionSubtitle("agent_claude-desktop"), "Claude Desktop");
+ assert.equal(sessionSubtitle("agent_gemini"), "Agent");
+ assert.equal(sessionSubtitle("agent_whatever"), "Agent");
+});
+
+// ── Declaring pills ──────────────────────────────────────────────────────────
+
+test("a declaration from an older or edited settings file is made usable", () => {
+ assert.deepEqual(
+ sanitizeDeclared({ mainPill: "integration_stripe", activeIntegrations: ["integration_claude", "x"] }, "linux"),
+ { mainPill: "integration_claude", activeIntegrations: [] },
+ );
+ assert.deepEqual(
+ sanitizeDeclared({ mainPill: "agent_cursor", activeIntegrations: ["agent_cursor", "integration_n8n", "integration_n8n", "agent_hermes"] }, "linux"),
+ { mainPill: "agent_cursor", activeIntegrations: ["integration_n8n"] },
+ );
+ // No mainPill at all: a settings.json from before this version.
+ assert.deepEqual(
+ sanitizeDeclared({ activeIntegrations: ["integration_github"] }, "windows"),
+ { mainPill: "integration_claude", activeIntegrations: ["integration_github"] },
+ );
+ assert.equal(sanitizeDeclared({ mainPill: "agent_claude-desktop", activeIntegrations: [] }, "windows").mainPill,
+ "integration_claude");
+});
+
+test("up to four pills next to the main one, never the main one itself", () => {
+ const d = {
+ mainPill: "integration_claude",
+ activeIntegrations: ["integration_n8n", "integration_github", "integration_stripe"],
+ };
+ const four = toggleDeclared(d, "agent_gemini", "linux");
+ assert.equal(four.length, MAX_DECLARED);
+ assert.equal(toggleDeclared({ ...d, activeIntegrations: four }, "ai_anthropic", "linux"), null);
+ assert.equal(toggleDeclared(d, "integration_claude", "linux"), null);
+ assert.equal(toggleDeclared(d, "agent_hermes", "linux"), null);
+ assert.equal(toggleDeclared(d, "agent_claude-desktop", "linux"), null);
+ assert.ok(toggleDeclared(d, "agent_claude-desktop", "windows").includes("agent_claude-desktop"));
+ assert.deepEqual(toggleDeclared(d, "integration_github", "linux"), ["integration_n8n", "integration_stripe"]);
+ // Coming soon can still be declared, as on macOS.
+ assert.ok(toggleDeclared(d, "ai_google", "linux").includes("ai_google"));
+});
+
+test("picking a main pill takes it out of the declared ones, and only workspace tools qualify", () => {
+ const d = { mainPill: "integration_claude", activeIntegrations: ["agent_cursor", "integration_n8n"] };
+ assert.deepEqual(chooseMainPill(d, "agent_cursor", "linux"), {
+ mainPill: "agent_cursor", activeIntegrations: ["integration_n8n"],
+ });
+ assert.equal(chooseMainPill(d, "integration_n8n", "linux"), null);
+ assert.equal(chooseMainPill(d, "agent_gemini", "linux"), null);
+});
+
+test("pills are ordered main first, then other agents, then the catalog's order", () => {
+ const ids = (list) => list.map((t) => t.id);
+ const tasks = ["integration_stripe", "agent_mine", "integration_n8n", "agent_cursor", "integration_claude", "agent_gemini"]
+ .map((id) => ({ id }));
+ assert.deepEqual(ids(orderPills(tasks, "integration_claude")), [
+ "integration_claude", "agent_mine", "agent_cursor", "agent_gemini", "integration_n8n", "integration_stripe",
+ ]);
+ assert.deepEqual(ids(orderPills(tasks, "agent_cursor")).slice(0, 3), [
+ "agent_cursor", "agent_mine", "integration_claude",
+ ]);
+});
+
+// ── In the app state ─────────────────────────────────────────────────────────
+
+beforeEach(() => {
+ State.tasks = [];
+ State.focusId = null;
+ State.os = "windows";
+ State.settings = { ...DEFAULT_SETTINGS };
+});
+
+const ids = () => State.tasks.map((t) => t.id);
+
+test("the main pill always loads, the declared ones join it, and focus starts on it", () => {
+ State.settings.mainPill = "agent_cursor";
+ State.settings.activeIntegrations = ["integration_github", "agent_gemini"];
+ State.loadIntegrationTasks();
+ assert.deepEqual(ids(), ["agent_cursor", "agent_gemini", "integration_github"]);
+ assert.equal(State.focusId, "agent_cursor");
+ assert.equal(State.tasks[1].name, "Gemini CLI");
+ assert.equal(State.tasks[1].color, "#8AB4F8");
+});
+
+test("an old settings file gets VS Code as its main pill and keeps its integrations", () => {
+ State.settings = { ...DEFAULT_SETTINGS, mainPill: undefined };
+ State.loadIntegrationTasks();
+ assert.deepEqual(ids(), [
+ "integration_claude", "integration_resend", "integration_n8n", "integration_vercel", "integration_github",
+ ]);
+ assert.equal(State.settings.mainPill, "integration_claude");
+});
+
+test("switching the main pill frees its slot and the old main pill goes when idle", () => {
+ State.loadIntegrationTasks();
+ State.settings.mainPill = "agent_codex";
+ State.loadIntegrationTasks();
+ assert.equal(ids()[0], "agent_codex");
+ assert.ok(!ids().includes("integration_claude"));
+ assert.equal(State.focusId, "agent_codex");
+});
+
+test("a pill in the middle of a session stays until the session ends", () => {
+ State.loadIntegrationTasks();
+ State.tasks[0].state = "working";
+ State.settings.mainPill = "agent_cursor";
+ State.loadIntegrationTasks();
+ assert.ok(ids().includes("integration_claude"));
+ State.removeTask("integration_claude");
+ assert.ok(!ids().includes("integration_claude"));
+});
+
+test("the end of a session puts a kept pill back as it was, and removes any other", () => {
+ State.settings.activeIntegrations = ["agent_gemini"];
+ State.loadIntegrationTasks();
+ const gemini = State.tasks.find((t) => t.id === "agent_gemini");
+ Object.assign(gemini, { name: "proj", state: "finished", steps: ["a"], pillBadge: "finished" });
+ State.removeTask("agent_gemini");
+ assert.deepEqual(
+ [gemini.name, gemini.state, gemini.steps, gemini.pillBadge],
+ ["Gemini CLI", "idle", [], null],
+ );
+ State.upsertExternalAgent("agent_mine", "mine", "#22C55E");
+ State.setFocus("agent_mine");
+ State.removeTask("agent_mine");
+ assert.ok(!ids().includes("agent_mine"));
+ assert.equal(State.focusId, "integration_claude");
+});
+
+test("a Claude Code session gets its pill even when it is not loaded", () => {
+ State.settings.mainPill = "agent_codex";
+ State.loadIntegrationTasks();
+ const t = State.upsertWorkspacePill("integration_claude", "proj", "/p");
+ assert.equal(ids()[1], "integration_claude");
+ assert.equal(t.name, "proj");
+ assert.equal(t.sessionCwd, "/p");
+ assert.equal(State.upsertWorkspacePill("not_a_pill", "x", ""), null);
+});
+
+test("toggling declares up to four pills and never the main one", () => {
+ State.settings.activeIntegrations = [];
+ State.loadIntegrationTasks();
+ for (const id of ["integration_n8n", "agent_gemini", "ai_anthropic", "integration_stripe", "integration_github"]) {
+ State.toggleIntegration(id);
+ }
+ assert.deepEqual(State.settings.activeIntegrations, [
+ "integration_n8n", "agent_gemini", "ai_anthropic", "integration_stripe",
+ ]);
+ State.toggleIntegration("integration_claude");
+ assert.ok(ids().includes("integration_claude"));
+ State.setFocus("agent_gemini");
+ State.toggleIntegration("agent_gemini");
+ assert.ok(!ids().includes("agent_gemini"));
+ assert.equal(State.focusId, "integration_claude");
+});