File tree Expand file tree Collapse file tree
Tool/Sources/BuiltinExtension Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import AppKit
2+ import Combine
13import Foundation
4+ import XcodeInspector
25
36public final class BuiltinExtensionManager {
47 public static let shared : BuiltinExtensionManager = . init( )
58 private( set) var extensions : [ BuiltinExtension ] = [ ]
6-
9+
10+ private var cancellable : Set < AnyCancellable > = [ ]
11+
12+ init ( ) {
13+ XcodeInspector . shared. $activeApplication. sink { [ weak self] app in
14+ if let app, app. isXcode || app. isExtensionService {
15+ self ? . checkAppConfiguration ( )
16+ }
17+ } . store ( in: & cancellable)
18+ }
19+
720 public func setupExtensions( _ extensions: [ BuiltinExtension ] ) {
821 self . extensions = extensions
922 }
10-
23+
1124 public func terminate( ) {
1225 for ext in extensions {
1326 ext. terminate ( )
1427 }
1528 }
1629}
30+
31+ extension BuiltinExtensionManager {
32+ func checkAppConfiguration( ) {
33+ let suggestionFeatureProvider = UserDefaults . shared. value ( for: \. suggestionFeatureProvider)
34+ for ext in extensions {
35+ let isSuggestionFeatureInUse = suggestionFeatureProvider ==
36+ . builtIn( ext. suggestionServiceId)
37+ let isChatFeatureInUse = false
38+ ext. appConfigurationDidChange ( . init(
39+ suggestionServiceInUse: isSuggestionFeatureInUse,
40+ chatServiceInUse: isChatFeatureInUse
41+ ) )
42+ }
43+ }
44+ }
45+
You can’t perform that action at this time.
0 commit comments