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.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Choose your main coding tool, show Cursor sessions on the Cursor pill, and fix the permission card when the island is open (#120)
Louis5332f9ee4de9
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swiftindex 3c1465c5..2ac8e1bf 100644--- a/NotchBuddy/Sources/App/AppState.swift+++ b/NotchBuddy/Sources/App/AppState.swift@@ -193,7 +193,7 @@ final class AppState: ObservableObject {}}- // Active integration pills (VS Code excluded — always on). Max 4.+ // Active integration pills (main workspace pill excluded). Max 4.@Published var activeIntegrations: Set<String> = ["integration_resend", "integration_n8n", "integration_vercel", "integration_github"] {didSet {if let data = try? JSONEncoder().encode(Array(activeIntegrations)) {@@ -267,9 +267,7 @@ final class AppState: ObservableObject {if let d = ud.data(forKey: "activeIntegrations"),let a = try? JSONDecoder().decode([String].self, from: d) { activeIntegrations = Set(a) }if let v = ud.string(forKey: "mainPill"), !v.isEmpty,- v == "integration_claude" ||- (PillCatalog.available.contains(where: { $0.id == v && $0.category == .workspace })- && activeIntegrations.contains(v)) {+ PillCatalog.available.contains(where: { $0.id == v && $0.category == .workspace && !$0.comingSoon }) {mainPillId = v}@@ -301,9 +299,9 @@ final class AppState: ObservableObject {}func removeTask(id: String) {- // integration_claude: ALWAYS reset, never remove (Claude Code sessions pass through it)- // mainPillId: also always reset (the active workspace pill)- let isProtected = id == "integration_claude" || id == mainPillId+ // mainPillId: always reset, never remove (the active workspace tool)+ // activeIntegrations: also reset (user declared it active, keep it as idle)+ let isProtected = id == mainPillIdlet isActiveDecl = PillCatalog.definition(for: id) != nil && activeIntegrations.contains(id)if isProtected || isActiveDecl {if let idx = tasks.firstIndex(where: { $0.id == id }) {@@ -355,25 +353,22 @@ final class AppState: ObservableObject {// Sanitize: remove saved IDs not in cataloglet catalogIds = Set(catalog.map { $0.id })activeIntegrations = activeIntegrations.filter { catalogIds.contains($0) }- // Validate mainPillId: must be integration_claude or a checked workspace pill- if mainPillId != "integration_claude",- !(PillCatalog.available.contains(where: { $0.id == mainPillId && $0.category == .workspace })- && activeIntegrations.contains(mainPillId)) {- mainPillId = "integration_claude"+ // Validate mainPillId: must be a non-comingSoon workspace pill in the catalog+ if !PillCatalog.available.contains(where: { $0.id == mainPillId && $0.category == .workspace && !$0.comingSoon }) {+ mainPillId = PillCatalog.defaultMainPillId}+ // mainPillId must never be in activeIntegrations (migration + invariant)+ activeIntegrations.remove(mainPillId)for def in catalog {- // integration_claude always loads; mainPillId always loads; activeIntegrations load- let shouldLoad = def.id == "integration_claude"- || def.id == mainPillId- || activeIntegrations.contains(def.id)+ // mainPillId always loads; activeIntegrations load+ let shouldLoad = def.id == mainPillId || activeIntegrations.contains(def.id)let loaded = tasks.contains(where: { $0.id == def.id })if shouldLoad && !loaded {let task = AgentTask(id: def.id, name: def.name, color: def.color,state: .idle, steps: [], source: def.source, isIntegration: true)tasks.append(task)}- if !shouldLoad && loaded- && def.id != "integration_claude" && def.id != mainPillId {+ if !shouldLoad && loaded {tasks.removeAll { $0.id == def.id }}}@@ -383,16 +378,14 @@ final class AppState: ObservableObject {}/// Toggle a catalog pill on/off.- /// integration_claude: never toggleable.- /// mainPillId (workspace): can be unchecked — resets mainPillId to integration_claude.- /// Max 4 non-claude pills active at once.+ /// mainPillId: never toggleable (change via the Main picker first).+ /// Max 4 non-main pills active at once.func toggleIntegration(_ id: String) {- guard id != "integration_claude" else { return }+ guard id != mainPillId else { return }guard PillCatalog.available.contains(where: { $0.id == id }) else { return }if activeIntegrations.contains(id) {activeIntegrations.remove(id)tasks.removeAll { $0.id == id }- if mainPillId == id { mainPillId = "integration_claude" }if focusId == id { focusId = mainPillId }} else {guard activeIntegrations.count < 4 else { return }diff --git a/NotchBuddy/Sources/App/HookServer.swift b/NotchBuddy/Sources/App/HookServer.swiftindex e5e726cc..a8afb913 100644--- a/NotchBuddy/Sources/App/HookServer.swift+++ b/NotchBuddy/Sources/App/HookServer.swift@@ -1,6 +1,7 @@import Foundationimport Darwinimport AppKit+import SwiftUIimport CryptoKit// MARK: - HookServer@@ -40,6 +41,7 @@ final class HookServer: @unchecked Sendable {private var pendingApprovalFD: Int32 = -1 // held open while user decidesprivate var approvalFDSource: (any DispatchSourceRead)? = nil // monitors pendingApprovalFDprivate var activeSessionId: String? = nil // current Claude Code session+ private var focusBeforeApproval: String? = nil // saved focus to restore after approvalprivate init() {}@@ -60,10 +62,18 @@ final class HookServer: @unchecked Sendable {cancelApprovalFDSource()pendingApprovalFD = -1let state = AppState.shared+ let pillId = state.pendingApproval?.pillId ?? "integration_claude"state.pendingApproval = nilstate.isPinned = false- state.updateTask(id: "integration_claude", state: .working)- clearPillBadge(id: "integration_claude")+ state.updateTask(id: pillId, state: .working)+ clearPillBadge(id: pillId)+ // Restore focus to the pill that was focused before the approval card appeared.+ if let prev = focusBeforeApproval {+ focusBeforeApproval = nil+ if state.focusId == pillId, state.tasks.contains(where: { $0.id == prev }) {+ withAnimation(.spring(response: 0.5, dampingFraction: 0.72)) { state.focusId = prev }+ }+ }state.noteMessage = notestate.view = .noteDispatchQueue.main.asyncAfter(deadline: .now() + 3) {@@ -199,67 +209,86 @@ final class HookServer: @unchecked Sendable {@MainActorprivate func processEvent(name: String, payload: [String: Any]) {let state = AppState.shared- let sessionId = payload["session_id"] as? String ?? "unknown"+ let sessionId = payload["session_id"] as? String+ ?? payload["conversation_id"] as? String+ ?? "unknown"let cwd = payload["cwd"] as? String ?? ""let rawName = URL(fileURLWithPath: cwd).lastPathComponentlet projectName = aliasProjectName(rawName.isEmpty ? "Session" : rawName)// Determine which pill this event belongs to.// coucou_agent must be lowercase, digits and hyphens, ≤ 24 chars.- // Absent or invalid → Claude Code pill (integration_claude); no change in behaviour.let rawAgent = payload["coucou_agent"] as? String ?? ""let validAgent = Self.validateAgent(rawAgent)- let agentId = validAgent.map { "agent_\($0)" } ?? "integration_claude"- let isExternalAgent = validAgent != nillet termProgram = payload["term_program"] as? String ?? ""let bundleId = payload["bundle_id"] as? String ?? ""- let isVSCode = termProgram.lowercased().contains("vscode") ||- bundleId.lowercased().contains("vscode")- // External agents bypass the VS Code filter (their relay runs in any terminal).- guard isExternalAgent || isVSCode else {++ // Cursor identified solely by its stable Electron bundle ID.+ // ToDesktop builds other apps too — do not match on "todesktop" alone.+ let isCursorEditor = bundleId.lowercased() == "com.todesktop.230313mzl4w4u92"+ let isVSCodeEditor = !isCursorEditor && (+ termProgram.lowercased().contains("vscode") ||+ bundleId.lowercased().contains("vscode"))++ // Routing: coucou_agent → external pill; Cursor → agent_cursor; VS Code → integration_claude.+ let agentId: String+ let isExternalAgent: Bool+ if let agent = validAgent {+ agentId = "agent_\(agent)"+ isExternalAgent = true+ } else if isCursorEditor {+ agentId = "agent_cursor"+ isExternalAgent = false+ } else if isVSCodeEditor {+ agentId = "integration_claude"+ isExternalAgent = false+ } else {nbLog("Ignored \(name) from \(termProgram.isEmpty ? bundleId : termProgram) (\(projectName))")return}let focused = state.focusId == agentId- // While a permission request is pending on the Claude Code pill, skip events to- // preserve the .approval state and keep the card visible.- if state.pendingApproval != nil && agentId == "integration_claude" {- if let pending = state.pendingApproval {- switch name {- case "PostToolUse", "PostToolUseFailure":- // Only dismiss when this exact tool call finished — same session, tool and input.- // Other parallel tools finishing must not close the card.- if sessionId == pending.sessionId,- (payload["tool_name"] as? String ?? "") == pending.tool,- Self.approvalInputKey(payload["tool_input"] as? [String: Any] ?? [:]) == pending.inputKey {- dismissApprovalCard(note: "Handled in VS Code.")- }- case "Stop", "StopFailure", "UserPromptSubmit", "SessionEnd":- // Turn ended or session interrupted — the permission is moot.- if sessionId == pending.sessionId {- dismissApprovalCard(note: "Handled in VS Code.")- }- default: break+ // While a permission request is pending, dismiss when the resolving event arrives,+ // then continue normal processing. Only skip normal processing when unresolved.+ if let pending = state.pendingApproval, agentId == pending.pillId {+ let handledNote = pending.pillId == "agent_cursor" ? "Handled in Cursor." : "Handled in VS Code."+ var resolved = false+ switch name {+ case "PostToolUse", "PostToolUseFailure":+ // Only dismiss when this exact tool call finished — same session, tool and input.+ // Other parallel tools finishing must not close the card.+ if sessionId == pending.sessionId,+ (payload["tool_name"] as? String ?? "") == pending.tool,+ Self.approvalInputKey(payload["tool_input"] as? [String: Any] ?? [:]) == pending.inputKey {+ dismissApprovalCard(note: handledNote)+ resolved = true}+ case "Stop", "StopFailure", "UserPromptSubmit", "SessionEnd":+ // Turn ended or session interrupted — the permission is moot.+ if sessionId == pending.sessionId {+ dismissApprovalCard(note: handledNote)+ resolved = true+ }+ default: break}- return+ if !resolved { return }+ // Approval dismissed — fall through so the resolving event updates state normally.}switch name {case "SessionStart":activeSessionId = sessionId- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertTask(projectName: projectName, cwd: cwd) }+ if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd) }nbLog("SessionStart \(isExternalAgent ? agentId : projectName) (\(sessionId.prefix(8)))")if state.isPresent { expandIfNeeded(to: .overview) }SoundEngine.shared.play("work")case "UserPromptSubmit":activeSessionId = sessionId- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertTask(projectName: projectName, cwd: cwd) }+ if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd) }state.updateTask(id: agentId, state: .thinking)if let prompt = payload["prompt"] as? String, !prompt.isEmpty {appendStep(id: agentId, step: String(prompt.prefix(60)))@@ -268,7 +297,7 @@ final class HookServer: @unchecked Sendable {case "PreToolUse":activeSessionId = sessionId- if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertTask(projectName: projectName, cwd: cwd) }+ if isExternalAgent { upsertExternalAgent(id: agentId, name: validAgent!) } else { upsertWorkspaceTask(id: agentId, projectName: projectName, cwd: cwd) }state.updateTask(id: agentId, state: .working)let tool = payload["tool_name"] as? String ?? "Tool"let input = payload["tool_input"] as? [String: Any] ?? [:]@@ -309,7 +338,7 @@ final class HookServer: @unchecked Sendable {if isExternalAgent {AppState.shared.removeTask(id: agentId)} else {- state.updateTask(id: agentId, state: .idle)+ AppState.shared.updateTask(id: agentId, state: .idle)self.clearPillBadge(id: agentId)}}@@ -325,12 +354,7 @@ final class HookServer: @unchecked Sendable {case "SessionEnd":activeSessionId = nil- if isExternalAgent {- state.removeTask(id: agentId)- } else {- state.updateTask(id: agentId, state: .idle)- clearSession()- }+ state.removeTask(id: agentId)case "SubagentStart":appendStep(id: agentId, step: "+ subagent")@@ -389,8 +413,12 @@ final class HookServer: @unchecked Sendable {default: isAlert = false}if state.mode == .expanded {- // Don't hijack the approval card for other alerts- if isAlert && state.pendingApproval == nil { state.view = view }+ // Approval always wins; other alerts are blocked while a card is showing+ if view == .approval {+ state.view = view+ } else if isAlert && state.pendingApproval == nil {+ state.view = view+ }} else if isAlert {// Alerts always force-expandNotificationCenter.default.post(name: .hookExpand, object: view)@@ -406,7 +434,9 @@ final class HookServer: @unchecked Sendable {@MainActorprivate func processPermissionRequest(fd: Int32, payload: [String: Any]) {let state = AppState.shared- let sessionId = payload["session_id"] as? String ?? "unknown"+ let sessionId = payload["session_id"] as? String+ ?? payload["conversation_id"] as? String+ ?? "unknown"let cwd = payload["cwd"] as? String ?? ""let rawName = URL(fileURLWithPath: cwd).lastPathComponentlet projectName = aliasProjectName(rawName.isEmpty ? "Session" : rawName)@@ -426,9 +456,13 @@ final class HookServer: @unchecked Sendable {let termProgram = payload["term_program"] as? String ?? ""let bundleId = payload["bundle_id"] as? String ?? ""- let isVSCode = termProgram.lowercased().contains("vscode") ||- bundleId.lowercased().contains("vscode")- guard isVSCode else {+ // Cursor identified solely by its stable Electron bundle ID.+ let isCursorEditor = bundleId.lowercased() == "com.todesktop.230313mzl4w4u92"+ let isVSCodeEditor = !isCursorEditor && (+ termProgram.lowercased().contains("vscode") ||+ bundleId.lowercased().contains("vscode"))+ let pillId = isCursorEditor ? "agent_cursor" : "integration_claude"+ guard isCursorEditor || isVSCodeEditor else {Task.detached { [weak self] inself?.sendLine(fd: fd, text: #"{"permissionDecision":"ask"}"#)close(fd)@@ -440,7 +474,7 @@ final class HookServer: @unchecked Sendable {let toolInput = payload["tool_input"] as? [String: Any] ?? [:]var command = toolInput["command"] as? String ?? toollet inputKey = Self.approvalInputKey(toolInput)- nbLog("PermissionRequest \(tool)")+ nbLog("PermissionRequest \(tool) [\(pillId)]")if pendingApprovalFD >= 0 {// Displace the previous request: write "ask" then cancel its source.@@ -457,23 +491,27 @@ final class HookServer: @unchecked Sendable {pendingApprovalFD = fdactiveSessionId = sessionId- upsertTask(projectName: projectName, cwd: cwd)- state.updateTask(id: "integration_claude", state: .approval)+ upsertWorkspaceTask(id: pillId, projectName: projectName, cwd: cwd)+ state.updateTask(id: pillId, state: .approval)state.pendingApproval = ApprovalInfo(sessionId: sessionId, tool: tool,- command: command, inputKey: inputKey)+ command: command, inputKey: inputKey, pillId: pillId)state.isPinned = trueSoundEngine.shared.play("approval")- // Approval always forces the island open — user must be able to respond- state.focusId = "integration_claude"+ // Approval always forces the island open — user must be able to respond.+ // Save current focus so we can restore it when the card is dismissed.+ if focusBeforeApproval == nil { focusBeforeApproval = state.focusId }+ withAnimation(.spring(response: 0.5, dampingFraction: 0.72)) { state.focusId = pillId }expandIfNeeded(to: .approval)- // Monitor fd: if VS Code closes the connection (handled externally), dismiss the card.+ // Monitor fd: if the editor closes the connection (handled externally), dismiss the card.// The cancel handler closes the fd — never close it anywhere else.+ let capturedPillId = pillIdlet source = DispatchSource.makeReadSource(fileDescriptor: fd, queue: .main)source.setEventHandler { [weak self] inguard let self, self.pendingApprovalFD == fd else { return }- self.dismissApprovalCard(note: "Handled in VS Code.")+ let note = capturedPillId == "agent_cursor" ? "Handled in Cursor." : "Handled in VS Code."+ self.dismissApprovalCard(note: note)}source.setCancelHandler { close(fd) }source.resume()@@ -484,7 +522,8 @@ final class HookServer: @unchecked Sendable {let captured = fdDispatchQueue.main.asyncAfter(deadline: .now() + 115) { [weak self] inguard let self, self.pendingApprovalFD == captured else { return }- self.dismissApprovalCard(note: "Still waiting in VS Code.")+ let note = capturedPillId == "agent_cursor" ? "Still waiting in Cursor." : "Still waiting in VS Code."+ self.dismissApprovalCard(note: note)}}@@ -517,20 +556,45 @@ final class HookServer: @unchecked Sendable {}let state = AppState.shared+ let pillId = state.pendingApproval?.pillId ?? "integration_claude"state.pendingApproval = nilstate.isPinned = false- state.updateTask(id: "integration_claude", state: .working)- clearPillBadge(id: "integration_claude")+ state.updateTask(id: pillId, state: .working)+ clearPillBadge(id: pillId)+ // Restore focus to the pill that was focused before the approval card appeared.+ if let prev = focusBeforeApproval {+ focusBeforeApproval = nil+ if state.focusId == pillId, state.tasks.contains(where: { $0.id == prev }) {+ withAnimation(.spring(response: 0.5, dampingFraction: 0.72)) { state.focusId = prev }+ }+ }state.view = state.tasks.isEmpty ? .empty : .overview}- /// Updates integration_claude with the current session project name and cwd.+ /// Updates or transiently creates a workspace pill (VS Code or Cursor) task.+ /// If the task already exists (persistent), just updates name/cwd.+ /// If missing (transient), creates it and inserts after the main pill.@MainActor- private func upsertTask(projectName: String, cwd: String = "") {+ private func upsertWorkspaceTask(id: String, projectName: String, cwd: String = "") {let state = AppState.shared- guard let idx = state.tasks.firstIndex(where: { $0.id == "integration_claude" }) else { return }- state.tasks[idx].name = projectName- if !cwd.isEmpty { state.tasks[idx].sessionCwd = cwd }+ if let idx = state.tasks.firstIndex(where: { $0.id == id }) {+ state.tasks[idx].name = projectName+ if !cwd.isEmpty { state.tasks[idx].sessionCwd = cwd }+ return+ }+ // Transient: create and insert after the main pill+ let def = PillCatalog.definition(for: id)+ let color = def?.color ?? "#C0C4CC"+ let source = def?.source ?? .agent+ let task = AgentTask(id: id, name: projectName, color: color,+ state: .idle, steps: [], source: source, isIntegration: true)+ if let mainIdx = state.tasks.firstIndex(where: { $0.id == state.mainPillId }) {+ state.tasks.insert(task, at: mainIdx + 1)+ } else {+ state.tasks.insert(task, at: 0)+ }+ if state.focusId == nil { state.focusId = id }+ state.syncMode()}// MARK: - Badge helpers@@ -549,17 +613,6 @@ final class HookServer: @unchecked Sendable {state.tasks[idx].pillBadge = nil}- /// Resets integration_claude to idle, clears steps and project name.- @MainActor- private func clearSession() {- let state = AppState.shared- guard let idx = state.tasks.firstIndex(where: { $0.id == "integration_claude" }) else { return }- state.tasks[idx].steps = []- state.tasks[idx].stepIndex = 0- state.tasks[idx].name = "VS Code"- state.tasks[idx].pillBadge = nil- }-@MainActorprivate func appendStep(id: String, step: String) {let state = AppState.shared@@ -1233,7 +1286,7 @@ def main():payload.setdefault('term_session_id', env.get('TERM_SESSION_ID', ''))payload.setdefault('bundle_id', env.get('__CFBundleIdentifier', ''))if 'cwd' not in payload or not payload['cwd']:- paths = payload.get('workspacePaths', [])+ paths = payload.get('workspacePaths') or payload.get('workspace_roots', [])if isinstance(paths, list) and paths:payload['cwd'] = paths[0]else:@@ -1396,7 +1449,7 @@ def main():payload.setdefault('term_session_id', env.get('TERM_SESSION_ID', ''))payload.setdefault('bundle_id', env.get('__CFBundleIdentifier', ''))if 'cwd' not in payload or not payload['cwd']:- paths = payload.get('workspacePaths', [])+ paths = payload.get('workspacePaths') or payload.get('workspace_roots', [])if isinstance(paths, list) and paths:payload['cwd'] = paths[0]else:diff --git a/NotchBuddy/Sources/App/IslandTypes.swift b/NotchBuddy/Sources/App/IslandTypes.swiftindex 324b6dc3..5e506a88 100644--- a/NotchBuddy/Sources/App/IslandTypes.swift+++ b/NotchBuddy/Sources/App/IslandTypes.swift@@ -36,6 +36,8 @@ struct ApprovalInfo: Sendable {var command: String/// tool_input serialized to JSON with sortedKeys, "" if absent — used to match PostToolUse.var inputKey: String+ /// Pill that owns this approval: "integration_claude" or "agent_cursor".+ var pillId: String}// MARK: - Pill badge (shown on pill edge when non-focused task has an alert)diff --git a/NotchBuddy/Sources/App/PillCatalog.swift b/NotchBuddy/Sources/App/PillCatalog.swiftindex 6d9b1988..65284e7e 100644--- a/NotchBuddy/Sources/App/PillCatalog.swift+++ b/NotchBuddy/Sources/App/PillCatalog.swift@@ -33,7 +33,11 @@ struct PillDefinition {/// Label shown in the active-session card header (workspace/agent pills only).var sessionSubtitle: String {- id == "integration_claude" ? "Claude Code" : "Agent"+ switch id {+ case "integration_claude": return "Claude Code"+ case "agent_cursor": return "Cursor"+ default: return "Agent"+ }}}@@ -46,14 +50,14 @@ enum PillCatalog {.init(id: "integration_claude", name: "VS Code", color: "#F5F6F8",category: .workspace, subtitle: "Integration", source: .claudeCode),.init(id: "agent_cursor", name: "Cursor", color: "#C0C4CC",- category: .workspace, subtitle: "Integration", source: .agent, comingSoon: true),+ category: .workspace, subtitle: "Integration", source: .agent),+ .init(id: "agent_antigravity", name: "Antigravity", color: "#E879F9",+ category: .workspace, subtitle: "Integration", source: .agent, githubOnly: true),.init(id: "agent_codex", name: "Codex", color: "#2DD4BF",category: .workspace, subtitle: "Integration", source: .agent, comingSoon: true, githubOnly: true),// ── Agents ───────────────────────────────────────────────────────────.init(id: "agent_gemini", name: "Gemini CLI", color: "#8AB4F8",category: .agent, subtitle: "Agent", source: .agent, githubOnly: true),- .init(id: "agent_antigravity", name: "Antigravity", color: "#E879F9",- category: .agent, subtitle: "Agent", source: .agent, githubOnly: true),// ── AI for the chat ──────────────────────────────────────────────────.init(id: "ai_anthropic", name: "Anthropic", color: ChatProvider.anthropic.accentHex,category: .ai, subtitle: "Chat", source: .n8n),diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swiftindex f9ee07ee..2f841619 100644--- a/NotchBuddy/Sources/App/SettingsView.swift+++ b/NotchBuddy/Sources/App/SettingsView.swift@@ -428,19 +428,6 @@ struct SettingsView: View {// MARK: Active pillsGroupBox("Active pills") {VStack(alignment: .leading, spacing: 10) {- // VS Code: always active (mirrors main branch row exactly)- HStack {- Text("VS Code")- .font(.system(size: 12, weight: .semibold))- Circle().fill(Color(hex: "#F5F6F8")).frame(width: 8, height: 8)- Spacer()- Text("Always active")- .font(.system(size: 11))- .foregroundColor(.secondary)- }-- Divider()-Text("Choose the tools you use. Coucou only shows what you declare here.").font(.system(size: 11)).foregroundColor(.secondary)@@ -449,28 +436,20 @@ struct SettingsView: View {.font(.system(size: 11)).foregroundColor(state.activeIntegrations.count >= 4 ? .orange : .secondary)- // Main pill picker: shown only when a workspace pill (Cursor/Codex) is active- let workspacePills = PillCatalog.available.filter {- $0.category == .workspace && $0.id != "integration_claude"- && state.activeIntegrations.contains($0.id)- }- if !workspacePills.isEmpty {- Picker("Main pill", selection: $state.mainPillId) {- Text("VS Code").tag("integration_claude")- ForEach(workspacePills, id: \.id) { def in- Text(def.name).tag(def.id)- }- }- .onChange(of: state.mainPillId) { _, newId in- state.setFocus(newId)+ Picker("Main", selection: $state.mainPillId) {+ ForEach(PillCatalog.available.filter { $0.category == .workspace && !$0.comingSoon }, id: \.id) { def in+ Text(def.name).tag(def.id)}}+ .onChange(of: state.mainPillId) { _, newId in+ state.activeIntegrations.remove(newId) // main pill never in activeIntegrations+ state.loadIntegrationTasks()+ state.setFocus(newId)+ }- // Categories — integration_claude excluded (shown above)+ // All categories — main pill shown with "Main" label instead of toggleForEach(PillCategory.allCases, id: \.self) { cat in- let catPills = PillCatalog.available.filter {- $0.category == cat && $0.id != "integration_claude"- }+ let catPills = PillCatalog.available.filter { $0.category == cat }if !catPills.isEmpty {Divider()Text(cat.title)@@ -796,10 +775,12 @@ struct SettingsView: View {@ViewBuilderprivate func pillRow(_ def: PillDefinition) -> some View {- let isOn = state.activeIntegrations.contains(def.id)- let atMax = state.activeIntegrations.count >= 4 && !isOn- // Status hint: shown in 11pt gray before the toggle+ let isMain = def.id == state.mainPillId+ let isOn = state.activeIntegrations.contains(def.id)+ let atMax = state.activeIntegrations.count >= 4 && !isOn && !isMain+ // Status hint: shown in 11pt gray before the toggle (not shown for main pill)let hint: String? = {+ if isMain { return nil }if def.comingSoon { return "Coming soon" }#if !APPSTOREif def.id == "agent_gemini" && !HookServer.geminiHooksInstalled() { return "Hooks not installed" }@@ -820,17 +801,23 @@ struct SettingsView: View {.font(.system(size: 12)).foregroundColor(atMax ? .secondary : .primary)Spacer()- if let h = hint {- Text(h)+ if isMain {+ Text("Main").font(.system(size: 11)).foregroundColor(.secondary)+ } else {+ if let h = hint {+ Text(h)+ .font(.system(size: 11))+ .foregroundColor(.secondary)+ }+ Toggle("", isOn: Binding(+ get: { isOn },+ set: { _ in state.toggleIntegration(def.id) }+ ))+ .labelsHidden()+ .disabled(atMax)}- Toggle("", isOn: Binding(- get: { isOn },- set: { _ in state.toggleIntegration(def.id) }- ))- .labelsHidden()- .disabled(atMax)}}}diff --git a/README.md b/README.mdindex 9d0d4981..df06e959 100644--- a/README.md+++ b/README.md@@ -32,11 +32,11 @@ Meet **Mochi**: a soft little squircle with big eyes that pops out of your notch## Features-- 🤖 **Claude Code, Gemini CLI, Antigravity and other agents, live** — see every session in your notch: what it reads, edits and runs, step by step. Tag a hook payload with `coucou_agent` to give any agent its own pill (see [`docs/AGENTS.md`](docs/AGENTS.md)). Finished? Mochi does a happy little jump. Cursor and Codex pills are coming soon.-- ✅ **Approve from the notch** — Claude Code permission requests show up with **Allow / Deny**. One click, back to work.+- 🤖 **Claude Code, Cursor, Gemini CLI, Antigravity and other agents, live** — see every session in your notch: what it reads, edits and runs, step by step. Tag a hook payload with `coucou_agent` to give any agent its own pill (see [`docs/AGENTS.md`](docs/AGENTS.md)). Finished? Mochi does a happy little jump.+- ✅ **Approve from the notch** — Claude Code permission requests show up with **Allow / Deny**, in VS Code or in Cursor's terminal. One click, back to work.- 🧑💻 **Jump to the right terminal** — open the exact terminal window of a session *(macOS)*.- 💬 **Chat with Claude, or with Gemini and OpenAI models using your own keys** *(Gemini and OpenAI: macOS)* — click the model name above the chat box to switch provider and pick a model; the list comes from each API account.-- 📋 **Declare the tools you use** — open Settings → Active pills and choose which coding tools, agents and AI providers show up in the island. VS Code is always there; toggle Gemini CLI, Antigravity, Anthropic, Google AI, OpenAI and more. Check Cursor or Codex and you can make it your main pill, the one in the big card *(macOS)*.+- 📋 **Declare the tools you use** — open Settings → Active pills and pick your main workspace tool (VS Code, Cursor or Antigravity), then toggle up to 4 more: Gemini CLI, Anthropic, Google AI, OpenAI and service integrations *(macOS)*.- 📎 **Drop a file on the notch** — Mochi turns into a box and swallows it, then ask a question about it or send it by email *(email: macOS, Mail.app)*.- 🪟 **Drag Mochi onto any window** — attach that window as context for Claude *(macOS)*.- 🔌 **Integrations** — Stripe payments, n8n workflows, GitHub, Vercel deployments, Resend emails, Notion, Cal.com. Each one gets its own little colored Mochi.diff --git a/docs/SPEC.md b/docs/SPEC.mdindex 0621552e..e182b344 100644--- a/docs/SPEC.md+++ b/docs/SPEC.md@@ -96,18 +96,18 @@ Toutes les pastilles déclarées sont définies dans `PillCatalog.all` (source d| Catégorie | Titre | Pastilles | Subtitle (repos) | Subtitle (session) ||---|---|---|---|---|-| `workspace` | Where you code | VS Code, Cursor *(coming soon)*, Codex *(coming soon, GitHub only)* | Integration | Claude Code / Agent |-| `agent` | Agents | Gemini CLI *(GitHub only)*, Antigravity *(GitHub only)* | Agent | Agent |+| `workspace` | Where you code | VS Code, Cursor, Antigravity *(GitHub only)*, Codex *(coming soon, GitHub only)* | Integration | Claude Code / Cursor / Agent |+| `agent` | Agents | Gemini CLI *(GitHub only)* | Agent | Agent || `ai` | AI for the chat | Anthropic, Google AI, OpenAI | Chat | — || `service` | Services | Resend, n8n, Vercel, GitHub, Notion, Cal.com, Stripe | Integration | — |Couleurs : Cursor `#C0C4CC`, Codex `#2DD4BF`, Gemini CLI `#8AB4F8`, Antigravity `#E879F9`, pastilles IA = `ChatProvider.accentHex`.Règles :-- **`integration_claude` est toujours chargée, jamais retirée, jamais décochée.** Elle ne compte pas dans les 4 places.-- `mainPillId` (défaut `integration_claude`) peut valoir une pastille workspace cochée (ex. Cursor). Si on décoche la principale, `mainPillId` revient à `integration_claude`.-- Max 4 pastilles autres qu'`integration_claude` actives à la fois (`activeIntegrations`, persisté). Cursor/Codex comptent dans les 4.-- `removeTask` sur `integration_claude` ou `mainPillId` ou une pastille déclarée + active → reset à `.idle` + `pillBadge = nil` + nom du catalogue (pas de suppression). Sinon → suppression normale.+- **`mainPillId`** (défaut `integration_claude`) est la pastille workspace toujours chargée. Elle ne compte pas dans les 4 places. Modifiable via le sélecteur Main dans Settings.+- Quand `mainPillId != "integration_claude"`, la pastille VS Code est chargée seulement si une session VS Code est active (transient) ou si elle est cochée dans `activeIntegrations`.+- Max 4 pastilles autres que `mainPillId` actives à la fois (`activeIntegrations`, persisté).+- `removeTask` sur `mainPillId` ou une pastille déclarée + active → reset à `.idle` + `pillBadge = nil` + nom du catalogue (pas de suppression). Sinon → suppression normale.- `sortTasksByCatalog` : pastilles du catalogue dans l'ordre du catalogue ; pastilles hors catalogue juste après `integration_claude`.- Pastilles `githubOnly` : exclues des builds App Store (`#if APPSTORE`).- Hooks (Gemini CLI, Antigravity) : `isConfigured` = `HookServer.geminiHooksInstalled()` / `agyHooksInstalled()` sous `#if !APPSTORE`.diff --git a/docs/support.html b/docs/support.htmlindex 6ce0116e..b4671f7b 100644--- a/docs/support.html+++ b/docs/support.html@@ -26,11 +26,11 @@<h3>The chat doesn’t answer</h3><p>Add your API key in Settings: <b>Settings → Anthropic API</b> for Claude, or <b>Settings → Chat — other providers</b> <i>(macOS)</i> for Google AI (Gemini) or OpenAI. API usage is billed by the provider, separately from any subscription.</p><h3>An integration pill stays grey</h3>-<p>Check its key in Settings. Up to 4 pills (other than VS Code) can be active at once — see <b>Settings → Active pills</b>.</p>+<p>Check its key in Settings. Up to 4 pills can be active at once in addition to the main workspace tool — see <b>Settings → Active pills</b>.</p><h3>What are Active pills? (macOS)</h3>-<p>Active pills are the coding tools, agents and AI providers you declare in <b>Settings → Active pills</b>. VS Code is always there; you can add up to 4 more, including Gemini CLI, Antigravity, Anthropic, Google AI, OpenAI and service integrations. When Cursor or Codex is checked, a Main pill menu lets you choose which one opens in the big card. An agent that sends <code>coucou_agent</code> in its hook payload still gets its own automatic pill regardless.</p>-<h3>When are Cursor and Codex sessions available?</h3>-<p>Cursor and Codex pills are already in <b>Settings → Active pills</b> <i>(Codex: GitHub build only)</i>. You can declare them and set either as the Main pill. Support for their actual sessions is coming in a future version.</p>+<p>Active pills are the coding tools, agents and AI providers you declare in <b>Settings → Active pills</b>. The <b>Main</b> picker at the top lets you choose your primary workspace tool (VS Code, Cursor or Antigravity — GitHub build only). You can then add up to 4 more pills: Gemini CLI, Anthropic, Google AI, OpenAI and service integrations. An agent that sends <code>coucou_agent</code> in its hook payload still gets its own automatic pill regardless.</p>+<h3>Can I use Coucou with Cursor? (macOS)</h3>+<p>Yes. Install the Claude Code hooks (<b>Settings → Claude Code → Install hooks</b>). Claude Code started in Cursor's terminal then shows up on the Cursor pill, and its permission requests can be answered from the notch, like in VS Code. Cursor's own agent shows up too when Cursor loads Claude Code's hooks; its requests are still answered in Cursor. Pick Cursor as your Main tool if that's where you code. Codex support is coming.</p><h3>No sound</h3><p>Check the speaker icon in the notch header and the volume in Settings.</p><h3>Which model does the chat use?</h3>@@ -65,11 +65,11 @@<h3>Le chat ne répond pas</h3><p>Ajoute ta clé d’API dans les Réglages : <b>Réglages → Anthropic API</b> pour Claude, ou <b>Réglages → Chat — other providers</b> <i>(macOS)</i> pour Google AI (Gemini) ou OpenAI. L’API est facturée par le fournisseur, à part de tout abonnement.</p><h3>Une pastille reste grise</h3>-<p>Vérifie sa clé dans les Réglages. Jusqu’à 4 pastilles (hors VS Code) peuvent être actives en même temps — voir <b>Réglages → Active pills</b>.</p>+<p>Vérifie sa clé dans les Réglages. Jusqu’à 4 pastilles peuvent être actives en même temps, en plus de l’outil de code principal — voir <b>Réglages → Active pills</b>.</p><h3>Qu’est-ce que les Active pills ? (macOS)</h3>-<p>Les Active pills sont les outils de code, agents et fournisseurs IA que tu déclares dans <b>Réglages → Active pills</b>. VS Code est toujours présent ; tu peux en ajouter jusqu’à 4 autres, dont Gemini CLI, Antigravity, Anthropic, Google AI, OpenAI et des intégrations de services. Quand Cursor ou Codex est coché, un menu Main pill te permet de choisir lequel s’affiche dans la grande carte de l’island. Un agent qui envoie <code>coucou_agent</code> dans son payload obtient quand même sa pastille automatique.</p>-<h3>Quand les sessions Cursor et Codex seront-elles disponibles ?</h3>-<p>Les pastilles Cursor et Codex sont déjà dans <b>Réglages → Active pills</b> <i>(Codex : version GitHub uniquement)</i>. Tu peux les déclarer et en faire la Main pill. La prise en charge de leurs sessions arrivera dans une prochaine version.</p>+<p>Les Active pills sont les outils de code, agents et fournisseurs IA que tu déclares dans <b>Réglages → Active pills</b>. Le sélecteur <b>Main</b> en haut te permet de choisir ton outil principal (VS Code, Cursor ou Antigravity — version GitHub uniquement). Tu peux ensuite ajouter jusqu’à 4 pastilles supplémentaires : Gemini CLI, Anthropic, Google AI, OpenAI et des intégrations de services. Un agent qui envoie <code>coucou_agent</code> dans son payload obtient quand même sa pastille automatique.</p>+<h3>Puis-je utiliser Coucou avec Cursor ? (macOS)</h3>+<p>Oui. Installe les hooks Claude Code (<b>Réglages → Claude Code → Install hooks</b>). Claude Code lancé dans le terminal de Cursor apparaît alors sur la pastille Cursor, et tu peux répondre à ses demandes d’autorisation depuis le notch, comme dans VS Code. L’agent de Cursor apparaît aussi quand Cursor charge les hooks de Claude Code ; ses demandes se règlent encore dans Cursor. Choisis Cursor comme outil principal si c’est là que tu codes. Codex arrive bientôt.</p><h3>Pas de son</h3><p>Vérifie l’icône haut-parleur dans l’en-tête du notch et le volume dans les Réglages.</p><h3>Quel modèle utilise le chat ?</h3>