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
Fix PermissionRequest: Always uses updatedPermissions, no auto-deny
Louis Raille2c76370a57e3
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swiftindex ed3bd038..6fd9f920 100644--- a/NotchBuddy/Sources/App/AppState.swift+++ b/NotchBuddy/Sources/App/AppState.swift@@ -180,10 +180,6 @@ final class AppState: ObservableObject {// Pending approval request from Claude Code hook@Published var pendingApproval: ApprovalInfo? = nil- // Always-allow mode (set by "Toujours autoriser" button)- @Published var alwaysAllow: Bool = false--// MARK: - Init (loads persisted settings)private init() {diff --git a/NotchBuddy/Sources/App/HookServer.swift b/NotchBuddy/Sources/App/HookServer.swiftindex e7064cc7..85fa798d 100644--- a/NotchBuddy/Sources/App/HookServer.swift+++ b/NotchBuddy/Sources/App/HookServer.swift@@ -273,7 +273,8 @@ final class HookServer: @unchecked Sendable {if pendingApprovalFD >= 0 {let old = pendingApprovalFDTask.detached { [weak self] in- self?.sendLine(fd: old, text: #"{"permissionDecision":"deny"}"#)+ // "ask" → nb-hook outputs nothing → Claude Code re-asks+ self?.sendLine(fd: old, text: #"{"permissionDecision":"ask"}"#)close(old)}}@@ -296,7 +297,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.sendApprovalDecision("deny")+ // "ask" → nb-hook outputs nothing → Claude Code re-asks rather than denying+ self.sendApprovalDecision("ask")}}@@ -309,7 +311,8 @@ final class HookServer: @unchecked Sendable {let json: Stringswitch decision {case "allow": json = #"{"permissionDecision":"allow"}"#- case "always": json = #"{"permissionDecision":"allow","alwaysAllow":true}"#+ case "always": json = #"{"permissionDecision":"always"}"#+ case "ask": json = #"{"permissionDecision":"ask"}"#default: json = #"{"permissionDecision":"deny"}"#}@@ -321,7 +324,6 @@ final class HookServer: @unchecked Sendable {}let state = AppState.shared- if decision == "always" { state.alwaysAllow = true }state.pendingApproval = nilstate.isPinned = falsestate.updateTask(id: "integration_claude", state: .working)@@ -740,26 +742,9 @@ def main():sys.stdout.flush()sys.exit(0)elif decision == 'always':- # Persist the permission rule from Claude Code's suggestion+ # Let Claude Code persist the rule via updatedPermissionssuggestions = payload.get('permission_suggestions', [])- if suggestions:- try:- settings_path = os.path.expanduser('~/.claude/settings.json')- if os.path.exists(settings_path):- with open(settings_path, 'r') as f:- settings = json.load(f)- else:- settings = {}- perms = settings.setdefault('permissions', {})- allow_list = perms.setdefault('allow', [])- for rule in suggestions:- if rule not in allow_list:- allow_list.append(rule)- with open(settings_path, 'w') as f:- json.dump(settings, f, indent=2, sort_keys=True)- except Exception:- pass- out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'allow'}}}+ out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'allow', 'updatedPermissions': suggestions}}}sys.stdout.write(json.dumps(out) + '\\n')sys.stdout.flush()sys.exit(0)@@ -768,10 +753,11 @@ def main():sys.stdout.write(json.dumps(out) + '\\n')sys.stdout.flush()sys.exit(0)+ # 'ask' or unknown: fall through → no output → Claude Code re-asksexcept Exception:pass- # App unreachable, timed out, or unknown decision — print nothing- # Claude Code will handle the absence of output+ # App unreachable, timed out, or no explicit decision — print nothing+ # Claude Code 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)@@ -847,26 +833,9 @@ def main():sys.stdout.flush()sys.exit(0)elif decision == 'always':- # Script runs outside sandbox so ~/.claude/settings.json is directly accessible+ # Let Claude Code persist the rule via updatedPermissionssuggestions = payload.get('permission_suggestions', [])- if suggestions:- try:- settings_path = os.path.expanduser('~/.claude/settings.json')- if os.path.exists(settings_path):- with open(settings_path, 'r') as f:- settings = json.load(f)- else:- settings = {}- perms = settings.setdefault('permissions', {})- allow_list = perms.setdefault('allow', [])- for rule in suggestions:- if rule not in allow_list:- allow_list.append(rule)- with open(settings_path, 'w') as f:- json.dump(settings, f, indent=2, sort_keys=True)- except Exception:- pass- out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'allow'}}}+ out = {'hookSpecificOutput': {'hookEventName': 'PermissionRequest', 'decision': {'behavior': 'allow', 'updatedPermissions': suggestions}}}sys.stdout.write(json.dumps(out) + '\\n')sys.stdout.flush()sys.exit(0)@@ -875,9 +844,10 @@ def main():sys.stdout.write(json.dumps(out) + '\\n')sys.stdout.flush()sys.exit(0)+ # 'ask' or unknown: fall through → no output → Claude Code re-asksexcept Exception:pass- # App unreachable, timed out, or unknown decision — print nothing+ # App unreachable, timed out, or no explicit decision — print nothingsys.exit(0)try:diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swiftindex 38010f75..696a69fb 100644--- a/NotchBuddy/Sources/App/IslandViewContent.swift+++ b/NotchBuddy/Sources/App/IslandViewContent.swift@@ -207,10 +207,8 @@ struct ApprovalView: View {PrimaryButton("Allow") {HookServer.shared.sendApprovalDecision("allow")}- if !state.alwaysAllow {- SecondaryButton("Always") {- HookServer.shared.sendApprovalDecision("always")- }+ SecondaryButton("Always") {+ HookServer.shared.sendApprovalDecision("always")}}}