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/chat-providers: Google AI, OpenAI, OpenRouter and local models in the chat

Claude5728a27a00b6
diff --cc windows/README.md
index 4214d943,171fb867..0578f5f1
--- a/windows/README.md
+++ b/windows/README.md
@@@ -48,29 -48,9 +48,30 @@@ installs for the current user only —
| Tray icon | Open, Settings…, Pause, Quit |
Everything else happens on its own: a Claude Code permission request opens the
-island with **Deny / Allow**, a finished session shows what it did, and
+island with **Deny / Allow**, a question from Claude Code shows its options to
+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, OpenCode, Amp, Hermes, Claude
- Desktop), the Anthropic chat,
++Desktop), the chat providers (Anthropic, Google AI, OpenAI, Ollama, LM Studio),
+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
++hooks are installed, never asks for a key; a local model server's pill says
++whether the chat is connected to it. 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">
@@@ -237,30 -190,14 +269,33 @@@ own window
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:
- 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, the one pill from the Mac catalog with nothing behind it here,
++ is left out.
+- 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.
+- 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.
+- Plan usage: the user's previous status line runs through Git Bash on Windows
+ (`/bin/sh` on Linux and Mac); without Git Bash it is not run, rather than
+ guessed at with `cmd`. The Codex CLI is looked for on `PATH` and in npm's,
+ Volta's, Bun's and pnpm's folders (and nvm's on Linux).
+ - The chat's model picker opens inside the chat card instead of a popover, and
+ it also offers OpenRouter and any OpenAI-compatible server, which the Mac
+ does not. Google AI, OpenAI and OpenRouter can see an image you dropped (sent
+ inline), where the Mac sends its name only.
## Linux
@@@ -304,16 -226,10 +339,18 @@@ What changes on Linux
gives no app the cursor position anywhere else.
- **Claude Code hooks** go through `~/.local/share/coucou/bin/coucou-hook` and a
Unix socket at `$XDG_RUNTIME_DIR/coucou.sock`. Both ends check that the other
- runs as the same user.
+ runs as the same user. Every other agent uses the same relay, single-quoted
+ for `sh`, and its config under `~` (see Supported agents). A config that is a
+ symlink (dotfiles) is written through to its target, with its permissions
+ kept.
- **Keys** live in the Secret Service (GNOME Keyring, KWallet).
+- **Plan usage**: the status line relay is `~/.local/share/coucou/bin/coucou-hook
+ --statusline` and runs your previous status line with `/bin/sh -c`, like Claude
+ Code. Codex is found on `$PATH`, in `~/.local/bin`, npm's global prefix, Volta,
+ Bun, pnpm, or nvm (newest Node first), since a desktop launch often has a
+ shorter `$PATH` than your shell.
+ - **Mochi's greeting** uses the full name in your account's GECOS field
+ (`chfn` sets it); without one the chat stays neutral.
- **Files**: preferences in `~/.config/coucou/`, the log at
`~/.local/share/coucou/coucou.log`.
- What the Windows build leaves out, this one does too: sending a file by
diff --cc windows/src-tauri/src/lib.rs
index 4eab7243,f4db6937..ed909777
--- a/windows/src-tauri/src/lib.rs
+++ b/windows/src-tauri/src/lib.rs
@@@ -1,15 -1,16 +1,20 @@@
// Coucou for Windows — app wiring and the commands the island calls.
+mod agent_hooks;
+mod agents;
+ mod chat;
mod claude;
+mod config_file;
+mod codex_plan;
mod files;
mod hooks;
+ mod identity;
mod integrations;
mod island;
+ mod local_chat;
mod log;
+ mod net;
+ mod openai_compat;
mod pipe;
mod platform;
mod secrets;
diff --cc windows/src-tauri/src/settings.rs
index 185d5cce,25445da3..98d522db
--- a/windows/src-tauri/src/settings.rs
+++ b/windows/src-tauri/src/settings.rs
@@@ -25,15 -24,18 +26,27 @@@ pub struct Settings
pub hooks_installed: bool,
/// Claude model used by the chat. Changeable in the settings window.
pub model: String,
+ /// Show the Claude plan pill (5 h and weekly limits) in the island's header.
+ /// Off until the user turns it on, so the header stays as it shipped.
+ pub show_plan_in_notch: bool,
+ /// Coucou's status line relay is the one in Claude Code's settings.json.
+ /// Like `hooks_installed`, the real state wins at launch over what was stored.
+ pub plan_relay_installed: bool,
+ /// Show the Codex plan pill (5 h / weekly limits from `codex app-server`).
+ /// Off by default; nothing is installed for it.
+ pub show_codex_plan_in_notch: bool,
+ /// Who the chat talks to: "anthropic", a cloud provider of
+ /// openai_compat.rs ("openai", "google", "openrouter"), or a model server
+ /// of local_chat.rs ("ollama", "lmstudio", "custom"). Picked in the chat view.
+ pub chat_provider: String,
+ /// The model picked for each provider other than Anthropic (whose model is
+ /// `model`), by provider id.
+ pub chat_models: BTreeMap<String, String>,
+ /// Addresses of the model servers once connected; empty means not connected.
+ pub ollama_url: String,
+ pub lmstudio_url: String,
+ /// Any other OpenAI-compatible server; its key, if any, is in the keychain.
+ pub custom_url: String,
}
fn default_model() -> String {
@@@ -58,9 -59,11 +71,14 @@@ impl Default for Settings
autostart: false,
hooks_installed: false,
model: default_model(),
+ show_plan_in_notch: false,
+ plan_relay_installed: false,
+ show_codex_plan_in_notch: false,
+ chat_provider: crate::chat::ANTHROPIC.into(),
+ chat_models: BTreeMap::new(),
+ ollama_url: String::new(),
+ lmstudio_url: String::new(),
+ custom_url: String::new(),
}
}
}
@@@ -323,9 -325,11 +341,14 @@@ mod tests
"autostart": true,
"hooksInstalled": true,
"model": "some-model",
+ "showPlanInNotch": true,
+ "planRelayInstalled": true,
- "showCodexPlanInNotch": true
++ "showCodexPlanInNotch": true,
+ "chatProvider": "ollama",
+ "chatModels": { "ollama": "llama3.2", "openai": "gpt-x" },
+ "ollamaUrl": "http://127.0.0.1:11434",
+ "lmstudioUrl": "http://127.0.0.1:1234",
+ "customUrl": "https://llm.example.com"
}"#;
fn custom() -> Value {
@@@ -653,9 -655,11 +676,14 @@@
"autostart",
"hooksInstalled",
"model",
+ "showPlanInNotch",
+ "planRelayInstalled",
+ "showCodexPlanInNotch",
+ "chatProvider",
+ "chatModels",
+ "ollamaUrl",
+ "lmstudioUrl",
+ "customUrl",
]
);
let _ = std::fs::remove_dir_all(&dir);
diff --cc windows/src/core/pills.ts
index ad6c9aeb,00000000..2c992cd6
mode 100644,000000..100644
--- a/windows/src/core/pills.ts
+++ b/windows/src/core/pills.ts
@@@ -1,237 -1,0 +1,241 @@@
+// 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 }
++ /** A model server the chat is connected to (Settings → Local models). */
++ | { kind: "server"; field: "ollamaUrl" | "lmstudioUrl" }
+ /** 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" };
++const server = (field: "ollamaUrl" | "lmstudioUrl"): PillConnect => ({ kind: "server", field });
+
+/** 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 },
+ // 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: "yes", connect: hooks },
+ { id: "agent_amp", name: "Amp", color: "#F59E0B", category: "agent",
+ subtitle: "Agent", source: "agent", support: "yes", connect: hooks },
+ { id: "agent_hermes", name: "Hermes", color: "#C084FC", category: "agent",
+ 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.
++ // The chat talks to each of them (src-tauri/src/chat.rs): a key for the
++ // cloud ones, a connected server for the local ones.
+ { id: "ai_google", name: "Google AI", color: ACCENT.google, category: "ai",
- subtitle: "Chat", source: "n8n", support: "soon", connect: key("google-api-key") },
++ subtitle: "Chat", source: "n8n", support: "yes", 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") },
++ subtitle: "Chat", source: "n8n", support: "yes", connect: key("openai-api-key") },
+ { id: "ai_ollama", name: "Ollama", color: ACCENT.ollama, category: "ai",
- subtitle: "Chat", source: "n8n", support: "no", connect: none },
++ subtitle: "Chat", source: "n8n", support: "yes", connect: server("ollamaUrl") },
+ { id: "ai_lmstudio", name: "LM Studio", color: ACCENT.lmstudio, category: "ai",
- subtitle: "Chat", source: "n8n", support: "no", connect: none },
++ subtitle: "Chat", source: "n8n", support: "yes", connect: server("lmstudioUrl") },
+ // ── 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 98a170be,955e4378..52204d9b
--- a/windows/src/core/state.ts
+++ b/windows/src/core/state.ts
@@@ -2,11 -2,7 +2,12 @@@
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";
+import type { CodexPlanUsage, PlanUsage } from "./plan";
+ import type { ProviderId } from "./providers";
export type AgentSource = "claudeCode" | "n8n" | "agent";
export type PillBadge = "approval" | "finished" | "error";
@@@ -104,12 -93,14 +105,20 @@@ export interface Settings
hooksInstalled: boolean;
/** Claude model used by the chat. */
model: string;
+ /** Show the Claude plan pill (5 h and weekly limits) in the island's header. */
+ showPlanInNotch: boolean;
+ /** Coucou's status line relay is installed in Claude Code's settings. */
+ planRelayInstalled: boolean;
+ /** Show the Codex plan pill in the island's header. */
+ showCodexPlanInNotch: boolean;
+ /** Who the chat talks to (see core/providers.ts); picked in the chat view. */
+ chatProvider: ProviderId;
+ /** The model picked for each provider other than Anthropic, by provider id. */
+ chatModels: Record<string, string>;
+ /** Model server addresses once connected; empty means not connected. */
+ ollamaUrl: string;
+ lmstudioUrl: string;
+ customUrl: string;
}
export const DEFAULT_SETTINGS: Settings = {
@@@ -125,9 -115,11 +134,14 @@@
autostart: false,
hooksInstalled: false,
model: "claude-opus-5",
+ showPlanInNotch: false,
+ planRelayInstalled: false,
+ showCodexPlanInNotch: false,
+ chatProvider: "anthropic",
+ chatModels: {},
+ ollamaUrl: "",
+ lmstudioUrl: "",
+ customUrl: "",
};
type Listener = () => void;
diff --cc windows/src/island/integrations.ts
index 10817291,862ffb14..bf798c93
--- a/windows/src/island/integrations.ts
+++ b/windows/src/island/integrations.ts
@@@ -15,40 -25,10 +15,44 @@@ export function registerIntegrationHand
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 "server":
++ // A local model server counts once the chat is connected to it.
++ configured = State.settings[def.connect.field] !== "";
++ 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 };
}
diff --cc windows/src/settings/main.ts
index 722e2457,cce0d926..700607f3
--- a/windows/src/settings/main.ts
+++ b/windows/src/settings/main.ts
@@@ -3,20 -3,10 +3,21 @@@
// integrations land here too in a later stage.
import "./settings.css";
-import { Bridge, onEvent, type HookStatus } from "../core/bridge";
+import { Bridge, onEvent, type HookPreview, type HookStatus } from "../core/bridge";
+ import { CUSTOM_SERVER_KEY, providerDef, urlExposure } from "../core/providers";
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")
+ ? "Windows Credential Manager"
+ : "Secret Service (GNOME Keyring, KWallet)";
let settings: Settings = { ...DEFAULT_SETTINGS };
let version = "";
@@@ -383,87 -255,261 +384,348 @@@ function apiSection(hasKey: boolean): H
);
}
+// ── 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";
++ if (def.connect.kind === "server" && !settings[def.connect.field]) return "Not connected";
+ 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,
+ );
+}
+
+ // ── Chat providers section ────────────────────────────────────────────────────
+
+ const CHAT_STRINGS = {
+ providersTitle: "Chat providers",
+ providersHint: "Chat with Google AI, OpenAI or OpenRouter instead of Claude: add a key here, then click the model name above the chat box to switch provider and model. Keys stay in the system keychain. These providers get no web search and no tools: they can answer, never act on this computer.",
+ stored: "•••••••• (stored)",
+ save: "Save",
+ remove: "Remove",
+ localTitle: "Local models",
+ localHint: "Chat with a model you run yourself: Ollama or LM Studio (leave the address empty for the usual one on this computer), or any server that speaks the OpenAI API, such as vLLM or llama.cpp. Once connected, pick it above the chat box.",
+ connect: "Connect",
+ connecting: "Connecting…",
+ disconnect: "Disconnect",
+ useInChat: "Use in chat",
+ inUse: "In use",
+ keyOptional: "API key (optional)",
+ localOnly: "Nothing leaves your PC: the server runs on this computer.",
+ remote: "This address is another machine: what you ask is sent to it.",
+ remoteHttp: "This address is another machine, over plain http: what you ask travels unencrypted.",
+ keyOverHttp: "Warning: the key would be sent unencrypted (http://) to another machine. Use https://, or a server on this computer.",
+ invalid: "Not a valid http:// or https:// address.",
+ noModels: (name: string) => `No models yet. Download one in ${name} first.`,
+ models: (n: number) => (n === 1 ? "1 model" : `${n} models`),
+ };
+
+ interface CloudDef {
+ id: "google" | "openai" | "openrouter";
+ name: string;
+ placeholder: string;
+ where: string;
+ }
+
+ const CLOUD: CloudDef[] = [
+ { id: "google", name: "Google AI", placeholder: "AIza…", where: "aistudio.google.com" },
+ { id: "openai", name: "OpenAI", placeholder: "sk-…", where: "platform.openai.com" },
+ { id: "openrouter", name: "OpenRouter", placeholder: "sk-or-…", where: "openrouter.ai/keys" },
+ ];
+
-function chatProvidersSection(present: Record<string, boolean>): HTMLElement {
++function chatProvidersSection(
++ present: Record<string, boolean>,
++ keyChanged: (key: string, on: boolean) => void,
++): HTMLElement {
+ const list = h("div", { style: "display:flex;flex-direction:column;gap:8px" });
+ for (const def of CLOUD) {
+ const p = providerDef(def.id);
+ const key = p.key!;
+ const input = h("input", {
+ type: "password",
+ placeholder: present[key] ? CHAT_STRINGS.stored : def.placeholder,
+ autocomplete: "off",
+ spellcheck: "false",
+ style: "flex:1 1 auto;min-width:0",
+ }) as HTMLInputElement;
+ const dotEl = statusDot(present[key] ?? false);
+ const saveBtn = h("button", { text: CHAT_STRINGS.save });
+ const removeBtn = h("button", { class: "danger", text: CHAT_STRINGS.remove });
+ const refresh = () => {
+ input.placeholder = present[key] ? CHAT_STRINGS.stored : def.placeholder;
+ dotEl.style.background = present[key] ? "#22c55e" : "#f4505e";
+ removeBtn.style.display = present[key] ? "" : "none";
+ };
+ saveBtn.addEventListener("click", async () => {
+ const value = input.value.trim();
+ if (!value) return;
+ try {
+ await Bridge.secretSet(key, value);
+ present[key] = true;
+ input.value = "";
++ keyChanged(key, true);
+ } catch {
+ dotEl.style.background = "#f5a524";
+ return;
+ }
+ refresh();
+ });
+ removeBtn.addEventListener("click", async () => {
+ try {
+ await Bridge.secretClear(key);
+ present[key] = false;
++ keyChanged(key, false);
+ } catch {
+ dotEl.style.background = "#f5a524";
+ return;
+ }
+ refresh();
+ });
+ refresh();
+ list.append(
+ h("div", { class: "row" },
+ h("label", {},
+ h("i", { class: "dot", style: `background:${p.accent};margin-right:8px` }),
+ h("span", { text: def.name }),
+ ),
+ input, saveBtn, removeBtn, dotEl,
+ ),
+ h("div", { class: "hint", style: "margin:-4px 0 0 144px", text: `Key from ${def.where}` }),
+ );
+ }
+ return h(
+ "section",
+ {},
+ h("h2", {}, h("span", { text: CHAT_STRINGS.providersTitle })),
+ h("div", { class: "hint", text: CHAT_STRINGS.providersHint }),
+ list,
+ );
+ }
+
+ // ── Local models section ──────────────────────────────────────────────────────
+
+ type LocalId = "ollama" | "lmstudio" | "custom";
+
+ /** Redraws the local models section after a change made elsewhere (the island). */
+ let localRedraw: (() => void) | null = null;
+
+ const LOCAL: Record<LocalId, { name: string; usual: string }> = {
+ ollama: { name: "Ollama", usual: "http://127.0.0.1:11434" },
+ lmstudio: { name: "LM Studio", usual: "http://127.0.0.1:1234" },
+ // No usual address: any server that speaks the OpenAI API.
+ custom: { name: "OpenAI-compatible", usual: "" },
+ };
+
+ /** What an address means for the user's data, as a hint line. */
+ function exposureNotice(url: string, withKey: boolean): HTMLElement | null {
+ switch (urlExposure(url)) {
+ case "local":
+ return h("div", { class: "hint", text: CHAT_STRINGS.localOnly });
+ case "remote":
+ return h("div", { class: "hint", text: CHAT_STRINGS.remote });
+ case "remote-http":
+ return withKey
+ ? h("div", { class: "notice warn", text: CHAT_STRINGS.keyOverHttp })
+ : h("div", { class: "hint", text: CHAT_STRINGS.remoteHttp });
+ case "invalid":
+ return url.trim() ? h("div", { class: "notice err", text: CHAT_STRINGS.invalid }) : null;
+ }
+ }
+
+ function localSection(customKey: boolean): HTMLElement {
+ const body = h("div", { style: "display:flex;flex-direction:column;gap:14px" });
+ const section = h(
+ "section",
+ {},
+ h("h2", {}, h("span", { text: CHAT_STRINGS.localTitle })),
+ h("div", { class: "hint", text: CHAT_STRINGS.localHint }),
+ body,
+ );
+ const redraw = () => {
+ clear(body);
+ for (const id of Object.keys(LOCAL) as LocalId[]) body.append(serverBlock(id));
+ };
+
+ function serverBlock(id: LocalId): HTMLElement {
+ const def = LOCAL[id];
+ const p = providerDef(id);
+ const field = p.urlField!;
+ const connected = settings[field] !== "";
+ const status = h("div", {});
+ const exposure = h("div", {});
+ const label = h("label", {},
+ h("i", { class: "dot", style: `background:${p.accent};margin-right:8px` }),
+ h("span", { text: def.name }),
+ );
+ const block = h("div", { style: "display:flex;flex-direction:column;gap:6px" });
+
+ if (connected) {
+ const inUse = settings.chatProvider === id;
+ const use = h("button", { class: inUse ? "" : "primary", text: inUse ? CHAT_STRINGS.inUse : CHAT_STRINGS.useInChat });
+ use.disabled = inUse;
+ use.addEventListener("click", () => {
+ settings.chatProvider = id;
+ void save().then(redraw);
+ });
+ const disconnect = h("button", { class: "danger", text: CHAT_STRINGS.disconnect });
+ disconnect.addEventListener("click", async () => {
+ settings[field] = "";
+ if (settings.chatProvider === id) settings.chatProvider = "anthropic";
+ if (id === "custom") {
+ await Bridge.secretClear(CUSTOM_SERVER_KEY).catch(() => {});
+ customKey = false;
+ }
+ await save();
+ redraw();
+ });
+ block.append(
+ h("div", { class: "row" }, label, h("span", { class: "path", text: settings[field] }), statusDot(true), use, disconnect),
+ status,
+ );
+ exposure.append(exposureNotice(settings[field], id === "custom" && customKey) ?? "");
+ block.append(exposure);
+ return block;
+ }
+
+ const input = h("input", {
+ type: "text",
+ placeholder: def.usual || "https://llm.example.com",
+ style: "flex:1 1 auto;min-width:0",
+ spellcheck: "false",
+ autocomplete: "off",
+ }) as HTMLInputElement;
+ // A custom server may want a key; it goes to the keychain, never to settings.json.
+ const key = h("input", {
+ type: "password",
+ placeholder: customKey ? CHAT_STRINGS.stored : CHAT_STRINGS.keyOptional,
+ style: "flex:1 1 auto;min-width:0",
+ autocomplete: "off",
+ spellcheck: "false",
+ }) as HTMLInputElement;
+ const connect = h("button", { class: "primary", text: CHAT_STRINGS.connect });
+
+ const showExposure = () => {
+ clear(exposure);
+ const withKey = id === "custom" && (customKey || key.value.trim() !== "");
+ const notice = exposureNotice(input.value || def.usual, withKey);
+ if (notice) exposure.append(notice);
+ };
+ input.addEventListener("input", showExposure);
+ key.addEventListener("input", showExposure);
+
+ connect.addEventListener("click", async () => {
+ connect.disabled = true;
+ clear(status);
+ status.append(h("div", { class: "hint", text: CHAT_STRINGS.connecting }));
+ try {
+ if (id === "custom" && key.value.trim()) {
+ await Bridge.secretSet(CUSTOM_SERVER_KEY, key.value.trim());
+ key.value = "";
+ customKey = true;
+ }
+ const server = await Bridge.localConnect(id, input.value);
+ if (!server.models.length) {
+ clear(status);
+ status.append(h("div", { class: "notice err", text: CHAT_STRINGS.noModels(def.name) }));
+ } else {
+ settings[field] = server.url;
+ if (!server.models.includes(settings.chatModels[id] ?? "")) {
+ settings.chatModels = { ...settings.chatModels, [id]: server.models[0] };
+ }
+ await save();
+ redraw();
+ return;
+ }
+ } catch (err) {
+ clear(status);
+ status.append(h("div", { class: "notice err", text: String(err).replace(/^Error:\s*/, "") }));
+ }
+ connect.disabled = false;
+ });
+
+ block.append(h("div", { class: "row" }, label, input, connect));
+ if (id === "custom") block.append(h("div", { class: "row" }, h("label", { text: "" }), key));
+ block.append(status, exposure);
+ showExposure();
+ return block;
+ }
+
+ redraw();
+ localRedraw = redraw;
+ return section;
+ }
+
// ── Integrations section ──────────────────────────────────────────────────────
interface IntegrationDef {
@@@ -672,23 -694,20 +934,38 @@@ 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;
+ }
+ }
++ /** A chat provider's key was saved or removed: its pill's row says so at once. */
++ const keyChanged = (key: string, on: boolean) => {
++ for (const def of availablePills()) {
++ if (def.connect.kind === "key" && def.connect.key === key) connected[def.id] = on;
++ }
++ for (const redraw of declaredViews) redraw();
++ };
+ const chatKeys: Record<string, boolean> = {};
+ for (const def of CLOUD) {
+ const key = providerDef(def.id).key!;
+ chatKeys[key] = (await Bridge.secretPresent(key)) ?? false;
+ }
+ const customKey = (await Bridge.secretPresent(CUSTOM_SERVER_KEY)) ?? false;
clear(root);
root.append(
h("h1", {}, h("span", { text: "Coucou" }), h("span", { class: "version", text: version })),
claudeSection(status),
+ agentsSection(agents),
+ planSection(status),
apiSection(hasKey),
- chatProvidersSection(chatKeys),
++ chatProvidersSection(chatKeys, keyChanged),
+ localSection(customKey),
+ activePillsSection(connected),
integrationsSection(present),
generalSection(),
h("div", {
@@@ -698,8 -717,10 +975,11 @@@
);
void onEvent<Settings>("settings-changed", (s) => {
+ const before = `${settings.chatProvider}|${settings.ollamaUrl}|${settings.lmstudioUrl}|${settings.customUrl}`;
settings = { ...settings, ...s };
+ for (const redraw of declaredViews) redraw();
+ const after = `${settings.chatProvider}|${settings.ollamaUrl}|${settings.lmstudioUrl}|${settings.customUrl}`;
+ if (before !== after) localRedraw?.();
});
}
diff --cc windows/src/views/integrations.ts
index 75bc42a6,b8ad73c8..9d9741e7
--- a/windows/src/views/integrations.ts
+++ b/windows/src/views/integrations.ts
@@@ -55,29 -53,6 +55,30 @@@ 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?.connect.kind === "server") return configured ? ok("Connected") : missing("Not connected");
+ 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;
diff --cc windows/tests/pills.test.mjs
index 7e06d895,00000000..5c625995
mode 100644,000000..100644
--- a/windows/tests/pills.test.mjs
+++ b/windows/tests/pills.test.mjs
@@@ -1,265 -1,0 +1,277 @@@
+// 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,
++ isComingSoon, 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 ["ai_ollama", "ai_lmstudio", "integration_music"]) {
++ for (const id of ["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"]) {
++ // Their plugins are written from Settings → Agents, and the chat talks to
++ // every provider (port/chat-providers), on both systems.
++ for (const id of ["agent_opencode", "agent_amp", "agent_hermes", "ai_google", "ai_openai", "ai_ollama", "ai_lmstudio"]) {
+ 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("no chat provider that works here says Coming soon", () => {
++ for (const id of ["ai_anthropic", "ai_google", "ai_openai", "ai_ollama", "ai_lmstudio"]) {
++ assert.ok(!isComingSoon(id), id);
++ }
++ // The local servers are connected through Settings → Local models, not a key.
++ assert.deepEqual(pillDefinition("ai_ollama").connect, { kind: "server", field: "ollamaUrl" });
++ assert.deepEqual(pillDefinition("ai_lmstudio").connect, { kind: "server", field: "lmstudioUrl" });
++ assert.equal(pillDefinition("ai_google").connect.key, "google-api-key");
++});
++
+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", "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", "ai_ollama"] }, "linux"),
++ sanitizeDeclared({ mainPill: "agent_cursor", activeIntegrations: ["agent_cursor", "integration_n8n", "integration_n8n", "integration_music"] }, "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, "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.
++ // Every chat provider can be declared now that the chat talks to it.
+ assert.ok(toggleDeclared(d, "ai_google", "linux").includes("ai_google"));
++ assert.ok(toggleDeclared(d, "ai_ollama", "linux").includes("ai_ollama"));
+});
+
+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");
+});