11import Client
22import ComposableArchitecture
33import Foundation
4+ import KeyboardShortcuts
45
56#if canImport(LicenseManagement)
67import LicenseManagement
78#endif
89
10+ extension KeyboardShortcuts . Name {
11+ static let showHideWidget = Self ( " ShowHideWidget " )
12+ }
13+
914struct HostApp : ReducerProtocol {
1015 struct State : Equatable {
1116 var general = General . State ( )
@@ -22,16 +27,20 @@ struct HostApp: ReducerProtocol {
2227 }
2328
2429 @Dependency ( \. toast) var toast
30+
31+ init ( ) {
32+ KeyboardShortcuts . userDefaults = . shared
33+ }
2534
2635 var body : some ReducerProtocol < State , Action > {
2736 Scope ( state: \. general, action: / Action. general) {
2837 General ( )
2938 }
30-
39+
3140 Scope ( state: \. chatModelManagement, action: / Action. chatModelManagement) {
3241 ChatModelManagement ( )
3342 }
34-
43+
3544 Scope ( state: \. embeddingModelManagement, action: / Action. embeddingModelManagement) {
3645 EmbeddingModelManagement ( )
3746 }
@@ -40,7 +49,7 @@ struct HostApp: ReducerProtocol {
4049 switch action {
4150 case . appear:
4251 return . none
43-
52+
4453 case . informExtensionServiceAboutLicenseKeyChange:
4554 #if canImport(LicenseManagement)
4655 return . run { _ in
@@ -55,13 +64,13 @@ struct HostApp: ReducerProtocol {
5564 #else
5665 return . none
5766 #endif
58-
67+
5968 case . general:
6069 return . none
61-
70+
6271 case . chatModelManagement:
6372 return . none
64-
73+
6574 case . embeddingModelManagement:
6675 return . none
6776 }
@@ -70,8 +79,8 @@ struct HostApp: ReducerProtocol {
7079}
7180
7281import Dependencies
73- import Preferences
7482import Keychain
83+ import Preferences
7584
7685struct UserDefaultsDependencyKey : DependencyKey {
7786 static var liveValue : UserDefaultsType = UserDefaults . shared
@@ -80,6 +89,7 @@ struct UserDefaultsDependencyKey: DependencyKey {
8089 it. removePersistentDomain ( forName: " HostAppPreview " )
8190 return it
8291 } ( )
92+
8393 static var testValue : UserDefaultsType = {
8494 let it = UserDefaults ( suiteName: " HostAppTest " ) !
8595 it. removePersistentDomain ( forName: " HostAppTest " )
@@ -106,3 +116,4 @@ extension DependencyValues {
106116 set { self [ APIKeyKeychainDependencyKey . self] = newValue }
107117 }
108118}
119+
0 commit comments