@@ -105,6 +105,7 @@ final class MacNodeModeCoordinator: NSObject {
105105 private let session : GatewayNodeSession
106106 private let nodeHostWorker : ( any MacNodeHostWorking ) ?
107107 private let presenceReporter : MacNodePresenceReporter
108+ private let notificationCenter : NotificationCenter
108109 private let routeInvalidationHook : ( @Sendable ( ) async -> Void ) ?
109110 private let refreshEvents : AsyncStream < Void >
110111 private let refreshContinuation : AsyncStream < Void > . Continuation
@@ -135,6 +136,7 @@ final class MacNodeModeCoordinator: NSObject {
135136 runtime: MacNodeRuntime ,
136137 nodeHostWorker: ( any MacNodeHostWorking ) ? = nil ,
137138 presenceReporter: MacNodePresenceReporter = MacNodePresenceReporter ( ) ,
139+ notificationCenter: NotificationCenter = . default,
138140 observeNotifications: Bool = false ,
139141 initialPaused: Bool ? = nil ,
140142 initialComputerControlEnabled: Bool ? = nil ,
@@ -145,6 +147,7 @@ final class MacNodeModeCoordinator: NSObject {
145147 self . runtime = runtime
146148 self . nodeHostWorker = nodeHostWorker
147149 self . presenceReporter = presenceReporter
150+ self . notificationCenter = notificationCenter
148151 self . routeInvalidationHook = routeInvalidationHook
149152 self . refreshEvents = refreshEvents. stream
150153 self . refreshContinuation = refreshEvents. continuation
@@ -154,40 +157,40 @@ final class MacNodeModeCoordinator: NSObject {
154157 super. init ( )
155158
156159 guard observeNotifications else { return }
157- NotificationCenter . default . addObserver (
160+ self . notificationCenter . addObserver (
158161 self ,
159162 selector: #selector( self . refreshNodeConfiguration) ,
160163 name: UserDefaults . didChangeNotification,
161164 object: UserDefaults . standard)
162- NotificationCenter . default . addObserver (
165+ self . notificationCenter . addObserver (
163166 self ,
164167 selector: #selector( self . refreshNodeConfiguration) ,
165168 name: NSApplication . didBecomeActiveNotification,
166169 object: nil )
167- NotificationCenter . default . addObserver (
170+ self . notificationCenter . addObserver (
168171 self ,
169172 selector: #selector( self . refreshNodeConfiguration) ,
170173 name: . openclawPermissionsChanged,
171174 object: nil )
172- NotificationCenter . default . addObserver (
175+ self . notificationCenter . addObserver (
173176 self ,
174177 selector: #selector( self . nodeHostWorkerFailed) ,
175178 name: . openclawNodeHostWorkerFailed,
176179 object: nil )
177- NotificationCenter . default . addObserver (
180+ self . notificationCenter . addObserver (
178181 self ,
179182 selector: #selector( self . nodeHostConfigurationChanged) ,
180183 name: . openclawConfigDidChange,
181184 object: nil )
182- NotificationCenter . default . addObserver (
185+ self . notificationCenter . addObserver (
183186 self ,
184187 selector: #selector( self . nodeHostConfigurationChanged) ,
185188 name: . openclawCLIInstalled,
186189 object: nil )
187190 }
188191
189192 deinit {
190- NotificationCenter . default . removeObserver ( self )
193+ self . notificationCenter . removeObserver ( self )
191194 self . refreshContinuation. finish ( )
192195 }
193196
0 commit comments