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.

Mac & iPhone: a colour of your own for each Mochi

Shakib Bin Kabir0018e9736a50
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7ad724d2..2e8478ca 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -60,6 +60,9 @@ jobs:
- name: Wardrobe tests
run: bash scripts/test-wardrobe.sh
+ - name: Pill colour tests
+ run: bash scripts/test-pill-colors.sh
+
- name: Claude settings file tests
run: bash scripts/test-claude-settings.sh
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swift
index 128e3a61..975f7817 100644
--- a/NotchBuddy/Sources/App/AppState.swift
+++ b/NotchBuddy/Sources/App/AppState.swift
@@ -73,6 +73,29 @@ final class AppState: ObservableObject {
@Published var mochiOutfitSelection: Outfit = .auto {
didSet { Outfit.stored = mochiOutfitSelection }
}
+ // A colour of the user's own for each pill's Mochi (pill id → "#RRGGBB") — persisted.
+ // Empty means the catalog's colours. PillDefinition.color reads the stored value, so
+ // what is built from the catalog follows on its own; the tasks already on the island
+ // hold a copy of their colour and are repainted here.
+ @Published var pillColors: [String: String] = [:] {
+ didSet {
+ PillColors.stored = pillColors
+ var repainted = tasks
+ var changed = false
+ for i in repainted.indices {
+ guard let def = PillCatalog.definition(for: repainted[i].id),
+ repainted[i].color != def.color else { continue }
+ repainted[i].color = def.color
+ changed = true
+ }
+ if changed { tasks = repainted }
+ }
+ }
+ /// Picks a colour for a pill's Mochi; nil, or the pill's own catalog colour, goes back to the default.
+ func setPillColor(_ id: String, _ hex: String?) {
+ guard let def = PillCatalog.definition(for: id) else { return }
+ pillColors = PillColors.picking(hex, for: id, catalogColor: def.defaultColor, in: pillColors)
+ }
// Transient: outfit preview while hovering in wardrobe (overrides resolvedOutfit in BotCanvasView)
var wardrobePreviewOutfit: Outfit? = nil
// Per-day seasonal cache — avoids recomputing Easter and date math on every frame
@@ -447,6 +470,7 @@ final class AppState: ObservableObject {
if let v = ud.object(forKey: "soundEnabled") as? Bool { soundEnabled = v }
if let v = ud.object(forKey: "soundVolume") as? Double { soundVolume = v }
mochiOutfitSelection = Outfit.stored
+ pillColors = PillColors.stored
if let v = ud.string(forKey: "claudeModel"),
!v.trimmingCharacters(in: .whitespaces).isEmpty { claudeModel = v }
if let v = ud.string(forKey: "chatProvider"), let p = ChatProvider(rawValue: v) { chatProvider = p }
diff --git a/NotchBuddy/Sources/App/BotCanvasView.swift b/NotchBuddy/Sources/App/BotCanvasView.swift
index 7f274a5c..0cfb4a02 100644
--- a/NotchBuddy/Sources/App/BotCanvasView.swift
+++ b/NotchBuddy/Sources/App/BotCanvasView.swift
@@ -224,6 +224,11 @@ struct MiniBotCanvasView: View {
.onChange(of: task.state) { _, newState in
engine.setState(newState)
}
+ // The colour is set once, when the engine is made: a colour picked in
+ // Settings has to reach a mini Mochi that is already on screen.
+ .onChange(of: task.color) { _, newColor in
+ engine.bodyColor = cgColorFromHex(newColor)
+ }
.onAppear {
engine.setState(task.state, force: true)
if let emote = task.emote {
diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swift
index 00996739..cfa5b8a2 100644
--- a/NotchBuddy/Sources/App/SettingsView.swift
+++ b/NotchBuddy/Sources/App/SettingsView.swift
@@ -129,6 +129,8 @@ struct SettingsView: View {
// Sidebar selection persisted across sessions
@AppStorage("settingsSection") private var selectedSection: String = "general"
+ // Active pills: the pill whose colour palette is open, if any
+ @State private var colorPalettePill: String? = nil
#if PHONE_LINK
@AppStorage("iPhoneSyncEnabled") private var iPhoneSyncEnabled = false
@AppStorage("iPhoneLiveActivityEnabled") private var iPhoneLiveActivityEnabled = false
@@ -1783,9 +1785,31 @@ struct SettingsView: View {
return nil
}()
HStack(spacing: 8) {
- Circle()
- .fill(Color(hex: def.color))
- .frame(width: 10, height: 10)
+ // The dot is the row's colour control: it looks as it always did,
+ // and a click opens the palette.
+ Button {
+ colorPalettePill = def.id
+ } label: {
+ Circle()
+ .fill(Color(hex: def.color))
+ .frame(width: 10, height: 10)
+ }
+ .buttonStyle(.plain)
+ .help(String(localized: "Color"))
+ .accessibilityLabel(Text(def.name + " · " + String(localized: "Color")))
+ .popover(isPresented: Binding(
+ get: { colorPalettePill == def.id },
+ set: { open in if !open && colorPalettePill == def.id { colorPalettePill = nil } }
+ ), arrowEdge: .bottom) {
+ PillColorPalette(
+ current: def.color,
+ isCustom: state.pillColors[def.id] != nil,
+ pick: { hex in
+ state.setPillColor(def.id, hex)
+ colorPalettePill = nil
+ }
+ )
+ }
Text(def.name)
.font(.system(size: 12))
.foregroundColor(atMax ? .secondary : .primary)
@@ -1811,6 +1835,48 @@ struct SettingsView: View {
}
}
+// MARK: - Pill colour palette (Active pills, opened from a row's dot)
+
+private struct PillColorPalette: View {
+ /// The colour the pill is painted with now.
+ let current: String
+ /// The user picked it: "Default" is offered, to go back to the catalog's.
+ let isCustom: Bool
+ /// nil = back to the catalog's colour.
+ let pick: (String?) -> Void
+
+ var body: some View {
+ let now = PillColors.normalized(current)
+ HStack(spacing: 7) {
+ ForEach(PillColors.palette, id: \.self) { hex in
+ Button {
+ pick(hex)
+ } label: {
+ Circle()
+ .fill(Color(hex: hex))
+ .frame(width: 18, height: 18)
+ .overlay(
+ Circle()
+ .stroke(Color.primary, lineWidth: 1.5)
+ .padding(-3)
+ .opacity(hex == now ? 1 : 0)
+ )
+ }
+ .buttonStyle(.plain)
+ .accessibilityLabel(Text(hex))
+ }
+ if isCustom {
+ Button(String(localized: "Default")) {
+ pick(nil)
+ }
+ .controlSize(.small)
+ }
+ }
+ .padding(.horizontal, 12)
+ .padding(.vertical, 10)
+ }
+}
+
// MARK: - Sidebar background (NSVisualEffectView .sidebar)
struct SidebarBackground: NSViewRepresentable {
diff --git a/NotchBuddy/Sources/CoucouKit/PillCatalog.swift b/NotchBuddy/Sources/CoucouKit/PillCatalog.swift
index 1cacd739..2880700d 100644
--- a/NotchBuddy/Sources/CoucouKit/PillCatalog.swift
+++ b/NotchBuddy/Sources/CoucouKit/PillCatalog.swift
@@ -23,7 +23,8 @@ enum PillCategory: String, CaseIterable {
struct PillDefinition {
let id: String
let name: String
- let color: String
+ /// The catalog's colour for this pill, whatever the user picked.
+ let defaultColor: String
let category: PillCategory
/// Label shown next to the task name in the idle card header.
let subtitle: String
@@ -31,6 +32,24 @@ struct PillDefinition {
var comingSoon: Bool = false
var githubOnly: Bool = false
+ /// The colour the pill is painted with: the user's own if they picked one
+ /// (Settings → Active pills), else the catalog's.
+ var color: String {
+ PillColors.color(for: id, catalogColor: defaultColor, in: PillColors.stored)
+ }
+
+ init(id: String, name: String, color: String, category: PillCategory, subtitle: String,
+ source: AgentSource, comingSoon: Bool = false, githubOnly: Bool = false) {
+ self.id = id
+ self.name = name
+ self.defaultColor = color
+ self.category = category
+ self.subtitle = subtitle
+ self.source = source
+ self.comingSoon = comingSoon
+ self.githubOnly = githubOnly
+ }
+
/// Label shown in the active-session card header (workspace/agent pills only).
var sessionSubtitle: String {
switch id {
diff --git a/NotchBuddy/Sources/CoucouKit/PillColors.swift b/NotchBuddy/Sources/CoucouKit/PillColors.swift
new file mode 100644
index 00000000..b2b1e96d
--- /dev/null
+++ b/NotchBuddy/Sources/CoucouKit/PillColors.swift
@@ -0,0 +1,72 @@
+import Foundation
+
+/// A colour of the user's own for each pill's Mochi.
+///
+/// `PillCatalog` keeps every default. This holds only what the user changed, by
+/// pill ID, so an empty preference paints the island exactly as the catalog
+/// says. Same key and values on Windows and Linux (`pillColors` in
+/// settings.json, read by windows/src/core/pill-colors.ts).
+enum PillColors {
+
+ /// 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.
+ static let palette: [String] = [
+ "#F5F6F8", "#F4505E", "#F29B38", "#FACC15", "#4ADE80",
+ "#2DD4BF", "#38BDF8", "#818CF8", "#C084FC", "#E879F9",
+ ]
+
+ /// "#RRGGBB" in upper case, or nil for anything that is not six hex digits.
+ static func normalized(_ raw: String?) -> String? {
+ guard let raw else { return nil }
+ var digits = raw.trimmingCharacters(in: .whitespacesAndNewlines)
+ if digits.hasPrefix("#") { digits.removeFirst() }
+ guard digits.count == 6, digits.allSatisfy({ $0.isASCII && $0.isHexDigit }) else { return nil }
+ return "#" + digits.uppercased()
+ }
+
+ /// A stored preference → pill ID → colour. Whatever is not a colour is left
+ /// out, so a damaged entry 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.
+ static func parsed(_ raw: Any?) -> [String: String] {
+ guard let entries = raw as? [String: Any] else { return [:] }
+ var colors: [String: String] = [:]
+ for (id, value) in entries {
+ guard !id.isEmpty, let hex = normalized(value as? String) else { continue }
+ colors[id] = hex
+ }
+ return colors
+ }
+
+ /// The colour a pill is painted with: the user's when there is one, else the catalog's.
+ static func color(for id: String, catalogColor: String, in colors: [String: String]) -> String {
+ normalized(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.
+ static func picking(_ hex: String?, for id: String, catalogColor: String,
+ in colors: [String: String]) -> [String: String] {
+ var next = parsed(colors)
+ if let picked = normalized(hex), picked != normalized(catalogColor) {
+ next[id] = picked
+ } else {
+ next.removeValue(forKey: id)
+ }
+ return next
+ }
+
+ // UserDefaults key "pillColors"; missing or unusable → no colour chosen.
+ static var stored: [String: String] {
+ get { parsed(UserDefaults.standard.dictionary(forKey: "pillColors")) }
+ set {
+ if newValue.isEmpty {
+ UserDefaults.standard.removeObject(forKey: "pillColors")
+ } else {
+ UserDefaults.standard.set(newValue, forKey: "pillColors")
+ }
+ }
+ }
+}
diff --git a/NotchBuddy/Sources/Phone/SessionDetailView.swift b/NotchBuddy/Sources/Phone/SessionDetailView.swift
index bb1fcd45..913ad21e 100644
--- a/NotchBuddy/Sources/Phone/SessionDetailView.swift
+++ b/NotchBuddy/Sources/Phone/SessionDetailView.swift
@@ -68,7 +68,10 @@ struct SessionDetailView: View {
ZStack {
Color.black
if let session {
- AgentBackdrop(hex: PillCatalog.definition(for: session.id)?.color ?? session.color)
+ // The Mac sends the colour it paints with: the user's own, if they picked one.
+ AgentBackdrop(hex: session.color.isEmpty
+ ? PillCatalog.definition(for: session.id)?.color ?? "#C0C4CC"
+ : session.color)
.frame(height: 360)
.mask(LinearGradient(colors: [.black, .black.opacity(0.5), .clear],
startPoint: .top, endPoint: .bottom))
diff --git a/scripts/test-pill-colors.sh b/scripts/test-pill-colors.sh
new file mode 100755
index 00000000..a0aa9ab3
--- /dev/null
+++ b/scripts/test-pill-colors.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+set -euo pipefail
+cd "$(dirname "$0")/.."
+TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/coucou-pill-colors.XXXXXX")"
+trap 'rm -rf "$TEST_DIR"' EXIT
+swiftc NotchBuddy/Sources/CoucouKit/PillColors.swift \
+ tests/PillColorsTests.swift -o "$TEST_DIR/pill-colors-tests"
+"$TEST_DIR/pill-colors-tests"
diff --git a/tests/PillColorsTests.swift b/tests/PillColorsTests.swift
new file mode 100644
index 00000000..6787d66c
--- /dev/null
+++ b/tests/PillColorsTests.swift
@@ -0,0 +1,91 @@
+import Foundation
+
+// A colour of the user's own for each pill's Mochi (CoucouKit/PillColors.swift).
+// Mirrors windows/tests/pill-colors.test.mjs so every platform reads the same
+// preference the same way.
+
+@main
+enum PillColorsTests {
+
+ static var failures = 0
+
+ static func check(_ label: String, _ got: Bool) {
+ if got { print(" ✓ \(label)") }
+ else { print(" ✗ \(label)"); failures += 1 }
+ }
+
+ static let vsCode = "#F5F6F8"
+ static let teal = "#2DD4BF"
+
+ static func main() {
+ print("PillColors.normalized — #RRGGBB in upper case")
+ check("lower case → upper", PillColors.normalized("#2dd4bf") == teal)
+ check("no # → #", PillColors.normalized("2DD4BF") == teal)
+ check("spaces around → trimmed", PillColors.normalized(" #2DD4BF ") == teal)
+ for bad in ["", "#2DD4B", "#2DD4BFF", "#GGGGGG", "teal", "rgb(1,2,3)", "#2DD4BF"] {
+ check("'\(bad)' → nil", PillColors.normalized(bad) == nil)
+ }
+ check("nil → nil", PillColors.normalized(nil) == nil)
+
+ print("PillColors.palette — the ten colours Windows and Linux offer too")
+ check("same list as PILL_PALETTE", PillColors.palette == [
+ "#F5F6F8", "#F4505E", "#F29B38", "#FACC15", "#4ADE80",
+ "#2DD4BF", "#38BDF8", "#818CF8", "#C084FC", "#E879F9",
+ ])
+ check("all different", Set(PillColors.palette).count == PillColors.palette.count)
+ check("all written #RRGGBB", PillColors.palette.allSatisfy { PillColors.normalized($0) == $0 })
+
+ print("PillColors.parsed — keeps what is a colour, drops the rest")
+ let mixed: [String: Any] = [
+ "integration_claude": "#2dd4bf", "agent_cursor": "blue", "": "#FFFFFF",
+ "agent_new": "#abcdef", "n": 3,
+ ]
+ check("colours kept, junk dropped",
+ PillColors.parsed(mixed) == ["integration_claude": teal, "agent_new": "#ABCDEF"])
+ check("nil → empty", PillColors.parsed(nil).isEmpty)
+ check("a string → empty", PillColors.parsed("x").isEmpty)
+ check("an array → empty", PillColors.parsed(["#2DD4BF"]).isEmpty)
+
+ print("PillColors.color — the user's colour, else the catalog's")
+ check("no preference → catalog",
+ PillColors.color(for: "integration_claude", catalogColor: vsCode, in: [:]) == vsCode)
+ check("picked → picked",
+ PillColors.color(for: "integration_claude", catalogColor: vsCode,
+ in: ["integration_claude": "#2dd4bf"]) == teal)
+ check("not a colour → catalog",
+ PillColors.color(for: "integration_claude", catalogColor: vsCode,
+ in: ["integration_claude": "nope"]) == vsCode)
+ check("another pill's colour → catalog",
+ PillColors.color(for: "agent_cursor", catalogColor: "#C0C4CC",
+ in: ["integration_claude": teal]) == "#C0C4CC")
+
+ print("PillColors.picking — stores a colour; the default, nothing or junk clears it")
+ let before = ["agent_cursor": "#F4505E"]
+ let picked = PillColors.picking("#2dd4bf", for: "integration_claude", catalogColor: vsCode, in: before)
+ check("picked is stored",
+ picked == ["agent_cursor": "#F4505E", "integration_claude": teal])
+ check("nil clears",
+ PillColors.picking(nil, for: "integration_claude", catalogColor: vsCode, in: picked) == before)
+ check("the catalog colour clears",
+ PillColors.picking("#f5f6f8", for: "integration_claude", catalogColor: vsCode, in: picked) == before)
+ check("junk clears",
+ PillColors.picking("teal", for: "integration_claude", catalogColor: vsCode, in: picked) == before)
+
+ print("PillColors.stored — UserDefaults key pillColors")
+ UserDefaults.standard.removeObject(forKey: "pillColors")
+ check("missing → empty", PillColors.stored.isEmpty)
+ PillColors.stored = ["integration_claude": teal]
+ check("round trip", PillColors.stored == ["integration_claude": teal])
+ check("stored under pillColors",
+ (UserDefaults.standard.dictionary(forKey: "pillColors") as? [String: String]) == ["integration_claude": teal])
+ UserDefaults.standard.set("not a dictionary", forKey: "pillColors")
+ check("unusable → empty", PillColors.stored.isEmpty)
+ UserDefaults.standard.set(["integration_claude": "nope", "agent_cursor": "#f4505e"], forKey: "pillColors")
+ check("damaged entry costs only itself", PillColors.stored == ["agent_cursor": "#F4505E"])
+ PillColors.stored = [:]
+ check("empty removes the key", UserDefaults.standard.object(forKey: "pillColors") == nil)
+
+ if failures == 0 { print("\nAll tests passed.") }
+ else { print("\n\(failures) test(s) FAILED."); exit(1) }
+ }
+}
diff --git a/windows/tests/pill-colors.test.mjs b/windows/tests/pill-colors.test.mjs
index 8d918bb4..c2288878 100644
--- a/windows/tests/pill-colors.test.mjs
+++ b/windows/tests/pill-colors.test.mjs
@@ -23,8 +23,12 @@ test("a colour is six hex digits, written #RRGGBB in upper case", () => {
});
test("the palette is ten different colours the catalog already uses", () => {
+ // The same list as PillColors.palette on macOS (tests/PillColorsTests.swift).
+ assert.deepEqual(PILL_PALETTE, [
+ "#F5F6F8", "#F4505E", "#F29B38", "#FACC15", "#4ADE80",
+ "#2DD4BF", "#38BDF8", "#818CF8", "#C084FC", "#E879F9",
+ ]);
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);