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.

Merge port/pills-approvals: pill catalog, main and declared pills, one permission card for every agent

Claude1d5f6bb9735f
diff --cc windows/README.md
index 384911e0,1e8a89ec..08ddfe94
--- a/windows/README.md
+++ b/windows/README.md
@@@ -52,6 -52,24 +52,25 @@@ island with **Deny / Allow**, a questio
pick from, a finished session shows what it did, and
your integrations sit in the coloured pills next to Mochi.
+ A permission card or a question stays until you answer it: the mouse leaving
+ never folds it, it comes up even when the island is already open or another
+ pill is in front, and the pill you were on comes back once you answer. To keep
+ it for later, fold it with the **⌃** in its corner (or `Esc` in the island): the
+ island shrinks to its compact size and stays on screen, nothing is answered, and
+ opening it again shows the card. **Open terminal** brings the window the session
+ runs in to the front.
+
+ ## Your pills
+
+ **Settings… → Active pills** lists the tools you use, from the same catalog as
+ the Mac app. Pick your **main tool** — VS Code, Cursor, Codex or Antigravity —
+ which is always there and doesn't take a slot, then declare up to four more:
-agents (Gemini CLI, Copilot CLI, Muse Code, Claude Desktop), the Anthropic chat,
++agents (Gemini CLI, Copilot CLI, Muse Code, OpenCode, Amp, Hermes, Claude
++Desktop), the Anthropic chat,
+ and the services under **Integrations**. A pill fed by hooks says whether its
+ hooks are installed, never asks for a key. A session on a pill you didn't
+ declare still shows up, for as long as it runs.
+
## Claude Code
<img src="screenshots/settings.png" width="562" alt="The settings window">
@@@ -139,67 -157,49 +158,82 @@@ problems. It stays on your machine
## Supported agents
-The relay (`coucou-hook.exe`) works with any tool that can run a command on hook events. Pass `--agent <name>` to create a named pill.
+Every agent below is installed from **Settings → Agents** with the same steps as
+Claude Code: the exact diff, the path of the dated backup, nothing written until
+you click, and uninstalling removes only Coucou's entries. A config Coucou cannot
+read, or where it finds something it does not expect, is left alone and the
+reason is shown. Each agent gets its own pill (`agent_<name>`, the Mac's ids and
+colours). The files are the Mac's, under `%USERPROFILE%` on Windows and `~` on
+Linux.
-| Agent | How to connect | Config file |
+| Agent | Installs | Permissions |
|---|---|---|
-| Claude Code | **Settings → Claude Code → Install hooks** | `%USERPROFILE%\.claude\settings.json` |
-| Gemini CLI | `--agent gemini` positional arg | `%USERPROFILE%\.gemini\settings.json` |
-| Antigravity | `--agent antigravity` positional arg | `%USERPROFILE%\.config\antigravity\hooks.json` |
-| Cursor | the Claude Code hooks: Claude Code in Cursor's terminal goes on the Cursor pill | `%USERPROFILE%\.claude\settings.json` |
-| Claude Desktop (Windows) | nothing to install: Claude Code sessions from the Claude app are tagged by the relay | — |
-| Codex | `--agent codex` positional arg | `%USERPROFILE%\.codex\hooks.json` |
-| Copilot CLI | `--agent copilot` positional arg + camelCase events | `%USERPROFILE%\.copilot\hooks\coucou.json` |
-| Muse Code | `--agent muse` positional arg | `%USERPROFILE%\.config\muse\settings.json` |
-| Any other | `--agent <name>` positional arg | your tool's hook config |
-
-OpenCode, Amp and Hermes are not yet supported on Windows or Linux. Their integration uses a plugin that calls `/bin/sh` with macOS-specific paths; the plugin installer lives in the Mac app only.
-
-A pill is **connected** when Coucou finds `coucou-hook --agent <name>` in the
-config file above (for Claude Code and Cursor: a SessionStart hook running
-Coucou's relay). Coucou only reads these files, each time the island opens.
-Permission requests get the island's card for Claude Code, in any terminal and
-in Cursor; other agents and Claude Desktop answer them in their own window.
+| Claude Code | `.claude\settings.json` (**Settings → Claude Code**) | Allow / Deny and questions in the island |
+| Codex | `.codex\hooks.json` — then trust the hooks once with `/hooks` in Codex | Allow / Deny in the island |
+| GitHub Copilot CLI | `.copilot\hooks\coucou.json` | Allow / Deny in the island |
+| Muse Code | `.config\muse\settings.json` | Allow / Deny in the island |
+| Gemini CLI | `.gemini\settings.json` | asked in Gemini CLI |
+| Antigravity | `.gemini\config\hooks.json` (a `coucou` hook group) | asked in Antigravity |
- | Cursor Agent | `.cursor\hooks.json` | asked in Cursor |
++| Cursor Agent | `.cursor\hooks.json` — Claude Code in Cursor's terminal also goes on the Cursor pill, through the Claude Code hooks | asked in Cursor |
++| Claude Desktop (Windows) | nothing to install: Claude Code sessions from the Claude app are tagged by the relay | asked in the Claude app |
+| OpenCode | plugin `.config\opencode\plugins\coucou.js` | asked in OpenCode |
+| Amp | plugin `.config\amp\plugins\coucou.ts` | asked in Amp |
+| Hermes Agent | plugin `.hermes\plugins\coucou\` — then `hermes plugins enable coucou` once | asked in Hermes |
+| Any other | run `coucou-hook --agent <name> [<Event>]` from your tool's hooks | asked in the tool |
+
+The relay maps every agent's event and field names onto Claude Code's (Gemini
+CLI's `BeforeTool`, Copilot's `preToolUse`, Cursor's `beforeSubmitPrompt`…), and
+answers each agent the way it expects. It never lets anything through on its
+own: with no click it prints no decision at all (`{}` for the agents that need
+JSON, `"ask"` for Copilot, which is fail-closed), so the agent asks in its own
+terminal exactly as without Coucou — including when Coucou is closed.
+
+The plugins start the relay directly, with no shell in between, and never wait
+for it. Amp's steps appear as each tool finishes: its "before" hook must return
+a verdict, and Coucou never gives one.
+
+**How each agent runs the relay on Windows.** Hook commands are written for the
+shell that runs them: Git Bash for Claude Code (quoted, forward slashes),
+PowerShell for Gemini CLI and Copilot CLI (`& '…\coucou-hook.exe'`), `cmd /C`
+for Codex. Cursor, Antigravity and Muse Code do not document theirs: the relay
+path is written bare when it has no space or special character — which works in
+cmd, PowerShell and when started directly — and in double quotes otherwise.
+These three are untested on Windows.
+
++A pill is **connected** when Coucou finds its own entries in the files above —
++the same check as Settings → Agents (for Claude Code: a SessionStart hook
++running Coucou's relay; the Cursor pill also counts Claude Code's hooks).
++Coucou only reads these files, each time the island opens. Permission requests
++get the island's card for Claude Code (in any terminal, and in Cursor's),
++Codex, Copilot CLI and Muse Code; other agents and Claude Desktop ask in their
++own window.
+
## What's different from the Mac version
- No notch, so the island lives at the top centre of the screen and retracts into
the top edge instead of hiding in a notch.
- Permission approval works from **any** terminal; the Mac build only listens to
VS Code sessions.
- - Not in this version: sending a file by email, dragging Mochi onto a window to
- attach it as context, and jumping to a specific terminal window — "Open
- terminal" opens the working folder in VS Code when `code` is on your `PATH`.
+ - "Open terminal" finds the session's window by walking up from the relay's
+ process to the terminal or editor that runs it. A session in a classic
+ console window (`cmd.exe` or PowerShell without Windows Terminal) has no such
+ ancestor — conhost owns that window — so its folder opens in VS Code instead,
+ as it does when `code` is on your `PATH` and nothing was found.
+ - No global keyboard shortcuts yet: a waiting card is folded with its **⌃** or
+ `Esc` in the island, and reopened by clicking the island or Open in the tray.
+ - Pills from the Mac catalog that have nothing behind them here are left out:
- OpenCode, Amp, Hermes, Apple Music, Ollama and LM Studio. Google AI and OpenAI
- can be declared but show "Coming soon": the chat here only talks to Anthropic.
++ Apple Music, Ollama and LM Studio. Google AI and OpenAI can be declared but
++ show "Coming soon": the chat here only talks to Anthropic.
+ - Not in this version: sending a dropped file by email and dragging Mochi onto
+ a window to attach it as context. On the Mac, email goes through Resend or
+ Apple Mail's scripting; neither has a safe equivalent that attaches a file
+ here, and the drop card would need a third button it doesn't have.
- Cal.com shows the next bookings as a list rather than the Mac's calendar.
- - An agent's permission request that arrives while another pill is in view
- badges its pill instead of taking the view; clicking the pill opens the card.
- The Mac moves the focus to it.
- - Agent pills come with a session and go when it ends: there is no "declared
- pills" list in Settings yet, and no main-pill choice.
- - The Cursor pill follows Cursor Agent's own hooks. On the Mac it follows
- Claude Code running in Cursor's terminal.
++- The Cursor pill carries both Cursor Agent's own hooks and Claude Code running
++ in Cursor's terminal.
+- Hermes: Coucou writes the plugin but does not run the `hermes` CLI, so it is
+ turned on once by hand. Hermes runs natively on Linux; on Windows it is
- untested. Claude Desktop's own pill is not here yet.
++ untested.
## Linux
diff --cc windows/hook/src/main.rs
index e02f4803,7ceac101..43ff6f5b
--- a/windows/hook/src/main.rs
+++ b/windows/hook/src/main.rs
@@@ -116,38 -70,127 +116,45 @@@ fn main()
std::process::exit(0);
}
-/// The documented PermissionRequest output. Anything we do not recognise prints
-/// nothing at all rather than guessing — silence is the safe answer.
-/// See https://code.claude.com/docs/en/hooks
-///
-/// `question` is the AskUserQuestion input, when that is what is being asked:
-/// the island may then answer it, which Claude Code takes as the same input
-/// with an `answers` map added. Nothing else of the input can be changed from
-/// the island, and no other tool's input can be changed at all.
-fn decision_json(decision: &str, question: Option<&serde_json::Value>) -> Option<String> {
- if decision.trim_start().starts_with('{') {
- let reply = serde_json::from_str::<serde_json::Value>(decision).ok()?;
- let answers = reply.get("answers")?.as_object()?;
- let question = question?;
- if !answers_fit(question, answers) {
- return None;
- }
- let mut input = question.as_object()?.clone();
- input.insert("answers".into(), serde_json::Value::Object(answers.clone()));
- return Some(
- serde_json::json!({
- "hookSpecificOutput": {
- "hookEventName": "PermissionRequest",
- "decision": { "behavior": "allow", "updatedInput": input },
- }
- })
- .to_string(),
- );
+fn print(line: Option<String>) {
+ if let Some(line) = line {
+ let mut out = std::io::stdout();
+ let _ = writeln!(out, "{line}");
+ let _ = out.flush();
}
- let behavior = match decision.trim() {
- // "always" still answers a plain allow; remembering it is the island's
- // business, not Claude Code's.
- "allow" | "always" => r#"{"behavior":"allow"}"#.to_string(),
- "deny" => r#"{"behavior":"deny","message":"Denied from Coucou"}"#.to_string(),
- _ => return None,
- };
- Some(format!(
- r#"{{"hookSpecificOutput":{{"hookEventName":"PermissionRequest","decision":{behavior}}}}}"#
- ))
}
-/// True when `answers` answers exactly the questions Claude Code asked: one entry
-/// per question, keyed by its text; a single-select answer is one of its option
-/// labels (a string), a multi-select answer a non-empty list of distinct labels
-/// (Claude Code 2.1.136+ takes the list, as the Mac sends it). Same rule as
-/// `QuestionPayload.accepts` on macOS.
-fn answers_fit(question: &serde_json::Value, answers: &serde_json::Map<String, serde_json::Value>) -> bool {
- let Some(items) = question.get("questions").and_then(|q| q.as_array()) else { return false };
- if items.is_empty() || items.len() != answers.len() {
- return false;
- }
- items.iter().all(|item| {
- let Some(text) = item.get("question").and_then(|q| q.as_str()) else { return false };
- let labels: Vec<&str> = item
- .get("options")
- .and_then(|o| o.as_array())
- .map(|opts| opts.iter().filter_map(|o| o.get("label").and_then(|l| l.as_str())).collect())
- .unwrap_or_default();
- let multi = item.get("multiSelect").and_then(|m| m.as_bool()).unwrap_or(false);
- match answers.get(text) {
- Some(serde_json::Value::String(pick)) if !multi => labels.contains(&pick.as_str()),
- Some(serde_json::Value::Array(picks)) if multi => {
- let picks: Vec<&str> = picks.iter().filter_map(|p| p.as_str()).collect();
- let mut seen = picks.clone();
- seen.sort_unstable();
- seen.dedup();
- !picks.is_empty() && seen.len() == picks.len() && picks.iter().all(|p| labels.contains(p))
- }
- _ => false,
- }
- })
-}
-
-/// Reads stdin and returns the payload to forward, the event name, and — for an
-/// AskUserQuestion permission request — the question as Claude Code sent it.
-fn read_event() -> Option<(String, String, Option<serde_json::Value>)> {
- let mut raw = Vec::new();
- if std::io::stdin().read_to_end(&mut raw).is_err() || raw.is_empty() {
- return None;
- }
+/// The payload to forward, from the raw stdin bytes. `env` reads an environment
+/// variable and `cwd` is the working directory, so tests stay pure.
+fn prepare(raw: &[u8], args: &Args, env: &dyn Fn(&str) -> Option<String>, cwd: &str) -> Option<Event> {
// Some shells hand us a UTF-8 BOM; serde_json would choke on it.
- if raw.starts_with(&[0xEF, 0xBB, 0xBF]) {
- raw.drain(..3);
- }
-
- let mut payload = serde_json::from_slice::<serde_json::Value>(&raw).ok()?;
+ let raw = raw.strip_prefix(&[0xEF, 0xBB, 0xBF]).unwrap_or(raw);
+ let mut payload = serde_json::from_slice::<Value>(raw).ok()?;
let map = payload.as_object_mut()?;
- // Parse argv: "coucou-hook.exe [--agent <name>] [<EventName>]"
- // --agent tags the payload with coucou_agent so the app routes to the right pill.
- // Absent or invalid names are validated and discarded by the app, not here.
- let mut agent = String::new();
- let mut arg_event = String::new();
- {
- let mut it = std::env::args().skip(1);
- while let Some(arg) = it.next() {
- if arg == "--agent" {
- agent = it.next().unwrap_or_default();
- } else if arg_event.is_empty() {
- arg_event = arg;
- }
- }
- }
- // Which agent this hook was installed for. Absent means Claude Code,
- // so existing hook commands keep working unchanged.
- let env = |name: &str| std::env::var(name).ok();
- if let Some(tag) = agent_tag(&agent, &env) {
- map.insert("coucou_agent".into(), serde_json::Value::String(tag));
+ // Which agent this hook was installed for, so the app routes it to the right
+ // pill. Absent means Claude Code, so existing hook commands keep working
- // unchanged; invalid names are discarded by the app, not here.
- if !args.agent.is_empty() {
- map.insert("coucou_agent".into(), Value::String(args.agent.clone()));
++ // unchanged; invalid names are discarded by the app, not here. A Claude Code
++ // session started from the Claude desktop app is tagged `claude-desktop`.
++ if let Some(tag) = agent_tag(&args.agent, env) {
++ map.insert("coucou_agent".into(), Value::String(tag));
+ }
+ // Claude Code in Cursor's terminal goes on the Cursor pill (Mac #120).
+ if !map.contains_key("term_editor") {
- if let Some(editor) = term_editor(&env) {
- map.insert("term_editor".into(), serde_json::Value::String(editor.into()));
++ if let Some(editor) = term_editor(env) {
++ map.insert("term_editor".into(), Value::String(editor.into()));
+ }
}
- let event = map
+
+ let raw_event = map
.get("hook_event_name")
- .and_then(|v| v.as_str())
- .map(str::to_string)
+ .and_then(Value::as_str)
.filter(|s| !s.is_empty())
- .unwrap_or(arg_event);
- map.insert("hook_event_name".into(), serde_json::Value::String(event.clone()));
+ .map(str::to_string)
+ .unwrap_or_else(|| args.event.clone());
+ normalize::fields(map, env);
+ let name = normalize::refine(normalize::event(&raw_event), map);
+ map.insert("hook_event_name".into(), Value::String(name.clone()));
for field in DROPPED_FIELDS {
map.remove(*field);
@@@ -169,29 -235,37 +176,53 @@@
let mut line = payload.to_string();
line.push('\n');
- Some((line, event, question))
+ Some(Event { line, name, question })
+}
+
+/// Which terminal the session runs in. Unlike macOS, Coucou here accepts events
+/// from every terminal, so this is context only — never a filter.
+fn add_terminal_context(map: &mut Map<String, Value>, env: &dyn Fn(&str) -> Option<String>) {
+ for (key, var) in [
+ ("term_program", "TERM_PROGRAM"),
+ ("wt_session", "WT_SESSION"),
+ ("term_session_id", "TERM_SESSION_ID"),
+ ("vscode_pid", "VSCODE_PID"),
+ ("session_pid", "CLAUDE_CODE_SSE_PORT"),
+ ] {
+ if !map.contains_key(key) {
+ map.insert(key.into(), Value::String(env(var).unwrap_or_default()));
+ }
+ }
}
+ /// The `coucou_agent` tag: `--agent` when given, otherwise `claude-desktop` for
+ /// a Claude Code session started from the Claude desktop app, which says so in
+ /// CLAUDE_CODE_ENTRYPOINT — the same rule as the Mac's relay (#191). Nothing
+ /// for a plain Claude Code session.
+ fn agent_tag(arg: &str, env: &dyn Fn(&str) -> Option<String>) -> Option<String> {
+ if !arg.is_empty() {
+ return Some(arg.to_string());
+ }
+ (env("CLAUDE_CODE_ENTRYPOINT").as_deref() == Some("claude-desktop"))
+ .then(|| "claude-desktop".to_string())
+ }
+
+ /// `cursor` when the session runs in Cursor's integrated terminal. Cursor sets
+ /// TERM_PROGRAM=vscode like VS Code does, so it is told apart by its own trace
+ /// variable, or by its executable behind VS Code's git helper.
+ fn term_editor(env: &dyn Fn(&str) -> Option<String>) -> Option<&'static str> {
+ if env("CURSOR_TRACE_ID").is_some_and(|v| !v.is_empty()) {
+ return Some("cursor");
+ }
+ let helper = env("VSCODE_GIT_ASKPASS_NODE").unwrap_or_default();
+ let exe = helper.rsplit(['/', '\\']).next().unwrap_or_default().to_ascii_lowercase();
+ exe.starts_with("cursor").then_some("cursor")
+ }
+
/// Caps every string in the payload. A single Write can carry a whole file.
-fn truncate_strings(value: &mut serde_json::Value) {
+fn truncate_strings(value: &mut Value) {
match value {
- serde_json::Value::String(s) => {
+ Value::String(s) => {
if s.len() > MAX_FIELD_LEN {
// Cut on a char boundary; a lone byte index can split UTF-8.
let mut end = MAX_FIELD_LEN;
@@@ -243,13 -317,106 +274,47 @@@ fn talk(payload: &str, waits_for_answer
mod tests {
use super::*;
- #[test]
- fn decision_json_matches_the_documented_shape() {
- assert_eq!(
- decision_json("allow", None).unwrap(),
- r#"{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}"#
- );
- assert_eq!(
- decision_json("deny", None).unwrap(),
- r#"{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"deny","message":"Denied from Coucou"}}}"#
- );
- // "always" is an island concept; Claude Code just gets an allow.
- assert!(decision_json("always", None).unwrap().contains(r#""behavior":"allow""#));
- }
-
- #[test]
- fn anything_unrecognised_prints_nothing() {
- assert!(decision_json("", None).is_none());
- assert!(decision_json("maybe", None).is_none());
- // The shape the app used to send must not be mistaken for a decision.
- assert!(decision_json(r#"{"permissionDecision":"allow"}"#, None).is_none());
- }
-
- #[test]
- fn an_answered_question_goes_back_as_the_same_input_plus_answers() {
- let question = serde_json::json!({
- "questions": [{ "question": "Which one?", "options": [{ "label": "A" }, { "label": "B" }] }]
- });
- let out = decision_json(r#"{"answers":{"Which one?":"B"}}"#, Some(&question)).unwrap();
- let v: serde_json::Value = serde_json::from_str(&out).unwrap();
- let decision = &v["hookSpecificOutput"]["decision"];
- assert_eq!(decision["behavior"], "allow");
- assert_eq!(decision["updatedInput"]["questions"], question["questions"]);
- assert_eq!(decision["updatedInput"]["answers"]["Which one?"], "B");
- }
-
- #[test]
- fn answers_are_only_accepted_for_a_question() {
- // Any other tool: the island cannot rewrite its input.
- assert!(decision_json(r#"{"answers":{"q":"a"}}"#, None).is_none());
- let question = serde_json::json!({ "questions": [] });
- assert!(decision_json(r#"{"answers":{}}"#, Some(&question)).is_none());
- assert!(decision_json(r#"{"answers":{"q":1}}"#, Some(&question)).is_none());
- assert!(decision_json(r#"{"command":"rm -rf /"}"#, Some(&question)).is_none());
- }
-
- #[test]
- fn answers_must_match_the_questions_asked() {
- let q = serde_json::json!({ "questions": [
- { "question": "Which one?", "options": [{ "label": "A" }, { "label": "B" }] },
- { "question": "Extras?", "multiSelect": true,
- "options": [{ "label": "Tests" }, { "label": "Docs" }, { "label": "Lint" }] }
- ]});
- let ok = |a: &str| decision_json(a, Some(&q)).is_some();
- assert!(ok(r#"{"answers":{"Which one?":"A","Extras?":["Tests","Docs"]}}"#));
- // Not one of the labels, or an answer to a question nobody asked.
- assert!(!ok(r#"{"answers":{"Which one?":"C","Extras?":["Tests"]}}"#));
- assert!(!ok(r#"{"answers":{"Which one?":"A","Extras?":["Tests"],"Other?":"x"}}"#));
- // A question left out.
- assert!(!ok(r#"{"answers":{"Which one?":"A"}}"#));
- // Shapes: single-select is one string, multi-select a non-empty list.
- assert!(!ok(r#"{"answers":{"Which one?":["A"],"Extras?":["Tests"]}}"#));
- assert!(!ok(r#"{"answers":{"Which one?":"A","Extras?":"Tests"}}"#));
- assert!(!ok(r#"{"answers":{"Which one?":"A","Extras?":[]}}"#));
- assert!(!ok(r#"{"answers":{"Which one?":"A","Extras?":["Tests","Tests"]}}"#));
+ fn run(raw: &str, agent: &str, event: &str) -> (Value, Event) {
+ let args = Args { agent: agent.into(), event: event.into() };
+ let ev = prepare(raw.as_bytes(), &args, &|_| None, "/home/me/here").expect("forwarded");
+ let v = serde_json::from_str(ev.line.trim_end()).unwrap();
+ (v, ev)
}
+ fn env_of(vars: &'static [(&'static str, &'static str)]) -> impl Fn(&str) -> Option<String> {
+ move |name| vars.iter().find(|(k, _)| *k == name).map(|(_, v)| v.to_string())
+ }
+
+ #[test]
+ fn claude_desktop_sessions_are_tagged_and_an_explicit_agent_wins() {
+ let desktop = env_of(&[("CLAUDE_CODE_ENTRYPOINT", "claude-desktop")]);
+ assert_eq!(agent_tag("", &desktop).as_deref(), Some("claude-desktop"));
+ assert_eq!(agent_tag("gemini", &desktop).as_deref(), Some("gemini"));
+ assert_eq!(agent_tag("", &env_of(&[("CLAUDE_CODE_ENTRYPOINT", "cli")])), None);
+ assert_eq!(agent_tag("", &env_of(&[])), None);
+ }
+
+ #[test]
+ fn cursor_is_told_apart_from_vs_code() {
+ assert_eq!(term_editor(&env_of(&[("CURSOR_TRACE_ID", "abc")])), Some("cursor"));
+ assert_eq!(
+ term_editor(&env_of(&[(
+ "VSCODE_GIT_ASKPASS_NODE",
+ r"C:\Users\me\AppData\Local\Programs\cursor\Cursor.exe"
+ )])),
+ Some("cursor")
+ );
+ assert_eq!(
+ term_editor(&env_of(&[(
+ "VSCODE_GIT_ASKPASS_NODE",
+ r"C:\Users\me\AppData\Local\Programs\Microsoft VS Code\Code.exe"
+ )])),
+ None
+ );
+ assert_eq!(term_editor(&env_of(&[("CURSOR_TRACE_ID", "")])), None);
+ assert_eq!(term_editor(&env_of(&[("TERM_PROGRAM", "vscode")])), None);
+ }
+
#[test]
fn long_strings_are_cut_on_a_char_boundary() {
let mut v = serde_json::json!({ "tool_input": { "content": "é".repeat(4000) } });
diff --cc windows/src-tauri/src/agent_hooks.rs
index 00000000,aa64f813..dd80cd0f
mode 000000,100644..100644
--- a/windows/src-tauri/src/agent_hooks.rs
+++ b/windows/src-tauri/src/agent_hooks.rs
@@@ -1,0 -1,230 +1,143 @@@
+ // Whether each hook-driven pill is connected.
+ //
+ // A pill fed by hook events has no key: it is connected once the agent's config
+ // routes its events to coucou-hook (Mac #183 — the idle card used to say "Key
-// not configured" for these). Only reads, and only the agents' own config files;
-// nothing here ever writes.
++// not configured" for these). Only reads; nothing here ever writes.
+ //
-// The checks themselves are pure functions over parsed JSON, so they are tested
-// on fixtures rather than on the real files.
++// Claude Code is read here, with the Mac's own rule. Every other agent is read
++// by agents.rs — the code that writes their configs is the one source of truth
++// for where those files are and what Coucou's entries look like, so the pill
++// and Settings → Agents always agree.
+
+ use std::collections::HashMap;
+ use std::path::PathBuf;
+
+ use serde_json::Value;
+
-use crate::platform::home_dir;
+
+ /// Port of `coucouHooksPresent(inSettings:)` (ClaudeHookDetection.swift): true
+ /// when a parsed `~/.claude/settings.json` routes Claude Code's SessionStart
+ /// events to Coucou. The command text is what tells: Coucou's relay here is
+ /// `coucou-hook`, the Mac's is `~/.claude/coucou/nb-hook` (or NotchBuddy in the
+ /// App Store build), so a settings file shared between machines reads the same.
+ pub fn claude_hooks_present(settings: &Value) -> bool {
+ let Some(groups) = settings
+ .get("hooks")
+ .and_then(|h| h.get("SessionStart"))
+ .and_then(Value::as_array)
+ else {
+ return false;
+ };
+ groups.iter().any(|group| {
+ group.get("hooks").and_then(Value::as_array).is_some_and(|hooks| {
+ hooks.iter().any(|hook| {
+ hook.get("command")
+ .and_then(Value::as_str)
+ .is_some_and(|c| c.contains("NotchBuddy") || c.contains("coucou"))
+ })
+ })
+ })
+ }
+
-/// True when some string in `config` runs the relay for `agent`: it names
-/// `coucou-hook` (or the Mac's `nb-hook`) and passes `--agent <agent>`.
-///
-/// Every agent nests its hooks differently (Gemini and Codex under
-/// `hooks.<event>[].hooks[].command`, Copilot under `hooks.<event>[].bash` or
-/// `.powershell`, Antigravity under its own key), and the README tells people to
-/// write these files by hand, so the whole document is searched rather than one
-/// layout trusted.
-pub fn agent_hooks_present(config: &Value, agent: &str) -> bool {
- match config {
- Value::String(s) => runs_relay_for(s, agent),
- Value::Array(items) => items.iter().any(|v| agent_hooks_present(v, agent)),
- Value::Object(map) => map.values().any(|v| agent_hooks_present(v, agent)),
- _ => false,
- }
-}
-
-fn runs_relay_for(command: &str, agent: &str) -> bool {
- if !(command.contains("coucou-hook") || command.contains("nb-hook")) {
- return false;
- }
- // `--agent gemini` must not also match `--agent gemini-beta`.
- let flag = format!("--agent {agent}");
- command.match_indices(&flag).any(|(at, _)| {
- command[at + flag.len()..]
- .chars()
- .next()
- .is_none_or(|c| c.is_whitespace() || c == '"' || c == '\'')
- })
-}
-
-/// Agents configured through their own hook file, with the `--agent` tag the
-/// relay is given and where that file lives. Antigravity has two places: the
-/// one this README names, and the Mac's.
-fn agent_configs() -> Vec<(&'static str, &'static str, Vec<PathBuf>)> {
- let home = home_dir();
- vec![
- ("agent_gemini", "gemini", vec![home.join(".gemini").join("settings.json")]),
- (
- "agent_antigravity",
- "antigravity",
- vec![
- home.join(".config").join("antigravity").join("hooks.json"),
- home.join(".gemini").join("config").join("hooks.json"),
- ],
- ),
- ("agent_codex", "codex", vec![home.join(".codex").join("hooks.json")]),
- ("agent_copilot", "copilot", vec![home.join(".copilot").join("hooks").join("coucou.json")]),
- ("agent_muse", "muse", vec![home.join(".config").join("muse").join("settings.json")]),
- ]
-}
-
+ /// A JSON file as a value; anything missing or unreadable is "nothing there".
+ fn read_json(path: &PathBuf) -> Value {
+ std::fs::read(path)
+ .ok()
+ .and_then(|bytes| {
+ let text = bytes.strip_prefix(&[0xEF, 0xBB, 0xBF]).unwrap_or(&bytes).to_vec();
+ serde_json::from_slice(&text).ok()
+ })
+ .unwrap_or(Value::Null)
+ }
+
+ /// Pill ID → connected, for every hook-driven pill.
+ pub fn status() -> HashMap<String, bool> {
+ let claude = claude_hooks_present(&read_json(&crate::hooks::settings_path()));
+ let mut out = HashMap::new();
- // Cursor sessions are Claude Code in Cursor's terminal: the same hooks.
+ out.insert("integration_claude".to_string(), claude);
- out.insert("agent_cursor".to_string(), claude);
- for (pill, agent, paths) in agent_configs() {
- let present = paths.iter().any(|p| agent_hooks_present(&read_json(p), agent));
- out.insert(pill.to_string(), present);
++ for agent in crate::agents::list() {
++ out.insert(format!("agent_{}", agent.id), agent.installed);
++ }
++ // The Cursor pill also carries Claude Code run in Cursor's terminal, which
++ // Claude Code's own hooks report.
++ if claude {
++ out.insert("agent_cursor".to_string(), true);
+ }
+ out
+ }
+
+ #[cfg(test)]
+ mod tests {
+ use super::*;
+
+ fn settings(json: &str) -> Value {
+ serde_json::from_str(json).unwrap_or(Value::Null)
+ }
+
+ // The ten cases of tests/ClaudeHookDetectionTests.swift, plus this build's relay.
+
+ #[test]
+ fn the_hook_coucou_writes_is_installed() {
+ assert!(claude_hooks_present(&settings(
+ r#"{"hooks":{"SessionStart":[{"hooks":[
+ {"type":"command","command":"\"C:/Users/me/AppData/Local/Coucou/bin/coucou-hook.exe\" SessionStart"}]}]}}"#
+ )));
+ assert!(claude_hooks_present(&settings(
+ r#"{"hooks":{"SessionStart":[{"hooks":[
+ {"type":"command","command":"'/home/me/.local/share/coucou/bin/coucou-hook' SessionStart"}]}]}}"#
+ )));
+ }
+
+ #[test]
+ fn the_mac_builds_hooks_count_too() {
+ assert!(claude_hooks_present(&settings(
+ r#"{"hooks":{"SessionStart":[{"hooks":[
+ {"type":"command","command":"$HOME/.claude/coucou/nb-hook"}]}]}}"#
+ )));
+ assert!(claude_hooks_present(&settings(
+ r#"{"hooks":{"SessionStart":[{"hooks":[
+ {"type":"command","command":"/Applications/NotchBuddy.app/.../nb-hook"}]}]}}"#
+ )));
+ }
+
+ #[test]
+ fn our_hook_next_to_somebody_elses_is_installed() {
+ assert!(claude_hooks_present(&settings(
+ r#"{"hooks":{"SessionStart":[
+ {"hooks":[{"type":"command","command":"/usr/local/bin/other-tool"}]},
+ {"hooks":[{"type":"command","command":"$HOME/.claude/coucou/nb-hook"}]}]}}"#
+ )));
+ }
+
+ #[test]
+ fn other_tools_only_is_not_installed() {
+ // The case that showed "Key not configured" on macOS.
+ assert!(!claude_hooks_present(&settings(
+ r#"{"hooks":{"SessionStart":[{"hooks":[
+ {"type":"command","command":"$HOME/.vibe-island/bin/vibe-island-bridge"},
+ {"type":"command","command":"python3 /Users/me/.claude/skills/harness/hook.py"}]}]}}"#
+ )));
+ }
+
+ #[test]
+ fn hooks_for_other_events_do_not_count() {
+ assert!(!claude_hooks_present(&settings(
+ r#"{"hooks":{"PreToolUse":[{"hooks":[
+ {"type":"command","command":"$HOME/.claude/coucou/nb-hook"}]}]}}"#
+ )));
+ }
+
+ #[test]
+ fn malformed_or_empty_settings_never_read_as_installed() {
+ for json in [
+ "{}",
+ r#"{"hooks":{"SessionStart":[]}}"#,
+ r#"{"hooks":{"SessionStart":[{"hooks":[{"type":"command"}]}]}}"#,
+ r#"{"hooks":{"SessionStart":"not-an-array"}}"#,
+ r#"{"hooks":"not-an-object"}"#,
+ "not json",
+ ] {
+ assert!(!claude_hooks_present(&settings(json)), "{json}");
+ }
+ }
-
- // Other agents: any place in their config that runs the relay with their tag.
-
- #[test]
- fn an_agent_is_connected_when_its_config_runs_the_relay_with_its_tag() {
- let gemini = settings(
- r#"{"hooks":{"BeforeTool":[{"hooks":[
- {"type":"command","command":"\"C:/Users/me/AppData/Local/Coucou/bin/coucou-hook.exe\" --agent gemini BeforeTool"}]}]}}"#,
- );
- assert!(agent_hooks_present(&gemini, "gemini"));
- assert!(!agent_hooks_present(&gemini, "codex"));
-
- // Copilot keeps the command under `bash` / `powershell`.
- let copilot = settings(
- r#"{"version":1,"hooks":{"preToolUse":[{"type":"command",
- "powershell":"& 'C:\\Users\\me\\AppData\\Local\\Coucou\\bin\\coucou-hook.exe' --agent copilot preToolUse"}]}}"#,
- );
- assert!(agent_hooks_present(&copilot, "copilot"));
-
- // The Mac's relay, in a config synced from a Mac.
- let codex = settings(r#"{"hooks":{"Stop":[{"hooks":[{"command":"~/.claude/coucou/nb-hook --agent codex"}]}]}}"#);
- assert!(agent_hooks_present(&codex, "codex"));
- }
-
- #[test]
- fn a_longer_tag_or_another_program_is_not_the_agent() {
- let beta = settings(r#"{"hooks":{"x":[{"command":"coucou-hook --agent gemini-beta x"}]}}"#);
- assert!(!agent_hooks_present(&beta, "gemini"));
- let other = settings(r#"{"hooks":{"x":[{"command":"other-relay --agent gemini x"}]}}"#);
- assert!(!agent_hooks_present(&other, "gemini"));
- let quoted = settings(r#"{"cmd":["coucou-hook", "--agent gemini"]}"#);
- // Split over two strings: no single command runs the relay with the tag.
- assert!(!agent_hooks_present(&quoted, "gemini"));
- assert!(!agent_hooks_present(&Value::Null, "gemini"));
- let at_end = settings(r#"{"c":"coucou-hook --agent muse"}"#);
- assert!(agent_hooks_present(&at_end, "muse"));
- }
+ }
diff --cc windows/src-tauri/src/lib.rs
index 06ef6602,681113da..aa71d359
--- a/windows/src-tauri/src/lib.rs
+++ b/windows/src-tauri/src/lib.rs
@@@ -1,8 -1,7 +1,9 @@@
// Coucou for Windows — app wiring and the commands the island calls.
+ mod agent_hooks;
+mod agents;
mod claude;
+mod config_file;
mod files;
mod hooks;
mod integrations;
@@@ -430,13 -434,13 +459,16 @@@ pub fn run()
list_monitors,
open_url,
open_in_vscode,
+ open_session,
+ open_claude_desktop,
quit_app,
hooks_status,
+ agent_hooks_status,
hooks_preview,
hooks_apply,
+ agent_hooks_list,
+ agent_hooks_preview,
+ agent_hooks_apply,
approval_decision,
approval_answer,
approval_ack,
diff --cc windows/src/core/pills.ts
index 00000000,efb797cf..ad6c9aeb
mode 000000,100644..100644
--- a/windows/src/core/pills.ts
+++ b/windows/src/core/pills.ts
@@@ -1,0 -1,237 +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.
++ // A plugin that starts the relay, written from Settings → Agents (agents.rs).
+ { id: "agent_opencode", name: "OpenCode", color: "#4ADE80", category: "agent",
- subtitle: "Agent", source: "agent", support: "no", connect: hooks },
++ subtitle: "Agent", source: "agent", support: "yes", connect: hooks },
+ { id: "agent_amp", name: "Amp", color: "#F59E0B", category: "agent",
- subtitle: "Agent", source: "agent", support: "no", connect: hooks },
++ subtitle: "Agent", source: "agent", support: "yes", connect: hooks },
+ { id: "agent_hermes", name: "Hermes", color: "#C084FC", category: "agent",
- subtitle: "Agent", source: "agent", support: "no", connect: hooks },
++ subtitle: "Agent", source: "agent", support: "yes", 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 --cc windows/src/core/state.ts
index cb0d1557,5409ba83..4d060fd3
--- a/windows/src/core/state.ts
+++ b/windows/src/core/state.ts
@@@ -29,7 -35,7 +35,7 @@@ export interface AgentTask
export interface ApprovalInfo {
requestId: string;
sessionId: string;
- /** The pill the request belongs to: Claude Code's, or an agent's (Codex…). */
- /** The pill the request belongs to: VS Code's, or Cursor's. */
++ /** The pill the request belongs to: VS Code's or Cursor's (Claude Code), or an agent's (Codex…). */
pillId: string;
tool: string;
command: string;
diff --cc windows/src/island/hooks.ts
index cb458675,53a1962c..f3044136
--- a/windows/src/island/hooks.ts
+++ b/windows/src/island/hooks.ts
@@@ -8,7 -6,7 +8,8 @@@
import { Bridge, onEvent } from "../core/bridge";
import { Sound } from "../core/sound";
import { State, type AskedQuestion } from "../core/state";
+ import { pillDefinition } from "../core/pills";
+import { APPROVAL_AGENTS, agentColor, agentName, validateAgent } from "./agents";
import type { Island } from "./island";
const CLAUDE_ID = "integration_claude";
@@@ -59,10 -49,27 +57,12 @@@ interface HookPayload
tool_input?: Record<string, unknown>;
/** Optional agent tag: lowercase, digits and hyphens, ≤ 24 chars. */
coucou_agent?: string;
+ /** Hermes: where the session runs (telegram, discord…; "cli" in a terminal). */
+ platform?: 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. */
-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"];
-
-function agentColor(name: string): string {
- 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];
-}
-
const PROJECT_ALIASES: Record<string, string> = {
"notch-buddy": "Notch Buddy",
notchbuddy: "Notch Buddy",
@@@ -204,13 -210,16 +210,14 @@@ function handleHook(island: Island, pay
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 focused = State.focusId === agentId;
+ const sessionId = payload.session_id ?? "";
- const focused = State.focusId === agentId;
-
/** Alerts force the island open; work events only reveal the compact island. */
const surface = (view: Parameters<Island["alert"]>[0], isAlert: boolean) => {
if (State.mode === "expanded") {
@@@ -225,9 -234,12 +232,12 @@@
/** Ensure the agent pill exists (no-op for Claude Code). */
const ensurePill = () => {
if (isExternalAgent) {
- State.upsertExternalAgent(agentId, validAgent!, agentColor(validAgent!));
+ State.upsertExternalAgent(agentId, agentName(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);
}
};
@@@ -240,22 -252,6 +250,26 @@@
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);
+ }
+
++ // Read after the card above is dropped: its pill may have handed the front
++ // back to the pill you were on.
++ const focused = State.focusId === agentId;
++
switch (name) {
case "SessionStart":
ensurePill();
@@@ -324,13 -316,12 +338,14 @@@
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);
+ // 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(
@@@ -406,13 -389,15 +421,16 @@@
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 = {
+ // 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),
@@@ -422,17 -407,8 +440,10 @@@
// line is synchronous, so the card really is up by the time it lands.
if (requestId) void Bridge.approvalAck(requestId);
State.updateTask(agentId, view);
- State.isPinned = true;
Sound.play(view);
- if (State.focusId === agentId) {
- island.alert(view);
- } else {
- // 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. Clicking the pill brings the card up.
- State.setPillBadge(agentId, "approval");
- island.reveal();
- }
++ // Any agent's card (Claude Code, Codex, Copilot CLI, Muse Code) comes up
++ // the same way: beginApproval brought its pill to the front.
+ 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 --cc windows/src/island/island.ts
index 4f547d40,39939e4e..575db47f
--- a/windows/src/island/island.ts
+++ b/windows/src/island/island.ts
@@@ -123,14 -133,12 +133,16 @@@ 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.
++ // A pill with a waiting request opens on its card: going back to it
++ // after looking at another pill brings the card up again.
+ const req = State.pendingApproval;
+ if (req?.pillId === id) this.setView(req.questions ? "question" : "approval");
},
openTerminal: () => {
- const cwd = State.focusTask?.sessionCwd ?? null;
- void Bridge.openInVSCode(cwd);
+ const task = State.focusTask;
+ // Sessions from the Claude desktop app live there, not in a terminal.
+ if (task?.id === CLAUDE_DESKTOP_ID) void Bridge.openClaudeDesktop();
+ else void Bridge.openSession(task?.sessionId ?? null, task?.sessionCwd ?? null);
},
// The ↗ button — same targets as openAgentTarget() on macOS.
openTarget: () => {
diff --cc windows/src/settings/main.ts
index 8009de7e,9f3cd188..d8b36e51
--- a/windows/src/settings/main.ts
+++ b/windows/src/settings/main.ts
@@@ -5,9 -5,11 +5,13 @@@
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";
+import { agentsSection } from "./agents";
+import { renderDiff, statusDot } from "./parts";
/** Where secrets.rs keeps the keys on this OS. */
const KEY_STORE = navigator.userAgent.includes("Windows")
@@@ -460,8 -564,8 +562,9 @@@ async function main()
root.append(
h("h1", {}, h("span", { text: "Coucou" }), h("span", { class: "version", text: version })),
claudeSection(status),
+ agentsSection(agents),
apiSection(hasKey),
+ activePillsSection(connected),
integrationsSection(present),
generalSection(),
h("div", {
diff --cc windows/src/views/views.ts
index f49f714e,a7bb9f22..2fdfe627
--- a/windows/src/views/views.ts
+++ b/windows/src/views/views.ts
@@@ -195,9 -195,6 +195,8 @@@ function buildOverview(actions: ViewAct
cardKey = "";
}
clear(who);
+ // 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";
++ // pill it is, as on the Mac (PillDefinition.sessionSubtitle).
who.append(
dot(task.color, 7),
h("span", { class: "name", text: task.name }),
@@@ -239,6 -236,17 +238,20 @@@
};
}
+ /**
+ * IntegrationCardView.agentSessionActive: a workspace tool or an agent — or
+ * any other tagged agent — with something going on.
+ */
+ export function hasSessionTicker(task: AgentTask): boolean {
++ // A pill made for an agent's session (Gemini CLI, Codex… not declared) only
++ // exists while that session does: it keeps the ticker from the first event.
++ if (task.source === "agent" && !task.isIntegration) return true;
+ 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);
@@@ -479,9 -503,12 +510,13 @@@ function buildFinished(actions: ViewAct
el,
sync() {
clear(who);
- who.append(agentWho(State.focusTask, "Claude Code 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";
+ // Sessions from the Claude desktop app live there, not in a terminal.
+ const label = State.focusTask?.id === "agent_claude-desktop" ? "Open Claude" : "Open terminal";
+ const span = open.firstElementChild as HTMLElement;
+ if (span.textContent !== label) span.textContent = label;
},
};
}
diff --cc windows/tests/hooks.test.mjs
index f5fe07a4,a3bd45ff..c4fddb66
--- a/windows/tests/hooks.test.mjs
+++ b/windows/tests/hooks.test.mjs
@@@ -242,95 -242,56 +242,155 @@@ test("an agent's pill goes away when it
});
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"), []);
+ 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.
++ // The same card as Claude Code's: it comes up and its pill comes to the
++ // front, even from behind Claude Code's pill (unified with Mac #120).
+ assert.equal(task(id).state, "approval");
- assert.equal(task(id).pillBadge, "approval");
- assert.deepEqual(asked, ["reveal"]);
- // Claude Code's pill is untouched.
++ assert.equal(State.focusId, id);
++ assert.deepEqual(asked, ["alert:approval"]);
++ // Claude Code's pill is untouched, and comes back once the card goes.
+ assert.equal(task().state, "idle");
+ assert.equal(task().pillBadge ?? null, null);
++ State.endApproval();
++ assert.equal(State.focusId, CLAUDE);
+ }
+});
+
++test("an agent's turn ending takes its card down and gives the front back", () => {
++ State.setFocus("integration_n8n");
++ hook({ hook_event_name: "PermissionRequest", request_id: "r1", session_id: "s1", coucou_agent: "codex", tool_name: "Bash" });
++ assert.equal(State.focusId, "agent_codex");
++ asked = [];
++ hook({ hook_event_name: "Stop", session_id: "s1", coucou_agent: "codex" });
+ assert.equal(State.pendingApproval, null);
++ assert.equal(State.focusId, "integration_n8n");
++ // The stop no longer has the front: its pill is badged, the view is not taken.
++ assert.equal(task("agent_codex").pillBadge, "finished");
++ assert.ok(!asked.includes("alert:finished"));
++});
++
+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("Hermes says where a gateway session comes from", () => {
+ hook({ hook_event_name: "SessionStart", coucou_agent: "hermes", platform: "telegram" });
+ assert.deepEqual(task("agent_hermes").steps, ["Telegram"]);
+ hook({ hook_event_name: "SessionEnd", coucou_agent: "hermes" });
+ hook({ hook_event_name: "SessionStart", coucou_agent: "hermes", platform: "cli" });
+ assert.deepEqual(task("agent_hermes").steps, []);
+});
+
+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."]);
});
+ test("a Claude Desktop session gets the Claude Desktop pill, in its colour (Mac #191)", () => {
+ hook({ hook_event_name: "SessionStart", cwd: "C:\\p\\proj", session_id: "d1", coucou_agent: "claude-desktop" });
+ const desktop = task("agent_claude-desktop");
+ assert.equal(desktop.color, "#D97757");
+ assert.equal(desktop.sessionId, "d1");
+ assert.equal(task().state, "idle");
+ // Its permission requests are answered in the app, as on macOS.
+ hook({ hook_event_name: "PermissionRequest", request_id: "r1", coucou_agent: "claude-desktop", tool_name: "Bash" });
+ assert.deepEqual(sent("approval_decline"), [{ requestId: "r1" }]);
+ });
+
+ // ── 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 --cc windows/tests/pills.test.mjs
index 00000000,143347b1..7e06d895
mode 000000,100644..100644
--- a/windows/tests/pills.test.mjs
+++ b/windows/tests/pills.test.mjs
@@@ -1,0 -1,260 +1,265 @@@
+ // 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"]) {
++ for (const id of ["ai_ollama", "ai_lmstudio", "integration_music"]) {
+ assert.ok(!windows.includes(id), id);
+ assert.ok(!linux.includes(id), id);
+ }
++ // Their plugins are written from Settings → Agents on both systems.
++ for (const id of ["agent_opencode", "agent_amp", "agent_hermes"]) {
++ 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"]) {
++ for (const id of ["integration_claude", "agent_cursor", "agent_codex", "agent_gemini", "agent_copilot", "agent_muse", "agent_antigravity", "agent_opencode", "agent_amp", "agent_hermes"]) {
+ 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"),
++ sanitizeDeclared({ mainPill: "agent_cursor", activeIntegrations: ["agent_cursor", "integration_n8n", "integration_n8n", "ai_ollama"] }, "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, "integration_music", "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");
+ });