From da8b171265e0f9db09287e62e70e10afa0d44e9c Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Thu, 23 Jul 2026 22:13:51 +0200 Subject: [PATCH 1/4] macOS: fix Sendable warning for UnsafeMutablePointer Swift explicitly [marked UnsafeMutablePointer as non sendable](https://github.com/swiftlang/swift/commit/0568dbf903bbd7c1278c029d7e4eaaad6a460002). Moving from `@unchecked @retroactive` to `nonisolated(unsafe)` is safe for us as per the previous comments --- macos/Sources/Ghostty/Ghostty.Inspector.swift | 4 +++- macos/Sources/Ghostty/Ghostty.Surface.swift | 4 +++- macos/Sources/Ghostty/GhosttyPackage.swift | 7 ------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/macos/Sources/Ghostty/Ghostty.Inspector.swift b/macos/Sources/Ghostty/Ghostty.Inspector.swift index 79567bc4a..fc1983b8f 100644 --- a/macos/Sources/Ghostty/Ghostty.Inspector.swift +++ b/macos/Sources/Ghostty/Ghostty.Inspector.swift @@ -6,7 +6,9 @@ extension Ghostty { /// /// Wraps a `ghostty_inspector_t` final class Inspector: Sendable { - private let inspector: ghostty_inspector_t + /// A inspector is sendable because it is just a reference type. Using the inspector in parameters + /// may be unsafe but the value itself is safe to send across threads. + nonisolated(unsafe) private let inspector: ghostty_inspector_t /// Read the underlying C value for this inspector. This is unsafe because the value will be /// freed when the Inspector class is deinitialized. diff --git a/macos/Sources/Ghostty/Ghostty.Surface.swift b/macos/Sources/Ghostty/Ghostty.Surface.swift index 820441090..a076063d5 100644 --- a/macos/Sources/Ghostty/Ghostty.Surface.swift +++ b/macos/Sources/Ghostty/Ghostty.Surface.swift @@ -10,7 +10,9 @@ extension Ghostty { /// /// Wraps a `ghostty_surface_t` final class Surface: Sendable { - private let surface: ghostty_surface_t + /// A surface is sendable because it is just a reference type. Using the surface in parameters + /// may be unsafe but the value itself is safe to send across threads. + nonisolated(unsafe) private let surface: ghostty_surface_t /// Read the underlying C value for this surface. This is unsafe because the value will be /// freed when the Surface class is deinitialized. diff --git a/macos/Sources/Ghostty/GhosttyPackage.swift b/macos/Sources/Ghostty/GhosttyPackage.swift index 68c196dbc..313223aa3 100644 --- a/macos/Sources/Ghostty/GhosttyPackage.swift +++ b/macos/Sources/Ghostty/GhosttyPackage.swift @@ -4,13 +4,6 @@ import GhosttyKit // MARK: C Extensions -/// A command is fully self-contained so it is Sendable. -extension ghostty_command_s: @unchecked @retroactive Sendable {} - -/// A surface is sendable because it is just a reference type. Using the surface in parameters -/// may be unsafe but the value itself is safe to send across threads. -extension ghostty_surface_t: @unchecked @retroactive Sendable {} - extension Ghostty { // The user notification category identifier static let userNotificationCategory = "com.mitchellh.ghostty.userNotification" From 97ae257497ae687bca7f9c711e46c6937386480e Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Thu, 23 Jul 2026 22:19:41 +0200 Subject: [PATCH 2/4] macOS: fix warnings in showUserNotification --- .../Surface View/SurfaceView_AppKit.swift | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift index b5c73b9fe..35b99e436 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift @@ -1787,26 +1787,25 @@ extension Ghostty { // Note the callback may be executed on a background thread as documented // so we need @MainActor since we're reading/writing view state. - UNUserNotificationCenter.current().add(request) { @MainActor error in - if let error = error { - AppDelegate.logger.error("Error scheduling user notification: \(error, privacy: .public)") - return - } + Task { @MainActor in + do { + try await UNUserNotificationCenter.current().add(request) - // We need to keep track of this notification so we can remove it - // under certain circumstances - self.notificationIdentifiers.insert(uuid) + // We need to keep track of this notification so we can remove it + // under certain circumstances + notificationIdentifiers.insert(uuid) - // If we're focused then we schedule to remove the notification - // after a few seconds. If we gain focus we automatically remove it - // in focusDidChange. - if self.focused { - Task { @MainActor [weak self] in + // If we're focused then we schedule to remove the notification + // after a few seconds. If we gain focus we automatically remove it + // in focusDidChange. + if self.focused { try await Task.sleep(for: .seconds(3)) - self?.notificationIdentifiers.remove(uuid) + notificationIdentifiers.remove(uuid) UNUserNotificationCenter.current() .removeDeliveredNotifications(withIdentifiers: [uuid]) } + } catch { + AppDelegate.logger.error("Error scheduling user notification: \(error, privacy: .public)") } } } From c78226bfaea1e03107d91c4e27c836f9d8143a7b Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Thu, 23 Jul 2026 22:21:45 +0200 Subject: [PATCH 3/4] macOS: fix Main actor-isolated static property 'find' warnings --- macos/Sources/Ghostty/Surface View/OSSurfaceView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macos/Sources/Ghostty/Surface View/OSSurfaceView.swift b/macos/Sources/Ghostty/Surface View/OSSurfaceView.swift index a85f9d626..9f2926c8b 100644 --- a/macos/Sources/Ghostty/Surface View/OSSurfaceView.swift +++ b/macos/Sources/Ghostty/Surface View/OSSurfaceView.swift @@ -138,9 +138,9 @@ extension Ghostty.OSSurfaceView { init( from startSearch: Ghostty.Action.StartSearch, - pasteboard: NSPasteboard = NSPasteboard.find + pasteboard: NSPasteboard? = nil ) { - self.pasteboard = pasteboard + self.pasteboard = pasteboard ?? .find if let needle = startSearch.needle, !needle.isEmpty { setNeedle(needle) writePasteboardNeedle() From cb7eaa059dbc4be7318a6071efc14b4891c628e6 Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Thu, 23 Jul 2026 22:53:26 +0200 Subject: [PATCH 4/4] macOS: silent weak ownership difference warnings UpdateViewModel doesn't own the Task, we don't actually need it here. --- macos/Sources/Features/Update/UpdatePill.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/macos/Sources/Features/Update/UpdatePill.swift b/macos/Sources/Features/Update/UpdatePill.swift index e0301457d..21af76595 100644 --- a/macos/Sources/Features/Update/UpdatePill.swift +++ b/macos/Sources/Features/Update/UpdatePill.swift @@ -24,10 +24,10 @@ struct UpdatePill: View { .onChange(of: model.state) { newState in resetTask?.cancel() if case .notFound(let notFound) = newState { - resetTask = Task { [weak model] in + resetTask = Task { try? await Task.sleep(for: .seconds(5)) - guard !Task.isCancelled, case .notFound? = model?.state else { return } - model?.state = .idle + guard !Task.isCancelled, case .notFound = model.state else { return } + model.state = .idle notFound.acknowledgement() } } else {