Skip to content

Commit 9e3a013

Browse files
committed
Update
1 parent edd1af2 commit 9e3a013

File tree

6 files changed

+48
-16
lines changed

6 files changed

+48
-16
lines changed

Core/Package.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ let package = Package(
117117
"GitHubCopilotService",
118118
"CodeiumService",
119119
"LaunchAgentManager",
120+
"PlusFeatureFlag",
120121
.product(name: "Toast", package: "Tool"),
121122
.product(name: "SuggestionModel", package: "Tool"),
122123
.product(name: "MarkdownUI", package: "swift-markdown-ui"),
@@ -266,8 +267,9 @@ let package = Package(
266267
.target(
267268
name: "PlusFeatureFlag",
268269
dependencies: [
269-
.product(name: "LicenseManagement", package: "Tool"),
270-
]
270+
].pro([
271+
"LicenseManagement"
272+
])
271273
),
272274

273275
// MARK: - GitHub Copilot

Core/Sources/HostApp/CustomCommandSettings/CustomCommand.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ struct CustomCommandFeature: ReducerProtocol {
1818
case deleteCommand(CustomCommand)
1919
}
2020

21-
@Dependency(\.toastController) var toastController
21+
@Dependency(\.toast) var toast
2222

2323
var body: some ReducerProtocol<State, Action> {
2424
Reduce { state, action in
2525
switch action {
2626
case .createNewCommand:
27+
if settings.customCommands.count >= 10 {
28+
toast("Upgrade to Plus to add more commands", .info)
29+
return .none
30+
}
2731
state.editCustomCommand = EditCustomCommand.State(nil)
2832
return .none
2933
case let .editCommand(command):

Core/Sources/HostApp/CustomCommandSettings/CustomCommandView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ComposableArchitecture
22
import MarkdownUI
3+
import PlusFeatureFlag
34
import Preferences
45
import SwiftUI
56

@@ -72,7 +73,12 @@ struct CustomCommandView: View {
7273
Button(action: {
7374
store.send(.createNewCommand)
7475
}) {
75-
Text(Image(systemName: "plus.circle.fill")) + Text(" New Command")
76+
if isFeatureAvailable(\.unlimitedCustomCommands) {
77+
Text(Image(systemName: "plus.circle.fill")) + Text(" New Command")
78+
} else {
79+
Text(Image(systemName: "plus.circle.fill")) +
80+
Text(" New Command (\(settings.customCommands.count)/10)")
81+
}
7682
}
7783
.buttonStyle(.plain)
7884
.padding()

Core/Sources/HostApp/HostApp.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ struct HostApp: ReducerProtocol {
2929
case .appear:
3030
return .none
3131
case .informExtensionServiceAboutLicenseKeyChange:
32+
#if canImport(LicenseManagement)
3233
return .run { _ in
33-
#if canImport(LicenseManagement)
3434
let service = try getService()
3535
do {
3636
try await service
3737
.postNotification(name: Notification.Name.licenseKeyChanged.rawValue)
3838
} catch {
3939
toast(error.localizedDescription, .error)
4040
}
41-
#endif
4241
}
42+
#else
43+
return .none
44+
#endif
4345
case .general:
4446
return .none
4547
}

Core/Sources/PlusFeatureFlag/PlusFeatureFlag.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
import Dependencies
21
import Foundation
32
import SwiftUI
43

54
#if canImport(LicenseManagement)
65

76
import LicenseManagement
87

8+
#else
9+
10+
public typealias PlusFeatureFlag = Int
11+
12+
public struct PlusFeatureFlags {
13+
public let browserTab = 1
14+
public let unlimitedCustomCommands = 1
15+
init() {}
16+
}
17+
18+
#endif
19+
920
public func withFeatureEnabled(
1021
_ flag: KeyPath<PlusFeatureFlags, PlusFeatureFlag>,
1122
then: () throws -> Void
1223
) rethrows {
24+
#if canImport(LicenseManagement)
1325
try LicenseManagement.withFeatureEnabled(flag, then: then)
26+
#endif
1427
}
1528

1629
public func withFeatureEnabled(
1730
_ flag: KeyPath<PlusFeatureFlags, PlusFeatureFlag>,
1831
then: () async throws -> Void
1932
) async rethrows {
33+
#if canImport(LicenseManagement)
2034
try await LicenseManagement.withFeatureEnabled(flag, then: then)
35+
#endif
2136
}
2237

2338
public func isFeatureAvailable(_ flag: KeyPath<PlusFeatureFlags, PlusFeatureFlag>) -> Bool {
24-
LicenseManagement.isFeatureAvailable(flag)
39+
#if canImport(LicenseManagement)
40+
return LicenseManagement.isFeatureAvailable(flag)
41+
#else
42+
return false
43+
#endif
2544
}
2645

27-
#endif

TestPlan.xctestplan

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@
7878
"name" : "ChatServiceTests"
7979
}
8080
},
81-
{
82-
"target" : {
83-
"containerPath" : "container:Core",
84-
"identifier" : "SharedUIComponentsTests",
85-
"name" : "SharedUIComponentsTests"
86-
}
87-
},
8881
{
8982
"target" : {
9083
"containerPath" : "container:Tool",
@@ -105,6 +98,13 @@
10598
"identifier" : "SuggestionModelTests",
10699
"name" : "SuggestionModelTests"
107100
}
101+
},
102+
{
103+
"target" : {
104+
"containerPath" : "container:Tool",
105+
"identifier" : "SharedUIComponentsTests",
106+
"name" : "SharedUIComponentsTests"
107+
}
108108
}
109109
],
110110
"version" : 1

0 commit comments

Comments
 (0)