native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #173 from supabitapp/settings-disable-dock-badge

Add dock badge toggle for notifications

authored by

khoi and committed by
GitHub
b23b0b4d 2aed0bcf

+39 -1
+16 -1
supacode/Features/App/Reducer/AppFeature.swift
··· 21 21 var openActionSelection: OpenWorktreeAction = .finder 22 22 var selectedRunScript: String = "" 23 23 var runScriptStatusByWorktreeID: [Worktree.ID: Bool] = [:] 24 + var notificationIndicatorCount: Int = 0 24 25 @Presents var alert: AlertState<Alert>? 25 26 26 27 init( ··· 196 197 return .none 197 198 198 199 case .settings(.delegate(.settingsChanged(let settings))): 200 + let badgeLabel = 201 + settings.dockBadgeEnabled 202 + ? (state.notificationIndicatorCount == 0 ? nil : String(state.notificationIndicatorCount)) 203 + : nil 199 204 return .merge( 200 205 .send(.repositories(.setGithubIntegrationEnabled(settings.githubIntegrationEnabled))), 201 206 .send( ··· 208 213 ), 209 214 .run { _ in 210 215 await terminalClient.send(.setNotificationsEnabled(settings.inAppNotificationsEnabled)) 216 + }, 217 + .run { _ in 218 + await MainActor.run { 219 + NSApplication.shared.dockTile.badgeLabel = badgeLabel 220 + } 211 221 }, 212 222 .run { _ in 213 223 await worktreeInfoWatcher.send( ··· 426 436 } 427 437 428 438 case .terminalEvent(.notificationIndicatorChanged(let count)): 439 + state.notificationIndicatorCount = count 440 + let badgeLabel = 441 + state.settings.dockBadgeEnabled 442 + ? (count == 0 ? nil : String(count)) 443 + : nil 429 444 return .run { _ in 430 445 await MainActor.run { 431 - NSApplication.shared.dockTile.badgeLabel = count == 0 ? nil : String(count) 446 + NSApplication.shared.dockTile.badgeLabel = badgeLabel 432 447 } 433 448 } 434 449
+7
supacode/Features/Settings/Models/GlobalSettings.swift
··· 4 4 var updatesAutomaticallyCheckForUpdates: Bool 5 5 var updatesAutomaticallyDownloadUpdates: Bool 6 6 var inAppNotificationsEnabled: Bool 7 + var dockBadgeEnabled: Bool 7 8 var notificationSoundEnabled: Bool 8 9 var githubIntegrationEnabled: Bool 9 10 var deleteBranchOnArchive: Bool ··· 14 15 updatesAutomaticallyCheckForUpdates: true, 15 16 updatesAutomaticallyDownloadUpdates: false, 16 17 inAppNotificationsEnabled: true, 18 + dockBadgeEnabled: true, 17 19 notificationSoundEnabled: true, 18 20 githubIntegrationEnabled: true, 19 21 deleteBranchOnArchive: true ··· 25 27 updatesAutomaticallyCheckForUpdates: Bool, 26 28 updatesAutomaticallyDownloadUpdates: Bool, 27 29 inAppNotificationsEnabled: Bool, 30 + dockBadgeEnabled: Bool, 28 31 notificationSoundEnabled: Bool, 29 32 githubIntegrationEnabled: Bool, 30 33 deleteBranchOnArchive: Bool ··· 34 37 self.updatesAutomaticallyCheckForUpdates = updatesAutomaticallyCheckForUpdates 35 38 self.updatesAutomaticallyDownloadUpdates = updatesAutomaticallyDownloadUpdates 36 39 self.inAppNotificationsEnabled = inAppNotificationsEnabled 40 + self.dockBadgeEnabled = dockBadgeEnabled 37 41 self.notificationSoundEnabled = notificationSoundEnabled 38 42 self.githubIntegrationEnabled = githubIntegrationEnabled 39 43 self.deleteBranchOnArchive = deleteBranchOnArchive ··· 50 54 inAppNotificationsEnabled = 51 55 try container.decodeIfPresent(Bool.self, forKey: .inAppNotificationsEnabled) 52 56 ?? Self.default.inAppNotificationsEnabled 57 + dockBadgeEnabled = 58 + try container.decodeIfPresent(Bool.self, forKey: .dockBadgeEnabled) 59 + ?? Self.default.dockBadgeEnabled 53 60 notificationSoundEnabled = 54 61 try container.decodeIfPresent(Bool.self, forKey: .notificationSoundEnabled) 55 62 ?? Self.default.notificationSoundEnabled
+4
supacode/Features/Settings/Reducer/SettingsFeature.swift
··· 10 10 var updatesAutomaticallyCheckForUpdates: Bool 11 11 var updatesAutomaticallyDownloadUpdates: Bool 12 12 var inAppNotificationsEnabled: Bool 13 + var dockBadgeEnabled: Bool 13 14 var notificationSoundEnabled: Bool 14 15 var githubIntegrationEnabled: Bool 15 16 var deleteBranchOnArchive: Bool ··· 22 23 updatesAutomaticallyCheckForUpdates = settings.updatesAutomaticallyCheckForUpdates 23 24 updatesAutomaticallyDownloadUpdates = settings.updatesAutomaticallyDownloadUpdates 24 25 inAppNotificationsEnabled = settings.inAppNotificationsEnabled 26 + dockBadgeEnabled = settings.dockBadgeEnabled 25 27 notificationSoundEnabled = settings.notificationSoundEnabled 26 28 githubIntegrationEnabled = settings.githubIntegrationEnabled 27 29 deleteBranchOnArchive = settings.deleteBranchOnArchive ··· 34 36 updatesAutomaticallyCheckForUpdates: updatesAutomaticallyCheckForUpdates, 35 37 updatesAutomaticallyDownloadUpdates: updatesAutomaticallyDownloadUpdates, 36 38 inAppNotificationsEnabled: inAppNotificationsEnabled, 39 + dockBadgeEnabled: dockBadgeEnabled, 37 40 notificationSoundEnabled: notificationSoundEnabled, 38 41 githubIntegrationEnabled: githubIntegrationEnabled, 39 42 deleteBranchOnArchive: deleteBranchOnArchive ··· 73 76 state.updatesAutomaticallyCheckForUpdates = settings.updatesAutomaticallyCheckForUpdates 74 77 state.updatesAutomaticallyDownloadUpdates = settings.updatesAutomaticallyDownloadUpdates 75 78 state.inAppNotificationsEnabled = settings.inAppNotificationsEnabled 79 + state.dockBadgeEnabled = settings.dockBadgeEnabled 76 80 state.notificationSoundEnabled = settings.notificationSoundEnabled 77 81 state.githubIntegrationEnabled = settings.githubIntegrationEnabled 78 82 state.deleteBranchOnArchive = settings.deleteBranchOnArchive
+5
supacode/Features/Settings/Views/NotificationsSettingsView.swift
··· 14 14 ) 15 15 .help("Show bell icon next to worktree") 16 16 Toggle( 17 + "Show Dock badge", 18 + isOn: $store.dockBadgeEnabled 19 + ) 20 + .help("Show a badge on the Dock icon for unread notifications") 21 + Toggle( 17 22 "Play notification sound", 18 23 isOn: $store.notificationSoundEnabled 19 24 )
+6
supacodeTests/SettingsFeatureTests.swift
··· 15 15 updatesAutomaticallyCheckForUpdates: false, 16 16 updatesAutomaticallyDownloadUpdates: true, 17 17 inAppNotificationsEnabled: false, 18 + dockBadgeEnabled: false, 18 19 notificationSoundEnabled: true, 19 20 githubIntegrationEnabled: true, 20 21 deleteBranchOnArchive: false ··· 32 33 $0.updatesAutomaticallyCheckForUpdates = false 33 34 $0.updatesAutomaticallyDownloadUpdates = true 34 35 $0.inAppNotificationsEnabled = false 36 + $0.dockBadgeEnabled = false 35 37 $0.notificationSoundEnabled = true 36 38 $0.githubIntegrationEnabled = true 37 39 $0.deleteBranchOnArchive = false ··· 46 48 updatesAutomaticallyCheckForUpdates: false, 47 49 updatesAutomaticallyDownloadUpdates: false, 48 50 inAppNotificationsEnabled: false, 51 + dockBadgeEnabled: true, 49 52 notificationSoundEnabled: false, 50 53 githubIntegrationEnabled: true, 51 54 deleteBranchOnArchive: true ··· 71 74 updatesAutomaticallyCheckForUpdates: initialSettings.updatesAutomaticallyCheckForUpdates, 72 75 updatesAutomaticallyDownloadUpdates: initialSettings.updatesAutomaticallyDownloadUpdates, 73 76 inAppNotificationsEnabled: initialSettings.inAppNotificationsEnabled, 77 + dockBadgeEnabled: initialSettings.dockBadgeEnabled, 74 78 notificationSoundEnabled: initialSettings.notificationSoundEnabled, 75 79 githubIntegrationEnabled: initialSettings.githubIntegrationEnabled, 76 80 deleteBranchOnArchive: initialSettings.deleteBranchOnArchive ··· 115 119 updatesAutomaticallyCheckForUpdates: false, 116 120 updatesAutomaticallyDownloadUpdates: true, 117 121 inAppNotificationsEnabled: false, 122 + dockBadgeEnabled: false, 118 123 notificationSoundEnabled: false, 119 124 githubIntegrationEnabled: true, 120 125 deleteBranchOnArchive: true ··· 126 131 $0.updatesAutomaticallyCheckForUpdates = false 127 132 $0.updatesAutomaticallyDownloadUpdates = true 128 133 $0.inAppNotificationsEnabled = false 134 + $0.dockBadgeEnabled = false 129 135 $0.notificationSoundEnabled = false 130 136 $0.githubIntegrationEnabled = true 131 137 $0.deleteBranchOnArchive = true
+1
supacodeTests/SettingsFilePersistenceTests.swift
··· 101 101 #expect(settings.global.updatesAutomaticallyCheckForUpdates == false) 102 102 #expect(settings.global.updatesAutomaticallyDownloadUpdates == true) 103 103 #expect(settings.global.inAppNotificationsEnabled == true) 104 + #expect(settings.global.dockBadgeEnabled == true) 104 105 #expect(settings.global.notificationSoundEnabled == true) 105 106 #expect(settings.global.githubIntegrationEnabled == true) 106 107 #expect(settings.global.deleteBranchOnArchive == true)