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.

Fix sendLine: use withUnsafeBytes instead of &bytes[sent]

Louis Raille40caf18925d5
diff --git a/NotchBuddy/Sources/App/HookServer.swift b/NotchBuddy/Sources/App/HookServer.swift
index 69f5d27a..8dd6c4ac 100644
--- a/NotchBuddy/Sources/App/HookServer.swift
+++ b/NotchBuddy/Sources/App/HookServer.swift
@@ -439,12 +439,14 @@ final class HookServer: @unchecked Sendable {
}
private func sendLine(fd: Int32, text: String) {
- var bytes = Array((text + "\n").utf8)
- var sent = 0
- while sent < bytes.count {
- let n = Darwin.send(fd, &bytes[sent], bytes.count - sent, 0)
- if n <= 0 { break }
- sent += n
+ let bytes = Array((text + "\n").utf8)
+ bytes.withUnsafeBytes { buffer in
+ var sent = 0
+ while sent < buffer.count {
+ let n = Darwin.send(fd, buffer.baseAddress! + sent, buffer.count - sent, 0)
+ if n <= 0 { break }
+ sent += n
+ }
}
}