Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Windows & Linux: a colour of your own for each Mochi

Shakib Bin Kabir810001f8a3eb
diff --git a/NotchBuddy/Resources/Localizable.xcstrings b/NotchBuddy/Resources/Localizable.xcstrings
index 17ebfe25..543d957d 100644
--- a/NotchBuddy/Resources/Localizable.xcstrings
+++ b/NotchBuddy/Resources/Localizable.xcstrings
@@ -1793,6 +1793,70 @@
}
}
},
+ "Color": {
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "اللون"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "রং"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Color"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Color"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Couleur"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "रंग"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Warna"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Cor"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Цвет"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "颜色"
+ }
+ }
+ }
+ },
"Coming soon": {
"localizations": {
"ar": {
@@ -2241,6 +2305,70 @@
}
}
},
+ "Default": {
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "الافتراضي"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "ডিফল্ট"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Default"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Predeterminado"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Par défaut"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "डिफ़ॉल्ट"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Bawaan"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Padrão"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "По умолчанию"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "默认"
+ }
+ }
+ }
+ },
"Deny": {
"localizations": {
"ar": {
diff --git a/windows/src-tauri/src/settings.rs b/windows/src-tauri/src/settings.rs
index 0d5c8456..2eec83fc 100644
--- a/windows/src-tauri/src/settings.rs
+++ b/windows/src-tauri/src/settings.rs
@@ -54,6 +54,11 @@ pub struct Settings {
/// season), "none" or an outfit id — the Mac's raw values. The island reads
/// anything it doesn't know as "auto", so the value is stored as it comes.
pub mochi_outfit: String,
+ /// A colour of the user's own for a pill's Mochi, by pill ID ("#RRGGBB"),
+ /// picked in Settings → Active pills. Empty means the catalog's colours.
+ /// Kept as it comes, like `mochi_outfit`: src/core/pill-colors.ts reads
+ /// whatever is not a colour as "no choice".
+ pub pill_colors: BTreeMap<String, String>,
/// Interface language: "" follows the system, else one of i18n::LANGUAGES
/// ("fr", "pt-BR", "zh-Hans"…). Kept as it comes, like `mochi_outfit`: a
/// code this build doesn't know reads as "".
@@ -112,6 +117,7 @@ impl Default for Settings {
custom_url: String::new(),
shortcuts: Default::default(),
mochi_outfit: "auto".into(),
+ pill_colors: BTreeMap::new(),
language: String::new(),
desktop_mochi: DesktopMochiPref::default(),
}
@@ -365,7 +371,8 @@ mod tests {
use serde_json::{json, Value};
/// A settings.json in which no value is the default one.
- const CUSTOM: &str = r#"{
+ // Two #: the colours in it are written "#RRGGBB".
+ const CUSTOM: &str = r##"{
"soundEnabled": false,
"soundVolume": 0.5,
"autoCloseInterval": 30.0,
@@ -386,9 +393,10 @@ mod tests {
"customUrl": "https://llm.example.com",
"shortcuts": { "openChat": { "keys": "Ctrl+Shift+K", "enabled": false } },
"mochiOutfit": "witchHat",
+ "pillColors": { "integration_claude": "#2DD4BF" },
"language": "pt-BR",
"desktopMochi": { "onDesktop": true, "spot": { "x": 1500.5, "y": -300.0, "space": "screen" } }
-}"#;
+}"##;
fn custom() -> Value {
serde_json::from_str(CUSTOM).unwrap()
@@ -509,6 +517,24 @@ mod tests {
assert_eq!(loaded.desktop_mochi.spot, None);
}
+ #[test]
+ fn a_file_from_before_the_colours_paints_every_pill_as_the_catalog_says() {
+ let loaded = parse(&custom_with("pillColors", None)).unwrap();
+ assert!(loaded.pill_colors.is_empty());
+ assert_eq!(loaded.mochi_outfit, "witchHat");
+ }
+
+ #[test]
+ fn pill_colours_are_kept_as_written_and_cost_nothing_else_when_unusable() {
+ // A pill a newer build added keeps its colour through a save by this one.
+ let loaded = parse(&custom_with("pillColors", Some(json!({ "agent_new": "#abcdef" })))).unwrap();
+ assert_eq!(loaded.pill_colors.get("agent_new").map(String::as_str), Some("#abcdef"));
+ // Not a map of strings: the colours fall back, and nothing else does.
+ let loaded = parse(&custom_with("pillColors", Some(json!(["#2DD4BF"])))).unwrap();
+ assert!(loaded.pill_colors.is_empty());
+ assert_eq!(loaded.model, "some-model");
+ }
+
#[test]
fn an_outfit_this_build_does_not_know_is_kept_as_written() {
// A newer build may add outfits: the island shows "auto" for it, but
@@ -769,6 +795,7 @@ mod tests {
"customUrl",
"shortcuts",
"mochiOutfit",
+ "pillColors",
"language",
"desktopMochi",
]
diff --git a/windows/src/core/pill-colors.ts b/windows/src/core/pill-colors.ts
new file mode 100644
index 00000000..e6b990b4
--- /dev/null
+++ b/windows/src/core/pill-colors.ts
@@ -0,0 +1,58 @@
+// A colour of your own for each pill's Mochi — the pure half, port of
+// NotchBuddy/Sources/CoucouKit/PillColors.swift. The catalog (./pills.ts) keeps
+// every default; the `pillColors` preference holds only what the user changed,
+// by pill ID, so an empty one paints the island exactly as the catalog says.
+
+/**
+ * What the palette offers, in the order it is shown. Every colour is one the
+ * catalog already uses, and all of them stay readable on the island's black
+ * with Mochi's dark eyes — which a free colour picker could not promise.
+ * Same list as PillColors.palette on macOS.
+ */
+export const PILL_PALETTE: readonly string[] = [
+ "#F5F6F8", "#F4505E", "#F29B38", "#FACC15", "#4ADE80",
+ "#2DD4BF", "#38BDF8", "#818CF8", "#C084FC", "#E879F9",
+];
+
+/** "#RRGGBB" in upper case, or null for anything that is not six hex digits. */
+export function normalizeHex(raw: unknown): string | null {
+ if (typeof raw !== "string") return null;
+ const m = /^#?([0-9a-fA-F]{6})$/.exec(raw.trim());
+ return m ? `#${m[1].toUpperCase()}` : null;
+}
+
+/**
+ * A stored preference → pill ID → colour. Whatever is not a colour is left
+ * out, so a hand-edited or damaged settings.json costs one pill its colour and
+ * nothing else. IDs are not checked against the catalog: a pill this build
+ * does not know keeps the colour a newer one gave it.
+ */
+export function parsePillColors(raw: unknown): Record<string, string> {
+ const out: Record<string, string> = {};
+ if (raw == null || typeof raw !== "object" || Array.isArray(raw)) return out;
+ for (const [id, value] of Object.entries(raw)) {
+ const hex = normalizeHex(value);
+ if (id && hex) out[id] = hex;
+ }
+ return out;
+}
+
+/** The colour a pill is painted with: the user's when there is one, else the catalog's. */
+export function pillColor(id: string, catalogColor: string, colors: unknown): string {
+ return parsePillColors(colors)[id] ?? catalogColor;
+}
+
+/**
+ * The preference once `hex` is picked for a pill. Picking nothing, something
+ * that is not a colour, or the pill's own catalog colour clears the entry: the
+ * preference never stores a default.
+ */
+export function withPillColor(
+ colors: unknown, id: string, hex: string | null, catalogColor: string,
+): Record<string, string> {
+ const next = parsePillColors(colors);
+ const picked = normalizeHex(hex);
+ if (picked && picked !== normalizeHex(catalogColor)) next[id] = picked;
+ else delete next[id];
+ return next;
+}
diff --git a/windows/src/core/state.ts b/windows/src/core/state.ts
index 0951ef01..b395a4e3 100644
--- a/windows/src/core/state.ts
+++ b/windows/src/core/state.ts
@@ -11,6 +11,7 @@ import type { ProviderId } from "./providers";
import type { FileDiff } from "./diff";
import type { Bindings } from "./shortcuts";
import { DEFAULT_OUTFIT, type Outfit } from "../mochi/wardrobe";
+import { pillColor } from "./pill-colors";
export type AgentSource = "claudeCode" | "n8n" | "agent";
export type PillBadge = "approval" | "finished" | "error";
@@ -79,10 +80,10 @@ export interface SearchResult {
note?: string;
}
-/** A fresh, idle task for a catalog pill. */
-function taskFor(def: PillDefinition, name = def.name): AgentTask {
+/** A fresh, idle task for a catalog pill, in the colour the user gave it if any. */
+function taskFor(def: PillDefinition, colors: unknown, name = def.name): AgentTask {
return {
- id: def.id, name, color: def.color, state: "idle", stepIndex: 0, steps: [],
+ id: def.id, name, color: pillColor(def.id, def.color, colors), state: "idle", stepIndex: 0, steps: [],
source: def.source, isIntegration: true,
};
}
@@ -131,6 +132,12 @@ export interface Settings {
* Same raw values as the Mac's "mochiOutfit"; read it through parseOutfit.
*/
mochiOutfit: string;
+ /**
+ * A colour of the user's own for a pill's Mochi, by pill ID ("#RRGGBB").
+ * Empty means the catalog's colours; read it through core/pill-colors.ts.
+ * Same key and values as the Mac's "pillColors".
+ */
+ pillColors: Record<string, string>;
/**
* Interface language: "" follows the system (when Coucou has its language,
* else English), or one of src/i18n's ten codes ("fr", "pt-BR", "zh-Hans"…).
@@ -166,6 +173,7 @@ export const DEFAULT_SETTINGS: Settings = {
customUrl: "",
shortcuts: {},
mochiOutfit: DEFAULT_OUTFIT,
+ pillColors: {},
language: "",
};
@@ -379,10 +387,15 @@ class AppState {
for (const def of availablePills(this.os)) {
const shouldLoad = def.id === d.mainPill || d.activeIntegrations.includes(def.id);
const idx = this.tasks.findIndex((t) => t.id === def.id);
- if (shouldLoad && idx < 0) this.tasks.push(taskFor(def));
+ if (shouldLoad && idx < 0) this.tasks.push(taskFor(def, this.settings.pillColors));
const busy = idx >= 0 && (this.tasks[idx].state !== "idle" || this.tasks[idx].steps.length > 0);
if (!shouldLoad && idx >= 0 && !busy) this.tasks.splice(idx, 1);
}
+ // A colour picked in Settings reaches the pills that are already up.
+ for (const t of this.tasks) {
+ const def = pillDefinition(t.id);
+ if (def) t.color = pillColor(def.id, def.color, this.settings.pillColors);
+ }
this.tasks = orderPills(this.tasks, d.mainPill);
if (!this.focusId || !this.tasks.some((t) => t.id === this.focusId)) this.focusId = d.mainPill;
this.notify();
@@ -424,7 +437,7 @@ class AppState {
if (this.tasks.some((t) => t.id === id)) return;
const def = pillDefinition(id);
this.insertAfterMain({
- id, name, color: def?.color ?? color,
+ id, name, color: def ? pillColor(def.id, def.color, this.settings.pillColors) : color,
state: "idle", stepIndex: 0, steps: [],
source: "agent", isIntegration: false,
});
@@ -440,7 +453,7 @@ class AppState {
if (!t) {
const def = pillDefinition(id);
if (!def) return null;
- t = taskFor(def, name);
+ t = taskFor(def, this.settings.pillColors, name);
this.insertAfterMain(t);
}
t.name = name;
diff --git a/windows/src/i18n/strings.json b/windows/src/i18n/strings.json
index f32fb6aa..4fc1a341 100644
--- a/windows/src/i18n/strings.json
+++ b/windows/src/i18n/strings.json
@@ -563,6 +563,17 @@
"ru": "Хуки Codex",
"id": "Hooks Codex"
},
+ "Color": {
+ "zh-Hans": "颜色",
+ "hi": "रंग",
+ "es": "Color",
+ "ar": "اللون",
+ "fr": "Couleur",
+ "bn": "রং",
+ "pt-BR": "Cor",
+ "ru": "Цвет",
+ "id": "Warna"
+ },
"Coming soon": {
"zh-Hans": "即将推出",
"hi": "जल्द आ रहा है",
@@ -695,6 +706,17 @@
"ru": "Свой…",
"id": "Kustom…"
},
+ "Default": {
+ "zh-Hans": "默认",
+ "hi": "डिफ़ॉल्ट",
+ "es": "Predeterminado",
+ "ar": "الافتراضي",
+ "fr": "Par défaut",
+ "bn": "ডিফল্ট",
+ "pt-BR": "Padrão",
+ "ru": "По умолчанию",
+ "id": "Bawaan"
+ },
"Demo": {
"zh-Hans": "演示",
"hi": "डेमो",
diff --git a/windows/src/settings/colors.ts b/windows/src/settings/colors.ts
new file mode 100644
index 00000000..c6b52a41
--- /dev/null
+++ b/windows/src/settings/colors.ts
@@ -0,0 +1,101 @@
+// The colour dot at the start of a pill's row, and the palette it opens — the
+// Mac's dot in Settings → Active pills does the same. The dot looks exactly as
+// it always did; what is new is that it can be clicked.
+
+import { PILL_PALETTE, pillColor, withPillColor } from "../core/pill-colors";
+import { h } from "../views/dom";
+import { t } from "../i18n/i18n";
+
+/** The palette on screen, if any: there is never more than one. */
+let closeOpen: (() => void) | null = null;
+
+/**
+ * `colors` reads the preference as it is now, `pick` is given the next one.
+ * `size` is the dot's own inline style, as each row had it.
+ */
+export function colorDot(
+ def: { id: string; name: string; color: string },
+ size: string,
+ colors: () => unknown,
+ pick: (next: Record<string, string>) => void,
+): HTMLElement {
+ const current = () => pillColor(def.id, def.color, colors());
+ const dot = h("i", {
+ class: "dot color-dot",
+ role: "button",
+ tabindex: "0",
+ style: `background:${current()};${size}`,
+ title: t("Color"),
+ "aria-label": `${def.name} · ${t("Color")}`,
+ "aria-haspopup": "true",
+ });
+
+ const open = () => {
+ closeOpen?.();
+ const palette = h("div", { class: "palette", role: "group", "aria-label": t("Color") });
+
+ const close = () => {
+ palette.remove();
+ document.removeEventListener("mousedown", outside, true);
+ document.removeEventListener("keydown", onKey, true);
+ window.removeEventListener("resize", close);
+ closeOpen = null;
+ };
+ const outside = (e: Event) => {
+ const at = e.target as Node;
+ if (!palette.contains(at) && at !== dot) close();
+ };
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key !== "Escape") return;
+ close();
+ dot.focus();
+ };
+ const choose = (hex: string | null) => {
+ pick(withPillColor(colors(), def.id, hex, def.color));
+ dot.style.background = current();
+ close();
+ dot.focus();
+ };
+
+ const now = current();
+ for (const hex of PILL_PALETTE) {
+ const swatch = h("button", {
+ class: hex === now ? "swatch on" : "swatch",
+ style: `background:${hex}`,
+ title: hex,
+ "aria-label": hex,
+ "aria-pressed": hex === now,
+ });
+ swatch.addEventListener("click", () => choose(hex));
+ palette.append(swatch);
+ }
+ // Back to the catalog's colour: only offered once it has been changed.
+ if (now !== pillColor(def.id, def.color, null)) {
+ const reset = h("button", { class: "reset", text: t("Default") });
+ reset.addEventListener("click", () => choose(null));
+ palette.append(reset);
+ }
+
+ document.body.append(palette);
+ // Under the dot, kept inside the window whichever way the text runs.
+ const at = dot.getBoundingClientRect();
+ const left = Math.max(8, Math.min(at.left - 10, window.innerWidth - palette.offsetWidth - 8));
+ palette.style.left = `${left}px`;
+ palette.style.top = `${at.bottom + 8}px`;
+
+ document.addEventListener("mousedown", outside, true);
+ document.addEventListener("keydown", onKey, true);
+ window.addEventListener("resize", close);
+ closeOpen = close;
+ (palette.querySelector<HTMLElement>(".swatch.on") ?? palette.querySelector<HTMLElement>(".swatch"))?.focus();
+ };
+
+ dot.addEventListener("click", () => (closeOpen ? closeOpen() : open()));
+ dot.addEventListener("keydown", (e) => {
+ const key = (e as KeyboardEvent).key;
+ if (key !== "Enter" && key !== " ") return;
+ e.preventDefault();
+ open();
+ });
+ return dot;
+}
diff --git a/windows/src/settings/main.ts b/windows/src/settings/main.ts
index 4282bac4..8571126a 100644
--- a/windows/src/settings/main.ts
+++ b/windows/src/settings/main.ts
@@ -16,6 +16,7 @@ import {
} from "../core/pills";
import { h, clear } from "../views/dom";
import { agentsSection } from "./agents";
+import { colorDot } from "./colors";
import { renderDiff, statusDot } from "./parts";
import {
LANGUAGES, N_, isRtl, onLanguageChange, resolveLanguage, setLanguage, systemLanguages, t, tn,
@@ -35,6 +36,12 @@ async function save() {
await Bridge.saveSettings(settings);
}
+/** A colour was picked for a pill's Mochi (see ./colors.ts): the island follows. */
+function pickColor(next: Record<string, string>) {
+ settings.pillColors = next;
+ void save();
+}
+
// ── Reusable bits ─────────────────────────────────────────────────────────────
function toggle(on: boolean, onChange: (v: boolean) => void): HTMLElement {
@@ -425,7 +432,7 @@ function activePillsSection(connected: Record<string, boolean>): HTMLElement {
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` }),
+ colorDot(def, "width:10px;height:10px", () => settings.pillColors, pickColor),
h("span", { class: "name", text: def.name }),
);
if (isMain) {
@@ -839,7 +846,7 @@ function integrationsSection(present: Record<string, boolean>): HTMLElement {
h("div", { style: "display:flex;gap:12px;align-items:flex-start" },
h("div", { style: "display:flex;align-items:center;gap:8px;min-width:132px;padding-top:4px" },
sw,
- h("i", { class: "dot", style: `background:${def.color}` }),
+ colorDot(def, "", () => settings.pillColors, pickColor),
h("span", { style: "font-size:12.5px", text: def.name }),
),
rows,
diff --git a/windows/src/settings/settings.css b/windows/src/settings/settings.css
index 155113b7..da46bfa8 100644
--- a/windows/src/settings/settings.css
+++ b/windows/src/settings/settings.css
@@ -295,6 +295,46 @@ select option {
font-size: 12.5px;
}
+/* The dot of a pill's row opens the colour palette (see ./colors.ts). The dot
+ itself is unchanged. */
+.color-dot {
+ cursor: pointer;
+}
+
+.color-dot:focus-visible {
+ outline: 2px solid rgba(255, 255, 255, 0.5);
+ outline-offset: 2px;
+}
+
+.palette {
+ position: fixed;
+ z-index: 10;
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ padding: 8px 10px;
+ background: var(--card);
+ border: 1px solid var(--hairline);
+ border-radius: 12px;
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
+}
+
+.palette .swatch {
+ width: 18px;
+ height: 18px;
+ padding: 0;
+ border-radius: 50%;
+}
+
+.palette .swatch.on {
+ box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px var(--ink);
+}
+
+.palette .reset {
+ padding: 3px 10px;
+ font-size: 11.5px;
+}
+
.pill-row.full .name {
color: var(--dim-2);
}
diff --git a/windows/src/views/views.ts b/windows/src/views/views.ts
index ff429eaf..7570c546 100644
--- a/windows/src/views/views.ts
+++ b/windows/src/views/views.ts
@@ -327,7 +327,7 @@ function buildOverview(actions: ViewActions): ViewHost {
} else if (task) {
const info = State.integrations[task.id];
const key = [
- language(), task.id, detailOpen, task.state, task.steps.join("|"),
+ language(), task.id, task.color, detailOpen, task.state, task.steps.join("|"),
info?.loaded, info?.error, info?.configured,
JSON.stringify(info?.data ?? {}),
].join("~");
@@ -342,7 +342,7 @@ function buildOverview(actions: ViewActions): ViewHost {
jump.style.display = detailOpen || mode === "plan" || mode === "diff" ? "none" : "";
const others = State.otherTasks.slice(0, 4);
- const pillKey = others.map((t) => `${t.id}:${t.pillBadge ?? ""}`).join("|");
+ const pillKey = others.map((t) => `${t.id}:${t.color}:${t.pillBadge ?? ""}`).join("|");
if (pillKey !== pillIds) {
pillIds = pillKey;
clear(pills);
diff --git a/windows/tests/pill-colors.test.mjs b/windows/tests/pill-colors.test.mjs
new file mode 100644
index 00000000..8d918bb4
--- /dev/null
+++ b/windows/tests/pill-colors.test.mjs
@@ -0,0 +1,115 @@
+// A colour of the user's own for each pill's Mochi (src/core/pill-colors.ts),
+// and how the app state paints with it. Mirrors tests/PillColorsTests.swift so
+// every platform reads the same preference the same way.
+
+import { beforeEach, test } from "node:test";
+import assert from "node:assert/strict";
+import { PILL_PALETTE, normalizeHex, parsePillColors, pillColor, withPillColor } from "../src/core/pill-colors.ts";
+import { PILL_CATALOG, pillDefinition } from "../src/core/pills.ts";
+import { DEFAULT_SETTINGS, State } from "../src/core/state.ts";
+
+const VS_CODE = pillDefinition("integration_claude").color;
+const TEAL = "#2DD4BF";
+
+// ── The pure half ─────────────────────────────────────────────────────────────
+
+test("a colour is six hex digits, written #RRGGBB in upper case", () => {
+ assert.equal(normalizeHex("#2dd4bf"), TEAL);
+ assert.equal(normalizeHex("2DD4BF"), TEAL);
+ assert.equal(normalizeHex(" #2DD4BF "), TEAL);
+ for (const bad of ["", "#2DD4B", "#2DD4BFF", "#GGGGGG", "teal", "rgb(1,2,3)", null, undefined, 0x2dd4bf, {}]) {
+ assert.equal(normalizeHex(bad), null, String(bad));
+ }
+});
+
+test("the palette is ten different colours the catalog already uses", () => {
+ const catalog = new Set(PILL_CATALOG.map((p) => p.color));
+ assert.equal(PILL_PALETTE.length, 10);
+ assert.equal(new Set(PILL_PALETTE).size, 10);
+ for (const hex of PILL_PALETTE) {
+ assert.equal(normalizeHex(hex), hex, hex);
+ assert.ok(catalog.has(hex), `${hex} is not a catalog colour`);
+ }
+});
+
+test("a stored preference keeps what is a colour and drops the rest", () => {
+ assert.deepEqual(
+ parsePillColors({ integration_claude: "#2dd4bf", agent_cursor: "blue", "": "#FFFFFF", agent_new: "#abcdef", n: 3 }),
+ { integration_claude: TEAL, agent_new: "#ABCDEF" },
+ );
+ for (const junk of [null, undefined, "x", 3, ["#2DD4BF"]]) assert.deepEqual(parsePillColors(junk), {});
+});
+
+test("a pill wears the user's colour when there is one, else the catalog's", () => {
+ assert.equal(pillColor("integration_claude", VS_CODE, {}), VS_CODE);
+ assert.equal(pillColor("integration_claude", VS_CODE, null), VS_CODE);
+ assert.equal(pillColor("integration_claude", VS_CODE, { integration_claude: "#2dd4bf" }), TEAL);
+ assert.equal(pillColor("integration_claude", VS_CODE, { integration_claude: "nope" }), VS_CODE);
+ assert.equal(pillColor("agent_cursor", "#C0C4CC", { integration_claude: TEAL }), "#C0C4CC");
+});
+
+test("picking a colour stores it; the default, nothing or junk clears it", () => {
+ const before = { agent_cursor: "#F4505E" };
+ const picked = withPillColor(before, "integration_claude", "#2dd4bf", VS_CODE);
+ assert.deepEqual(picked, { agent_cursor: "#F4505E", integration_claude: TEAL });
+ assert.deepEqual(before, { agent_cursor: "#F4505E" }, "the preference given is not changed");
+
+ assert.deepEqual(withPillColor(picked, "integration_claude", null, VS_CODE), before);
+ assert.deepEqual(withPillColor(picked, "integration_claude", VS_CODE.toLowerCase(), VS_CODE), before);
+ assert.deepEqual(withPillColor(picked, "integration_claude", "teal", VS_CODE), before);
+});
+
+// ── The app state ─────────────────────────────────────────────────────────────
+
+beforeEach(() => {
+ State.tasks = [];
+ State.focusId = null;
+ State.os = "windows";
+ State.settings = { ...DEFAULT_SETTINGS };
+});
+
+const colorOf = (id) => State.tasks.find((t) => t.id === id)?.color;
+
+test("with no preference every pill is painted as the catalog says", () => {
+ assert.deepEqual(DEFAULT_SETTINGS.pillColors, {});
+ State.loadIntegrationTasks();
+ for (const task of State.tasks) assert.equal(task.color, pillDefinition(task.id).color, task.id);
+});
+
+test("a pill is created in the colour the user gave it", () => {
+ State.settings.pillColors = { integration_claude: TEAL };
+ State.loadIntegrationTasks();
+ assert.equal(colorOf("integration_claude"), TEAL);
+ assert.equal(colorOf("integration_github"), pillDefinition("integration_github").color);
+});
+
+test("a colour picked later reaches the pills already on the island, and back", () => {
+ State.loadIntegrationTasks();
+ assert.equal(colorOf("integration_claude"), VS_CODE);
+
+ State.settings = { ...State.settings, pillColors: { integration_claude: TEAL } };
+ State.loadIntegrationTasks();
+ assert.equal(colorOf("integration_claude"), TEAL);
+
+ State.settings = { ...State.settings, pillColors: {} };
+ State.loadIntegrationTasks();
+ assert.equal(colorOf("integration_claude"), VS_CODE);
+});
+
+test("pills made for a session wear the colour too", () => {
+ State.settings.pillColors = { agent_gemini: TEAL, agent_cursor: "#F4505E" };
+ State.loadIntegrationTasks();
+ State.upsertExternalAgent("agent_gemini", "Gemini CLI", "#000000");
+ assert.equal(colorOf("agent_gemini"), TEAL);
+ State.upsertWorkspacePill("agent_cursor", "my-project", "");
+ assert.equal(colorOf("agent_cursor"), "#F4505E");
+});
+
+test("an agent the catalog does not know keeps the colour it came with", () => {
+ State.settings.pillColors = { agent_homemade: TEAL };
+ State.loadIntegrationTasks();
+ State.upsertExternalAgent("agent_homemade", "Homemade", "#60A5FA");
+ assert.equal(colorOf("agent_homemade"), "#60A5FA");
+ State.loadIntegrationTasks();
+ assert.equal(colorOf("agent_homemade"), "#60A5FA");
+});