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.

Codex: live sessions and approvals from the notch (#130)

Louis123e713f07c5
diff --git a/CLAUDE.md b/CLAUDE.md
index 9a0c322e..5614c57f 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -22,7 +22,7 @@ Windows and Linux: `cd windows && npm install && npm run tauri dev`
- No telemetry. Network calls only to services the user configured.
- Never block Claude Code: if the app doesn't answer, the hook exits immediately.
- Never overwrite `~/.claude/settings.json`: dated backup, merge, show the diff, write only after the user confirms.
-- Never send an email or approve a Claude Code permission without an explicit click.
+- Never send an email or approve a Claude Code or Codex permission without an explicit click.
- Performance: 0 % CPU when the island is hidden.
- Keep the bundle identifier `fr.louisraille.NotchBuddy` (Keychain items, preferences and permissions depend on it).
- Never restyle what already ships (pills, cards, Settings, chat…): existing views stay exactly as they are in `main`, which is the App Store build. Change the look of an existing view only when explicitly asked.
diff --git a/NotchBuddy/Sources/App/HookServer.swift b/NotchBuddy/Sources/App/HookServer.swift
index a8afb913..06687662 100644
--- a/NotchBuddy/Sources/App/HookServer.swift
+++ b/NotchBuddy/Sources/App/HookServer.swift
@@ -231,10 +231,22 @@ final class HookServer: @unchecked Sendable {
termProgram.lowercased().contains("vscode") ||
bundleId.lowercased().contains("vscode"))
- // Routing: coucou_agent → external pill; Cursor → agent_cursor; VS Code → integration_claude.
+ // Routing:
+ // • "codex" → agent_codex (GitHub build only: workspace pill, approvals in the notch)
+ // • other valid coucou_agent → external pill (fire-and-forget, no approval card)
+ // • Cursor bundle ID → agent_cursor
+ // • VS Code → integration_claude
+ #if !APPSTORE
+ let isCodexEvent = rawAgent == "codex"
+ #else
+ let isCodexEvent = false
+ #endif
let agentId: String
let isExternalAgent: Bool
- if let agent = validAgent {
+ if isCodexEvent {
+ agentId = "agent_codex"
+ isExternalAgent = false
+ } else if let agent = validAgent {
agentId = "agent_\(agent)"
isExternalAgent = true
} else if isCursorEditor {
@@ -253,7 +265,12 @@ final class HookServer: @unchecked Sendable {
// 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."
+ let handledNote: String
+ switch pending.pillId {
+ case "agent_cursor": handledNote = "Handled in Cursor."
+ case "agent_codex": handledNote = "Handled in Codex."
+ default: handledNote = "Handled in VS Code."
+ }
var resolved = false
switch name {
case "PostToolUse", "PostToolUseFailure":
@@ -265,7 +282,7 @@ final class HookServer: @unchecked Sendable {
dismissApprovalCard(note: handledNote)
resolved = true
}
- case "Stop", "StopFailure", "UserPromptSubmit", "SessionEnd":
+ case "Stop", "StopFailure", "UserPromptSubmit", "SessionEnd", "Interrupt":
// Turn ended or session interrupted — the permission is moot.
if sessionId == pending.sessionId {
dismissApprovalCard(note: handledNote)
@@ -352,6 +369,12 @@ final class HookServer: @unchecked Sendable {
setPillBadge(id: agentId, badge: .error)
}
+ case "Interrupt":
+ // Codex: user stopped the turn
+ activeSessionId = nil
+ state.updateTask(id: agentId, state: .idle)
+ clearPillBadge(id: agentId)
+
case "SessionEnd":
activeSessionId = nil
state.removeTask(id: agentId)
@@ -441,12 +464,23 @@ final class HookServer: @unchecked Sendable {
let rawName = URL(fileURLWithPath: cwd).lastPathComponent
let projectName = aliasProjectName(rawName.isEmpty ? "Session" : rawName)
- // External agents (coucou_agent) do not yet get an approval card — answering
- // would show a card that looks like a Claude Code request. Reply immediately
- // with no decision so the relay writes nothing and the agent re-asks in its
- // terminal. Approval support for other agents will come with Codex support.
let rawAgent = payload["coucou_agent"] as? String ?? ""
- if Self.validateAgent(rawAgent) != nil {
+ let termProgram = payload["term_program"] as? String ?? ""
+ let bundleId = payload["bundle_id"] as? String ?? ""
+ let isCursorEditor = bundleId.lowercased() == "com.todesktop.230313mzl4w4u92"
+ let isVSCodeEditor = !isCursorEditor && (
+ termProgram.lowercased().contains("vscode") ||
+ bundleId.lowercased().contains("vscode"))
+
+ // Codex gets the same approval card as Claude Code / Cursor (GitHub build only).
+ // Other external agents (any other coucou_agent) answer immediately with "ask"
+ // so the agent re-asks in its own terminal — they do not get a notch card.
+ #if !APPSTORE
+ let isCodexRequest = rawAgent == "codex"
+ #else
+ let isCodexRequest = false
+ #endif
+ if !isCodexRequest && Self.validateAgent(rawAgent) != nil {
Task.detached { [weak self] in
self?.sendLine(fd: fd, text: #"{"permissionDecision":"ask"}"#)
close(fd)
@@ -454,15 +488,16 @@ final class HookServer: @unchecked Sendable {
return
}
- let termProgram = payload["term_program"] as? String ?? ""
- let bundleId = payload["bundle_id"] as? String ?? ""
- // 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 {
+ // Determine which workspace pill owns the request.
+ let pillId: String
+ if isCodexRequest {
+ pillId = "agent_codex"
+ } else if isCursorEditor {
+ pillId = "agent_cursor"
+ } else {
+ pillId = "integration_claude"
+ }
+ guard isCodexRequest || isCursorEditor || isVSCodeEditor else {
Task.detached { [weak self] in
self?.sendLine(fd: fd, text: #"{"permissionDecision":"ask"}"#)
close(fd)
@@ -510,7 +545,12 @@ final class HookServer: @unchecked Sendable {
let source = DispatchSource.makeReadSource(fileDescriptor: fd, queue: .main)
source.setEventHandler { [weak self] in
guard let self, self.pendingApprovalFD == fd else { return }
- let note = capturedPillId == "agent_cursor" ? "Handled in Cursor." : "Handled in VS Code."
+ let note: String
+ switch capturedPillId {
+ case "agent_cursor": note = "Handled in Cursor."
+ case "agent_codex": note = "Handled in Codex."
+ default: note = "Handled in VS Code."
+ }
self.dismissApprovalCard(note: note)
}
source.setCancelHandler { close(fd) }
@@ -518,11 +558,16 @@ final class HookServer: @unchecked Sendable {
approvalFDSource = source
// 115s safety timeout — show a note and cancel without sending a decision.
- // nb-hook reads EOF from the cancel handler's close and exits; Claude Code re-asks.
+ // nb-hook reads EOF from the cancel handler's close and exits; Claude Code / Codex re-asks.
let captured = fd
DispatchQueue.main.asyncAfter(deadline: .now() + 115) { [weak self] in
guard let self, self.pendingApprovalFD == captured else { return }
- let note = capturedPillId == "agent_cursor" ? "Still waiting in Cursor." : "Still waiting in VS Code."
+ let note: String
+ switch capturedPillId {
+ case "agent_cursor": note = "Still waiting in Cursor."
+ case "agent_codex": note = "Still waiting in Codex."
+ default: note = "Still waiting in VS Code."
+ }
self.dismissApprovalCard(note: note)
}
}
@@ -637,34 +682,85 @@ final class HookServer: @unchecked Sendable {
private func frenchStep(tool: String, input: [String: Any]) -> String {
let labels: [String: String] = [
- "Bash": "Exécute",
- "Read": "Lit",
- "Write": "Écrit",
- "Edit": "Modifie",
- "Glob": "Cherche",
- "Grep": "Recherche",
- "WebSearch": "Recherche web",
- "WebFetch": "Récupère",
- "TodoWrite": "Tâches",
- "Task": "Agent",
- "LS": "Liste",
- "MultiEdit": "Modifie",
+ "Bash": "Exécute",
+ "Read": "Lit",
+ "Write": "Écrit",
+ "Edit": "Modifie",
+ "Glob": "Cherche",
+ "Grep": "Recherche",
+ "WebSearch": "Recherche web",
+ "WebFetch": "Récupère",
+ "TodoWrite": "Tâches",
+ "Task": "Agent",
+ "LS": "Liste",
+ "MultiEdit": "Modifie",
"NotebookEdit": "Notebook",
+ // Codex tools
+ "apply_patch": "Modifie",
+ "update_plan": "Tâches",
+ "spawn_agent": "Agent",
]
- let label = labels[tool] ?? tool
+ var label = labels[tool] ?? tool
+
+ // Codex MCP tools arrive as mcp__server__tool — show "server · tool"
+ if tool.hasPrefix("mcp__") {
+ let rest = String(tool.dropFirst(5))
+ let parts = rest.components(separatedBy: "__")
+ label = parts.count >= 2 ? "\(parts[0]) · \(parts.dropFirst().joined(separator: "__"))" : rest
+ }
+
+ // Bash: infer a more precise verb from the command
+ if tool == "Bash", let cmd = input["command"] as? String {
+ return "\(bashVerb(cmd)) · \(oneLine(cmd))"
+ }
+
+ // apply_patch: extract the first file name from the patch
+ if tool == "apply_patch", let patch = input["command"] as? String {
+ for line in patch.split(separator: "\n") {
+ for prefix in ["*** Update File: ", "*** Add File: ", "*** Delete File: "] {
+ if line.hasPrefix(prefix) {
+ let path = String(line.dropFirst(prefix.count))
+ return "\(label) · \(URL(fileURLWithPath: path).lastPathComponent)"
+ }
+ }
+ }
+ return label
+ }
+
if let cmd = input["command"] as? String {
- let short = String(cmd.prefix(40))
- return "\(label) · \(short)"
+ return "\(label) · \(oneLine(cmd))"
} else if let path = input["path"] as? String {
return "\(label) · \(URL(fileURLWithPath: path).lastPathComponent)"
} else if let file = input["file_path"] as? String {
return "\(label) · \(URL(fileURLWithPath: file).lastPathComponent)"
} else if let query = input["query"] as? String {
- return "\(label) · \(String(query.prefix(40)))"
+ return "\(label) · \(oneLine(query))"
}
return label
}
+ /// Infers a French verb from a shell command's first word.
+ private func bashVerb(_ command: String) -> String {
+ let first = command.split(whereSeparator: { $0.isWhitespace }).first.map(String.init) ?? ""
+ switch first {
+ case "cat", "bat", "head", "tail", "less", "more", "nl": return "Lit"
+ case "rg", "grep", "find", "fd", "ls", "tree", "wc": return "Cherche"
+ default: break
+ }
+ let testRunners = ["pytest", "vitest", "jest", "npm test", "npm run test",
+ "cargo test", "go test", "swift test", "make test",
+ "xcodebuild test", "unittest"]
+ if testRunners.contains(where: { command.contains($0) }) { return "Teste" }
+ return "Exécute"
+ }
+
+ /// Collapses whitespace so a multi-line command stays one ticker row.
+ private func oneLine(_ text: String, limit: Int = 60) -> String {
+ let collapsed = text.split(whereSeparator: { $0.isNewline || $0 == "\t" })
+ .joined(separator: " ")
+ return collapsed.count > limit ? String(collapsed.prefix(limit)) + "…" : collapsed
+ }
+
// MARK: - Logging
private func nbLog(_ message: String) {
@@ -1174,6 +1270,129 @@ final class HookServer: @unchecked Sendable {
}
}
+ // MARK: - Codex hook installer (#if !APPSTORE only)
+
+ static var codexHooksURL: URL {
+ FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".codex/hooks.json")
+ }
+
+ /// True when ~/.codex/hooks.json already routes Codex events to Coucou's nb-hook.
+ static func codexHooksInstalled() -> Bool {
+ guard let data = try? Data(contentsOf: codexHooksURL),
+ let root = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any],
+ let hooks = root["hooks"] as? [String: Any] else { return false }
+ for value in hooks.values {
+ guard let groups = value as? [[String: Any]] else { continue }
+ for group in groups {
+ if let innerHooks = group["hooks"] as? [[String: Any]] {
+ for hook in innerHooks {
+ if let cmd = hook["command"] as? String,
+ cmd.contains("nb-hook"), cmd.contains("--agent codex") { return true }
+ }
+ }
+ }
+ }
+ return false
+ }
+
+ private var _pendingCodexData: Data?
+ private var _pendingCodexFingerprint: String?
+
+ func previewCodexHooks(install: Bool) throws -> String {
+ let url = Self.codexHooksURL
+ let exists = FileManager.default.fileExists(atPath: url.path)
+ if !install && !exists {
+ throw NSError(domain: "CoucouNoop", code: 0, userInfo: [
+ NSLocalizedDescriptionKey: "No Codex hooks to remove."
+ ])
+ }
+ let current = exists ? try Data(contentsOf: url) : Data()
+ _pendingCodexFingerprint = sha256Hex(current)
+ let newData = install ? try buildCodexHooksData() : try withoutCodexHooks()
+ _pendingCodexData = newData
+ return String(data: newData, encoding: .utf8) ?? ""
+ }
+
+ func writeCodexHooks() throws {
+ guard let data = _pendingCodexData, let fp = _pendingCodexFingerprint else { return }
+ let url = Self.codexHooksURL
+ let current = (try? Data(contentsOf: url)) ?? Data()
+ guard sha256Hex(current) == fp else {
+ throw NSError(domain: "Coucou", code: 1, userInfo: [
+ NSLocalizedDescriptionKey: "~/.codex/hooks.json changed since preview. Refresh and try again."
+ ])
+ }
+ try writeJSONFile(data, to: url, suffix: "hooks.json")
+ _pendingCodexData = nil
+ _pendingCodexFingerprint = nil
+ }
+
+ private func buildCodexHooksData() throws -> Data {
+ var root = try Self.strictReadJSONObject(at: Self.codexHooksURL, label: "~/.codex/hooks.json")
+ if let raw = root["hooks"], !(raw is [String: Any]) {
+ throw NSError(domain: "Coucou", code: 2, userInfo: [
+ NSLocalizedDescriptionKey: "~/.codex/hooks.json: \"hooks\" has an unexpected type — Coucou has not touched it."
+ ])
+ }
+ let base = hookBase()
+ // Events, timeouts in seconds (Codex format).
+ // PermissionRequest uses 120s + a statusMessage shown in the Codex UI while waiting.
+ let events: [(String, Int, String?)] = [
+ ("SessionStart", 10, nil),
+ ("UserPromptSubmit", 10, nil),
+ ("PreToolUse", 10, nil),
+ ("PermissionRequest", 120, "Waiting for your answer in the notch (Coucou)"),
+ ("PostToolUse", 10, nil),
+ ("Stop", 10, nil),
+ ("SubagentStart", 10, nil),
+ ("SubagentStop", 10, nil),
+ ("Interrupt", 3, nil),
+ ("SessionEnd", 3, nil),
+ ]
+ var hooks = root["hooks"] as? [String: Any] ?? [:]
+ for (event, timeout, statusMsg) in events {
+ if let raw = hooks[event], !(raw is [[String: Any]]) {
+ throw NSError(domain: "Coucou", code: 2, userInfo: [
+ NSLocalizedDescriptionKey: "~/.codex/hooks.json: \"hooks\"[\"\(event)\"] has an unexpected type — Coucou has not touched it."
+ ])
+ }
+ var groups = hooks[event] as? [[String: Any]] ?? []
+ // Remove existing Coucou entries
+ groups = removeNbHookEntries(from: groups)
+ var hookEntry: [String: Any] = [
+ "type": "command",
+ "command": "\(base) --agent codex",
+ "timeout": timeout,
+ ]
+ if let msg = statusMsg { hookEntry["statusMessage"] = msg }
+ groups.append(["hooks": [hookEntry]])
+ hooks[event] = groups
+ }
+ root["hooks"] = hooks
+ return try JSONSerialization.data(withJSONObject: root,
+ options: [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes])
+ }
+
+ private func withoutCodexHooks() throws -> Data {
+ var root = try Self.strictReadJSONObject(at: Self.codexHooksURL, label: "~/.codex/hooks.json")
+ if let raw = root["hooks"], !(raw is [String: Any]) {
+ throw NSError(domain: "Coucou", code: 2, userInfo: [
+ NSLocalizedDescriptionKey: "~/.codex/hooks.json: \"hooks\" has an unexpected type — Coucou has not touched it."
+ ])
+ }
+ if var hooks = root["hooks"] as? [String: Any] {
+ for key in hooks.keys {
+ if let groups = hooks[key] as? [[String: Any]] {
+ let cleaned = removeNbHookEntries(from: groups)
+ if cleaned.isEmpty { hooks.removeValue(forKey: key) } else { hooks[key] = cleaned }
+ }
+ }
+ if hooks.isEmpty { root.removeValue(forKey: "hooks") } else { root["hooks"] = hooks }
+ }
+ return try JSONSerialization.data(withJSONObject: root,
+ options: [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes])
+ }
+
// MARK: SHA-256 fingerprint
private func sha256Hex(_ data: Data) -> String {
@@ -1334,23 +1553,29 @@ def main():
sys.stdout.write(json.dumps(out) + '\\n')
sys.stdout.flush()
sys.exit(0)
- elif decision == 'always':
+ elif decision == 'always' and agent != 'codex':
# Let Claude Code persist the rule via updatedPermissions
suggestions = payload.get('permission_suggestions', [])
out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'allow', 'updatedPermissions': suggestions}}}
sys.stdout.write(json.dumps(out) + '\\n')
sys.stdout.flush()
sys.exit(0)
+ elif decision == 'always':
+ # Codex rejects updatedPermissions — answer a plain allow instead
+ out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'allow'}}}
+ sys.stdout.write(json.dumps(out) + '\\n')
+ sys.stdout.flush()
+ sys.exit(0)
elif decision == 'deny':
out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'deny', 'message': 'Denied from Coucou'}}}
sys.stdout.write(json.dumps(out) + '\\n')
sys.stdout.flush()
sys.exit(0)
- # 'ask' or unknown: fall through → no output → Claude Code re-asks
+ # 'ask' or unknown: fall through → no output → agent re-asks
except Exception:
pass
# App unreachable, timed out, or no explicit decision — print nothing
- # Claude Code will handle the absence of output (re-ask or default behaviour)
+ # Claude Code / Codex will handle the absence of output (re-ask or default behaviour)
sys.exit(0)
# All other events: fire-and-forget (0.3s timeout, never blocks)
@@ -1361,7 +1586,7 @@ def main():
s.sendall((json.dumps(payload) + '\\n').encode())
s.close()
except Exception:
- pass # Always exit cleanly — never block Claude Code
+ pass # Always exit cleanly — never block the agent
# Gemini CLI and Antigravity expect a JSON response on stdout (empty = no decision)
if agent in ('gemini', 'antigravity'):
@@ -1497,19 +1722,25 @@ def main():
sys.stdout.write(json.dumps(out) + '\\n')
sys.stdout.flush()
sys.exit(0)
- elif decision == 'always':
+ elif decision == 'always' and agent != 'codex':
# Let Claude Code persist the rule via updatedPermissions
suggestions = payload.get('permission_suggestions', [])
out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'allow', 'updatedPermissions': suggestions}}}
sys.stdout.write(json.dumps(out) + '\\n')
sys.stdout.flush()
sys.exit(0)
+ elif decision == 'always':
+ # Codex rejects updatedPermissions — answer a plain allow instead
+ out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'allow'}}}
+ sys.stdout.write(json.dumps(out) + '\\n')
+ sys.stdout.flush()
+ sys.exit(0)
elif decision == 'deny':
out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'deny', 'message': 'Denied from Coucou'}}}
sys.stdout.write(json.dumps(out) + '\\n')
sys.stdout.flush()
sys.exit(0)
- # 'ask' or unknown: fall through → no output → Claude Code re-asks
+ # 'ask' or unknown: fall through → no output → agent re-asks
except Exception:
pass
# App unreachable, timed out, or no explicit decision — print nothing
@@ -1522,7 +1753,7 @@ def main():
s.sendall((json.dumps(payload) + '\\n').encode())
s.close()
except Exception:
- pass # Always exit cleanly — never block Claude Code
+ pass # Always exit cleanly — never block the agent
# Gemini CLI and Antigravity expect a JSON response on stdout (empty = no decision)
if agent in ('gemini', 'antigravity'):
diff --git a/NotchBuddy/Sources/App/IslandTypes.swift b/NotchBuddy/Sources/App/IslandTypes.swift
index 5e506a88..109a2457 100644
--- a/NotchBuddy/Sources/App/IslandTypes.swift
+++ b/NotchBuddy/Sources/App/IslandTypes.swift
@@ -36,7 +36,7 @@ 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".
+ /// Pill that owns this approval: "integration_claude", "agent_cursor", or "agent_codex".
var pillId: String
}
diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swift
index c0e1ec3c..87d1d1d3 100644
--- a/NotchBuddy/Sources/App/IslandViewContent.swift
+++ b/NotchBuddy/Sources/App/IslandViewContent.swift
@@ -243,8 +243,11 @@ struct ApprovalView: View {
PrimaryButton("Allow") {
HookServer.shared.sendApprovalDecision("allow")
}
- SecondaryButton("Always") {
- HookServer.shared.sendApprovalDecision("always")
+ // Codex rejects updatedPermissions, so "Always" is not offered
+ if approval?.pillId != "agent_codex" {
+ SecondaryButton("Always") {
+ HookServer.shared.sendApprovalDecision("always")
+ }
}
}
}
diff --git a/NotchBuddy/Sources/App/PillCatalog.swift b/NotchBuddy/Sources/App/PillCatalog.swift
index 65284e7e..d97f526e 100644
--- a/NotchBuddy/Sources/App/PillCatalog.swift
+++ b/NotchBuddy/Sources/App/PillCatalog.swift
@@ -36,6 +36,7 @@ struct PillDefinition {
switch id {
case "integration_claude": return "Claude Code"
case "agent_cursor": return "Cursor"
+ case "agent_codex": return "Codex"
default: return "Agent"
}
}
@@ -54,7 +55,7 @@ enum PillCatalog {
.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),
+ category: .workspace, subtitle: "Integration", source: .agent, githubOnly: true),
// ── Agents ───────────────────────────────────────────────────────────
.init(id: "agent_gemini", name: "Gemini CLI", color: "#8AB4F8",
category: .agent, subtitle: "Agent", source: .agent, githubOnly: true),
diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swift
index 2f841619..64d48543 100644
--- a/NotchBuddy/Sources/App/SettingsView.swift
+++ b/NotchBuddy/Sources/App/SettingsView.swift
@@ -42,6 +42,11 @@ struct SettingsView: View {
@State private var showAgyDiff: Bool = false
@State private var pendingAgyJSON: String = ""
@State private var agyPendingInstall: Bool = true
+
+ @State private var codexHooksInstalled: Bool = HookServer.codexHooksInstalled()
+ @State private var showCodexDiff: Bool = false
+ @State private var pendingCodexJSON: String = ""
+ @State private var codexPendingInstall: Bool = true
#endif
// Multi-provider chat keys
@@ -287,6 +292,39 @@ struct SettingsView: View {
}
.padding(6)
}
+
+ GroupBox("Codex Hooks") {
+ VStack(alignment: .leading, spacing: 10) {
+ Text(codexHooksInstalled
+ ? "Hooks installed — open Codex and run /hooks or open Hooks in the app's settings to trust them"
+ : "~/.codex/hooks.json")
+ .font(.system(size: 11, design: .monospaced))
+ .foregroundColor(.secondary)
+ HStack(spacing: 10) {
+ Button("Install hooks") { triggerCodexPreview(install: true) }
+ .buttonStyle(.borderedProminent)
+ Button("Uninstall") { triggerCodexPreview(install: false) }
+ .buttonStyle(.bordered)
+ }
+ if showCodexDiff {
+ ScrollView {
+ Text(pendingCodexJSON)
+ .font(.system(size: 10, design: .monospaced))
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+ .frame(height: 140)
+ .background(Color(NSColor.textBackgroundColor))
+ .cornerRadius(6)
+ HStack {
+ Button("Confirm & write") { confirmCodexOp() }
+ .buttonStyle(.borderedProminent)
+ Button("Cancel") { showCodexDiff = false; pendingCodexJSON = "" }
+ .buttonStyle(.bordered)
+ }
+ }
+ }
+ .padding(6)
+ }
#endif
// MARK: Integrations
@@ -680,6 +718,33 @@ struct SettingsView: View {
statusMessage = "❌ \(error.localizedDescription)"
}
}
+
+ private func triggerCodexPreview(install: Bool) {
+ do {
+ codexPendingInstall = install
+ pendingCodexJSON = try HookServer.shared.previewCodexHooks(install: install)
+ showCodexDiff = true
+ statusMessage = "Review the JSON below before confirming."
+ } catch let e as NSError where e.domain == "CoucouNoop" {
+ statusMessage = e.localizedDescription
+ } catch {
+ statusMessage = "❌ \(error.localizedDescription)"
+ }
+ }
+
+ private func confirmCodexOp() {
+ do {
+ try HookServer.shared.writeCodexHooks()
+ showCodexDiff = false
+ pendingCodexJSON = ""
+ codexHooksInstalled = codexPendingInstall
+ statusMessage = codexPendingInstall
+ ? "✓ Codex hooks installed — run /hooks in Codex or open Hooks in the app's settings to trust them."
+ : "✓ Codex hooks removed."
+ } catch {
+ statusMessage = "❌ \(error.localizedDescription)"
+ }
+ }
#endif
private func saveIntegrations() {
@@ -783,8 +848,9 @@ struct SettingsView: View {
if isMain { return nil }
if def.comingSoon { return "Coming soon" }
#if !APPSTORE
- if def.id == "agent_gemini" && !HookServer.geminiHooksInstalled() { return "Hooks not installed" }
+ if def.id == "agent_gemini" && !HookServer.geminiHooksInstalled() { return "Hooks not installed" }
if def.id == "agent_antigravity" && !HookServer.agyHooksInstalled() { return "Hooks not installed" }
+ if def.id == "agent_codex" && !HookServer.codexHooksInstalled() { return "Hooks not installed" }
#endif
if def.category == .ai {
let keyId = def.id == "ai_anthropic" ? "anthropic-api-key"
diff --git a/README.md b/README.md
index df06e959..60f2bc23 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, 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.
+- 🤖 **Claude Code, Cursor, Codex, 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 and Codex permission requests show up with **Allow / Deny** (and **Always** for Claude Code), in VS Code, Cursor's terminal, or Codex. 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 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)*.
+- 📋 **Declare the tools you use** — open Settings → Active pills and pick your main workspace tool (VS Code, Cursor, Codex 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.md
index e182b344..3a0b4c65 100644
--- a/docs/SPEC.md
+++ b/docs/SPEC.md
@@ -96,7 +96,7 @@ 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, Antigravity *(GitHub only)*, Codex *(coming soon, GitHub only)* | Integration | Claude Code / Cursor / Agent |
+| `workspace` | Where you code | VS Code, Cursor, Antigravity *(GitHub only)*, Codex *(GitHub only)* | Integration | Claude Code / Cursor / Codex / 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 | — |
@@ -110,7 +110,7 @@ Règles :
- `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`.
+- Hooks (Gemini CLI, Antigravity, Codex) : `isConfigured` = `HookServer.geminiHooksInstalled()` / `agyHooksInstalled()` / `codexHooksInstalled()` sous `#if !APPSTORE`. La section Codex Hooks dans Settings installe les hooks dans `~/.codex/hooks.json` avec le même flux backup + preview que Gemini CLI. Après l'installation, la carte affiche : « run /hooks in Codex or open Hooks in the app's settings to trust them ». Approbations Codex : carte avec Allow et Deny seulement (pas Always) ; updatedPermissions jamais envoyé ; notes « Handled in Codex. » / « Still waiting in Codex. ».
- Pastilles IA : `isConfigured` = clé API dans le Keychain. Bouton « Chat with… » → change le fournisseur et ouvre la vue `.prompt`.
### Boutons
diff --git a/docs/privacy.html b/docs/privacy.html
index 86867bd6..878041a8 100644
--- a/docs/privacy.html
+++ b/docs/privacy.html
@@ -35,8 +35,8 @@
</ul>
<p>We have no access to these requests or their responses.</p>
-<h2>5. Claude Code, Gemini CLI and Antigravity hooks</h2>
-<p>If you install the Claude Code hooks, Claude Code sends session events to Coucou through a local connection on your computer. If you install the Gemini CLI or Antigravity hooks, those agents send their session events the same way. These events never leave your computer through Coucou. Before changing any settings file (<code>~/.claude/settings.json</code>, <code>~/.gemini/settings.json</code>, <code>~/.gemini/config/hooks.json</code>), Coucou makes a dated backup and shows you the changes.</p>
+<h2>5. Claude Code, Gemini CLI, Antigravity and Codex hooks</h2>
+<p>If you install the Claude Code hooks, Claude Code sends session events to Coucou through a local connection on your computer. If you install the Gemini CLI, Antigravity or Codex hooks, those agents send their session events the same way. These events never leave your computer through Coucou. Before changing any settings file (<code>~/.claude/settings.json</code>, <code>~/.gemini/settings.json</code>, <code>~/.gemini/config/hooks.json</code>, <code>~/.codex/hooks.json</code>), Coucou makes a dated backup and shows you the changes.</p>
<h2>6. Email</h2>
<p>When you send a file by email, the message is created and sent by your own Mail app. Coucou never sends email by itself.</p>
@@ -87,8 +87,8 @@
</ul>
<p>Le développeur n’a accès ni à ces requêtes ni à leurs réponses.</p>
-<h2>5. Claude Code, Gemini CLI et Antigravity</h2>
-<p>Si tu installes les hooks Claude Code, Claude Code envoie les événements de session à Coucou par une connexion locale sur ton ordinateur. Si tu installes les hooks Gemini CLI ou Antigravity, ces agents envoient leurs événements de la même façon. Coucou ne les fait jamais sortir de ton ordinateur. Avant de modifier un fichier de configuration (<code>~/.claude/settings.json</code>, <code>~/.gemini/settings.json</code>, <code>~/.gemini/config/hooks.json</code>), Coucou en fait une sauvegarde datée et te montre les changements.</p>
+<h2>5. Claude Code, Gemini CLI, Antigravity et Codex</h2>
+<p>Si tu installes les hooks Claude Code, Claude Code envoie les événements de session à Coucou par une connexion locale sur ton ordinateur. Si tu installes les hooks Gemini CLI, Antigravity ou Codex, ces agents envoient leurs événements de la même façon. Coucou ne les fait jamais sortir de ton ordinateur. Avant de modifier un fichier de configuration (<code>~/.claude/settings.json</code>, <code>~/.gemini/settings.json</code>, <code>~/.gemini/config/hooks.json</code>, <code>~/.codex/hooks.json</code>), Coucou en fait une sauvegarde datée et te montre les changements.</p>
<h2>6. E-mail</h2>
<p>Quand tu envoies un fichier par e-mail, le message est créé et envoyé par ta propre app Mail. Coucou n’envoie jamais d’e-mail de lui-même.</p>
diff --git a/docs/support.html b/docs/support.html
index b4671f7b..7b58bce7 100644
--- a/docs/support.html
+++ b/docs/support.html
@@ -28,9 +28,11 @@
<h3>An integration pill stays grey</h3>
<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>. 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>
+<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, Codex 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>
+<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.</p>
+<h3>Can I use Coucou with Codex? (macOS, GitHub build)</h3>
+<p>Yes. Open <b>Settings → Codex Hooks → Install hooks</b>. Coucou shows you the changes to <code>~/.codex/hooks.json</code> before writing anything. Once installed, open Codex and run <code>/hooks</code>, or open <b>Hooks</b> in Codex's settings, to review and trust the hooks — Codex asks for this once. After that, your Codex sessions show up on the Codex pill, and permission requests show up with <b>Allow</b> and <b>Deny</b> in the notch.</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>
@@ -67,9 +69,11 @@
<h3>Une pastille reste grise</h3>
<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>. 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>
+<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, Codex 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>
+<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.</p>
+<h3>Puis-je utiliser Coucou avec Codex ? (macOS, version GitHub)</h3>
+<p>Oui. Ouvre <b>Réglages → Codex Hooks → Install hooks</b>. Coucou te montre les changements apportés à <code>~/.codex/hooks.json</code> avant d’écrire quoi que ce soit. Une fois les hooks installés, ouvre Codex et tape <code>/hooks</code>, ou ouvre <b>Hooks</b> dans les réglages de l’app, pour les passer en revue et leur faire confiance — Codex ne te le demande qu’une fois. Ensuite, tes sessions Codex apparaissent sur la pastille Codex, et les demandes d’autorisation apparaissent avec <b>Allow</b> et <b>Deny</b> dans le notch.</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>