Skip to content

Commit b3c5e5a

Browse files
austinywangclaude
andcommitted
fix: stop the fallback sound when notifications are denied
Implement fallbackEffects(_:authorizationState:) and route every out-of-band fallback call site through it: FeedCoordinator's denied branch, its just-declined-the-prompt branch, and the store's unauthorized scheduleUserNotification fallback. Only .denied strips the sound; .notDetermined (deferred prompt) and granted states keep the audible fallback, and delivery-failure fallbacks for authorized users are unchanged. This is the TCC-independent half of #5650: the Focus assertion-store gate cannot run on a default install (the store needs Full Disk Access), but a user who turned cmux notifications off has already asked for silence - including during Focus, which suppresses banners through the same denied-shaped fallback. The Focus gate remains as best-effort for FDA installs and the app-frontmost suppressed-banner path. This is the green half: the denied-authorization test from the previous commit now passes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 8e7a61a commit b3c5e5a

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

Sources/Feed/FeedCoordinator.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,17 @@ private extension FeedCoordinator {
919919
effects: effects
920920
)
921921
} else {
922+
// The user declined the prompt just now: honor the
923+
// fresh denial on this very notification.
922924
self.runFallbackEffectsIfStillAwaiting(
923925
requestId: requestId,
924926
title: title,
925927
subtitle: subtitle,
926928
body: body,
927-
effects: effects
929+
effects: TerminalNotificationStore.fallbackEffects(
930+
effects,
931+
authorizationState: .denied
932+
)
928933
)
929934
}
930935
default:
@@ -933,7 +938,12 @@ private extension FeedCoordinator {
933938
title: title,
934939
subtitle: subtitle,
935940
body: body,
936-
effects: effects
941+
effects: TerminalNotificationStore.fallbackEffects(
942+
effects,
943+
authorizationState: TerminalNotificationStore.authorizationState(
944+
from: settings.authorizationStatus
945+
)
946+
)
937947
)
938948
}
939949
}

Sources/TerminalNotificationQueue.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ extension TerminalNotificationStore {
447447
_ effects: TerminalNotificationPolicyEffects,
448448
authorizationState: NotificationAuthorizationState
449449
) -> TerminalNotificationPolicyEffects {
450-
effects
450+
guard authorizationState == .denied else { return effects }
451+
var silenced = effects
452+
silenced.sound = false
453+
return silenced
451454
}
452455
}

Sources/TerminalNotificationStore.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ final class TerminalNotificationStore: ObservableObject {
20912091
title: content.title,
20922092
subtitle: content.subtitle,
20932093
body: content.body,
2094-
effects: effects
2094+
effects: Self.fallbackEffects(effects, authorizationState: self.authorizationState)
20952095
)
20962096
return
20972097
}

0 commit comments

Comments
 (0)