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 App Store hooks: correct socket path, command path, getpwuid (build 4)
Louis Raille835421c7fff2
diff --git a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxprojindex 27336aa6..0423c8c5 100644--- a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj+++ b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj@@ -375,6 +375,7 @@isa = XCBuildConfiguration;buildSettings = {ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGNING_ALLOWED = YES;CODE_SIGN_ENTITLEMENTS = Resources/CoucouAppStore.entitlements;CODE_SIGN_IDENTITY = "Apple Development";CODE_SIGN_STYLE = Automatic;@@ -397,6 +398,7 @@isa = XCBuildConfiguration;buildSettings = {ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGNING_ALLOWED = YES;CODE_SIGN_ENTITLEMENTS = Resources/CoucouAppStore.entitlements;CODE_SIGN_IDENTITY = "Apple Development";CODE_SIGN_STYLE = Automatic;diff --git a/NotchBuddy/Resources/InfoAppStore.plist b/NotchBuddy/Resources/InfoAppStore.plistindex bdf7ea2d..ab3b158d 100644--- a/NotchBuddy/Resources/InfoAppStore.plist+++ b/NotchBuddy/Resources/InfoAppStore.plist@@ -19,7 +19,7 @@<key>CFBundleShortVersionString</key><string>1.0</string><key>CFBundleVersion</key>- <string>2</string>+ <string>4</string><key>ITSAppUsesNonExemptEncryption</key><false/><key>LSApplicationCategoryType</key>diff --git a/NotchBuddy/Sources/App/HookServer.swift b/NotchBuddy/Sources/App/HookServer.swiftindex a021f8cc..73441476 100644--- a/NotchBuddy/Sources/App/HookServer.swift+++ b/NotchBuddy/Sources/App/HookServer.swift@@ -14,16 +14,18 @@ final class HookServer: @unchecked Sendable {FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("NotchBuddy")}- static var socketPath: String { supportDir.appendingPathComponent("nb.sock").path }- static var hookScriptPath: String {+ static var socketPath: String {#if APPSTORE- // Use real user home (not container home) for the hook script path in settings.json- let realHome = NSHomeDirectoryForUser(NSUserName()) ?? FileManager.default.homeDirectoryForCurrentUser.path- return URL(fileURLWithPath: realHome).appendingPathComponent(".claude/coucou/nb-hook").path+ // Container home root keeps path ≤ 103 bytes (sun_path limit on macOS is 104 incl. NUL)+ // /Users/louis/Library/Containers/fr.louisraille.Coucou/Data/nb.sock = 66 bytes ✓+ return NSHomeDirectory() + "/nb.sock"#else- return supportDir.appendingPathComponent("nb-hook").path+ return supportDir.appendingPathComponent("nb.sock").path#endif}+ // hookScriptPath is only used by the non-App Store build.+ // App Store build derives the command from the panel-selected claudeURL in buildHooksData(claudeURL:).+ static var hookScriptPath: String { supportDir.appendingPathComponent("nb-hook").path }// No approval blocking state — notch is notification-only, user answers in VS Code@@ -48,6 +50,12 @@ final class HookServer: @unchecked Sendable {private func serverThread() {let path = Self.socketPath+ // sun_path on macOS is 104 bytes including the NUL terminator → max 103 usable bytes+ let maxSunPathBytes = MemoryLayout<sockaddr_un>.size - MemoryLayout<sa_family_t>.size - 1+ guard path.utf8.count <= maxSunPathBytes else {+ NSLog("HookServer: socket path too long (\(path.utf8.count) bytes, max \(maxSunPathBytes)): \(path)")+ return+ }try? FileManager.default.removeItem(atPath: path)let fd = socket(AF_UNIX, SOCK_STREAM, 0)@@ -645,7 +653,8 @@ final class HookServer: @unchecked Sendable {let parsed = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {settings = parsed}- let hookPath = Self.hookScriptPath+ // Derive hook path from the panel-selected claudeURL (real ~/.claude, not container)+ let hookPath = claudeURL.appendingPathComponent("coucou/nb-hook").pathlet quotedCmd = "/bin/sh \"\(hookPath.replacingOccurrences(of: "\"", with: "\\\""))\""let events: [(String, Int)] = [("SessionStart", 10), ("SessionEnd", 10),@@ -817,7 +826,7 @@ def main():event = payload.get('hook_event_name', '')socket_path = os.path.expanduser(- '~/Library/Containers/fr.louisraille.Coucou/Data/Library/Application Support/NotchBuddy/nb.sock'+ '~/Library/Containers/fr.louisraille.Coucou/Data/nb.sock')if event == 'PermissionRequest':diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swiftindex 696a69fb..8c565fd8 100644--- a/NotchBuddy/Sources/App/IslandViewContent.swift+++ b/NotchBuddy/Sources/App/IslandViewContent.swift@@ -958,14 +958,20 @@ struct IntegrationCardView: View {private var isConfigured: Bool {switch task.id {case "integration_claude":+ #if APPSTORE+ // Sandboxed: can't read ~/.claude directly — check install flag set by HookServer+ return UserDefaults.standard.bool(forKey: "coucouHooksInstalled")+ #elselet url = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".claude/settings.json")guard let data = try? Data(contentsOf: url),let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],let hooks = json["hooks"] as? [String: Any],let ss = hooks["SessionStart"] as? [[String: Any]] else { return false }return ss.contains { ($0["hooks"] as? [[String: Any]])?.contains {- ($0["command"] as? String)?.contains("NotchBuddy") == true+ let cmd = $0["command"] as? String+ return cmd?.contains("NotchBuddy") == true || cmd?.contains("coucou") == true} ?? false }+ #endifcase "integration_resend": return KeychainStore.shared.get("resend-api-key") != nilcase "integration_n8n": return KeychainStore.shared.get("n8n-api-key") != nilcase "integration_vercel": return KeychainStore.shared.get("vercel-token") != nildiff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swiftindex 95a1727a..7114f30c 100644--- a/NotchBuddy/Sources/App/SettingsView.swift+++ b/NotchBuddy/Sources/App/SettingsView.swift@@ -367,7 +367,9 @@ struct SettingsView: View {panel.canChooseDirectories = truepanel.allowsMultipleSelection = falsepanel.showsHiddenFiles = true- let realHomePath = NSHomeDirectoryForUser(NSUserName()) ?? FileManager.default.homeDirectoryForCurrentUser.path+ // getpwuid bypasses CFFIXED_USER_HOME and always returns the real user home+ let realHomePath = getpwuid(getuid()).flatMap { String(cString: $0.pointee.pw_dir, encoding: .utf8) }+ ?? "/Users/\(NSUserName())"panel.directoryURL = URL(fileURLWithPath: realHomePath)guard panel.runModal() == .OK, let url = panel.url else { return nil }guard url.lastPathComponent == ".claude" else {diff --git a/NotchBuddy/project.yml b/NotchBuddy/project.ymlindex c4c3fcc4..aba2ef9d 100644--- a/NotchBuddy/project.yml+++ b/NotchBuddy/project.yml@@ -94,7 +94,7 @@ targets:CFBundleName: CoucouCFBundleDisplayName: CoucouCFBundleIdentifier: fr.louisraille.Coucou- CFBundleVersion: "3"+ CFBundleVersion: "4"CFBundleShortVersionString: "1.0"CFBundlePackageType: APPLLSUIElement: YES@@ -114,3 +114,4 @@ targets:CODE_SIGN_ENTITLEMENTS: Resources/CoucouAppStore.entitlementsDEVELOPMENT_TEAM: 256AUJ9555SWIFT_ACTIVE_COMPILATION_CONDITIONS: APPSTORE+ CODE_SIGNING_ALLOWED: YES