mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-25 16:41:44 +00:00
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user