Skip to content

Commit f5f7343

Browse files
committed
Add license management view
1 parent 555a2e6 commit f5f7343

File tree

20 files changed

+181
-133
lines changed

20 files changed

+181
-133
lines changed

Copilot for Xcode/App.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ import SwiftUI
55
import UpdateChecker
66
import XPCShared
77

8+
struct VisualEffect: NSViewRepresentable {
9+
func makeNSView(context: Self.Context) -> NSView { return NSVisualEffectView() }
10+
func updateNSView(_ nsView: NSView, context: Context) { }
11+
}
12+
813
@main
914
struct CopilotForXcodeApp: App {
1015
var body: some Scene {
1116
WindowGroup {
1217
TabContainer()
1318
.frame(minWidth: 800, minHeight: 600)
19+
.background(VisualEffect().ignoresSafeArea())
1420
.onAppear {
1521
UserDefaults.setupDefaultSettings()
1622
}

Core/Package.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,29 @@ let package = Package(
117117
"GitHubCopilotService",
118118
"CodeiumService",
119119
"LaunchAgentManager",
120+
.product(name: "Toast", package: "Tool"),
120121
.product(name: "SuggestionModel", package: "Tool"),
121122
.product(name: "MarkdownUI", package: "swift-markdown-ui"),
122123
.product(name: "OpenAIService", package: "Tool"),
123124
.product(name: "Preferences", package: "Tool"),
124125
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
125-
]
126+
].pro([
127+
"ProHostApp",
128+
])
126129
),
127130

128131
// MARK: - XPC Related
129132

130133
.target(
131134
name: "XPCShared",
132-
dependencies: [.product(name: "SuggestionModel", package: "Tool"),]
135+
dependencies: [.product(name: "SuggestionModel", package: "Tool")]
133136
),
134137

135138
// MARK: - Suggestion Service
136139

137140
.target(
138141
name: "SuggestionInjector",
139-
dependencies: [.product(name: "SuggestionModel", package: "Tool"),]
142+
dependencies: [.product(name: "SuggestionModel", package: "Tool")]
140143
),
141144
.testTarget(
142145
name: "SuggestionInjectorTests",

Core/Sources/HostApp/AccountSettings/AzureView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ struct AzureView: View {
5151
.overriding(.init(featureProvider: .azureOpenAI))
5252
)
5353
.sendAndWait(content: "Hello", summary: nil)
54-
toast(Text("ChatGPT replied: \(reply ?? "N/A")"), .info)
54+
toast("ChatGPT replied: \(reply ?? "N/A")", .info)
5555
} catch {
56-
toast(Text(error.localizedDescription), .error)
56+
toast(error.localizedDescription, .error)
5757
}
5858
}
5959
}

Core/Sources/HostApp/AccountSettings/CodeiumView.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct CodeiumView: View {
8989
do {
9090
try await viewModel.install()
9191
} catch {
92-
toast(Text(error.localizedDescription), .error)
92+
toast(error.localizedDescription, .error)
9393
}
9494
}
9595
}) {
@@ -104,7 +104,7 @@ struct CodeiumView: View {
104104
do {
105105
try await viewModel.install()
106106
} catch {
107-
toast(Text(error.localizedDescription), .error)
107+
toast(error.localizedDescription, .error)
108108
}
109109
}
110110
}) {
@@ -158,7 +158,7 @@ struct CodeiumView: View {
158158
do {
159159
try await viewModel.signOut()
160160
} catch {
161-
toast(Text(error.localizedDescription), .error)
161+
toast(error.localizedDescription, .error)
162162
}
163163
}
164164
}) {
@@ -187,13 +187,13 @@ struct CodeiumView: View {
187187
if let step = newValue {
188188
switch step {
189189
case .downloading:
190-
toast(Text("Downloading.."), .info)
190+
toast("Downloading..", .info)
191191
case .uninstalling:
192-
toast(Text("Uninstalling old version.."), .info)
192+
toast("Uninstalling old version..", .info)
193193
case .decompressing:
194-
toast(Text("Decompressing.."), .info)
194+
toast("Decompressing..", .info)
195195
case .done:
196-
toast(Text("Done!"), .info)
196+
toast("Done!", .info)
197197
}
198198
}
199199
}
@@ -249,7 +249,7 @@ struct CodeiumSignInView: View {
249249
isPresented = false
250250
} catch {
251251
isGeneratingKey = false
252-
toast(Text(error.localizedDescription), .error)
252+
toast(error.localizedDescription, .error)
253253
}
254254
}
255255
}) {

Core/Sources/HostApp/AccountSettings/CopilotView.swift

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct CopilotView: View {
105105
do {
106106
try await viewModel.install()
107107
} catch {
108-
toast(Text(error.localizedDescription), .error)
108+
toast(error.localizedDescription, .error)
109109
}
110110
}
111111
}) {
@@ -120,7 +120,7 @@ struct CopilotView: View {
120120
do {
121121
try await viewModel.install()
122122
} catch {
123-
toast(Text(error.localizedDescription), .error)
123+
toast(error.localizedDescription, .error)
124124
}
125125
}
126126
}) {
@@ -270,13 +270,13 @@ struct CopilotView: View {
270270
if let step = newValue {
271271
switch step {
272272
case .downloading:
273-
toast(Text("Downloading.."), .info)
273+
toast("Downloading..", .info)
274274
case .uninstalling:
275-
toast(Text("Uninstalling old version.."), .info)
275+
toast("Uninstalling old version..", .info)
276276
case .decompressing:
277-
toast(Text("Decompressing.."), .info)
277+
toast("Decompressing..", .info)
278278
case .done:
279-
toast(Text("Done!"), .info)
279+
toast("Done!", .info)
280280
checkStatus()
281281
}
282282
}
@@ -295,14 +295,13 @@ struct CopilotView: View {
295295

296296
if status != .ok, status != .notSignedIn {
297297
toast(
298-
Text(
299-
"GitHub Copilot status is not \"ok\". Please check if you have a valid GitHub Copilot subscription."
300-
),
298+
"GitHub Copilot status is not \"ok\". Please check if you have a valid GitHub Copilot subscription.",
299+
301300
.error
302301
)
303302
}
304303
} catch {
305-
toast(Text(error.localizedDescription), .error)
304+
toast(error.localizedDescription, .error)
306305
}
307306
}
308307
}
@@ -316,17 +315,17 @@ struct CopilotView: View {
316315
let (uri, userCode) = try await service.signInInitiate()
317316
self.userCode = userCode
318317
guard let url = URL(string: uri) else {
319-
toast(Text("Verification URI is incorrect."), .error)
318+
toast("Verification URI is incorrect.", .error)
320319
return
321320
}
322321
let pasteboard = NSPasteboard.general
323322
pasteboard.declareTypes([NSPasteboard.PasteboardType.string], owner: nil)
324323
pasteboard.setString(userCode, forType: NSPasteboard.PasteboardType.string)
325-
toast(Text("Usercode \(userCode) already copied!"), .info)
324+
toast("Usercode \(userCode) already copied!", .info)
326325
openURL(url)
327326
isUserCodeCopiedAlertPresented = true
328327
} catch {
329-
toast(Text(error.localizedDescription), .error)
328+
toast(error.localizedDescription, .error)
330329
}
331330
}
332331
}
@@ -338,14 +337,14 @@ struct CopilotView: View {
338337
do {
339338
let service = try getGitHubCopilotAuthService()
340339
guard let userCode else {
341-
toast(Text("Usercode is empty."), .error)
340+
toast("Usercode is empty.", .error)
342341
return
343342
}
344343
let (username, status) = try await service.signInConfirm(userCode: userCode)
345344
self.settings.username = username
346345
self.status = status
347346
} catch {
348-
toast(Text(error.localizedDescription), .error)
347+
toast(error.localizedDescription, .error)
349348
}
350349
}
351350
}
@@ -358,7 +357,7 @@ struct CopilotView: View {
358357
let service = try getGitHubCopilotAuthService()
359358
status = try await service.signOut()
360359
} catch {
361-
toast(Text(error.localizedDescription), .error)
360+
toast(error.localizedDescription, .error)
362361
}
363362
}
364363
}

Core/Sources/HostApp/AccountSettings/OpenAIView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ struct OpenAIView: View {
5656
.overriding(.init(featureProvider: .openAI))
5757
)
5858
.sendAndWait(content: "Hello", summary: nil)
59-
toast(Text("ChatGPT replied: \(reply ?? "N/A")"), .info)
59+
toast("ChatGPT replied: \(reply ?? "N/A")", .info)
6060
} catch {
61-
toast(Text(error.localizedDescription), .error)
61+
toast(error.localizedDescription, .error)
6262
}
6363
}
6464
}.disabled(isTesting)

Core/Sources/HostApp/CustomCommandSettings/CustomCommand.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ import ComposableArchitecture
22
import Foundation
33
import Preferences
44
import SwiftUI
5+
import Toast
56

67
struct CustomCommandFeature: ReducerProtocol {
78
struct State: Equatable {
89
var editCustomCommand: EditCustomCommand.State?
910
}
10-
11+
1112
let settings: CustomCommandView.Settings
12-
13+
1314
enum Action: Equatable {
1415
case createNewCommand
1516
case editCommand(CustomCommand)
1617
case editCustomCommand(EditCustomCommand.Action)
1718
case deleteCommand(CustomCommand)
1819
}
19-
20+
2021
@Dependency(\.toastController) var toastController
21-
22+
2223
var body: some ReducerProtocol<State, Action> {
2324
Reduce { state, action in
2425
switch action {
@@ -41,10 +42,10 @@ struct CustomCommandFeature: ReducerProtocol {
4142
return .none
4243
case .editCustomCommand:
4344
return .none
44-
4545
}
4646
}.ifLet(\.editCustomCommand, action: /Action.editCustomCommand) {
4747
EditCustomCommand(settings: settings)
4848
}
4949
}
5050
}
51+

Core/Sources/HostApp/CustomCommandSettings/EditCustomCommand.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct EditCustomCommand: ReducerProtocol {
8585

8686
let settings: CustomCommandView.Settings
8787

88-
@Dependency(\.toastController) var toastController
88+
@Dependency(\.toast) var toast
8989

9090
var body: some ReducerProtocol<State, Action> {
9191
Scope(state: \.sendMessage, action: /Action.sendMessage) {
@@ -110,10 +110,7 @@ struct EditCustomCommand: ReducerProtocol {
110110
switch action {
111111
case .saveCommand:
112112
guard !state.name.isEmpty else {
113-
toastController.toast(
114-
content: Text("Command name cannot be empty."),
115-
type: .error
116-
)
113+
toast("Command name cannot be empty.", .error)
117114
return .none
118115
}
119116

@@ -158,7 +155,7 @@ struct EditCustomCommand: ReducerProtocol {
158155
if state.isNewCommand {
159156
settings.customCommands.append(newCommand)
160157
state.isNewCommand = false
161-
toastController.toast(content: Text("The command is created."), type: .info)
158+
toast("The command is created.", .info)
162159
} else {
163160
if let index = settings.customCommands.firstIndex(where: {
164161
$0.id == newCommand.id
@@ -167,7 +164,7 @@ struct EditCustomCommand: ReducerProtocol {
167164
} else {
168165
settings.customCommands.append(newCommand)
169166
}
170-
toastController.toast(content: Text("The command is updated."), type: .info)
167+
toast("The command is updated.", .info)
171168
}
172169

173170
return .none

Core/Sources/HostApp/General.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ struct General: ReducerProtocol {
6060
permissionGranted: isAccessibilityPermissionGranted
6161
))
6262
} catch {
63-
toastController.toast(
64-
content: Text(error.localizedDescription),
65-
type: .error
66-
)
63+
toastController.toast(content: error.localizedDescription, type: .error)
6764
await send(.failedReloading)
6865
}
6966
}
@@ -73,7 +70,7 @@ struct General: ReducerProtocol {
7370
state.isAccessibilityPermissionGranted = granted
7471
state.isReloading = false
7572
return .none
76-
73+
7774
case .failedReloading:
7875
state.isReloading = false
7976
return .none

Core/Sources/HostApp/GeneralView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ struct LaunchAgentView: View {
154154
try await LaunchAgentManager().setupLaunchAgent()
155155
isDidSetupLaunchAgentAlertPresented = true
156156
} catch {
157-
toast(Text(error.localizedDescription), .error)
157+
toast(error.localizedDescription, .error)
158158
}
159159
}
160160
}) {
@@ -176,7 +176,7 @@ struct LaunchAgentView: View {
176176
try await LaunchAgentManager().removeLaunchAgent()
177177
isDidRemoveLaunchAgentAlertPresented = true
178178
} catch {
179-
toast(Text(error.localizedDescription), .error)
179+
toast(error.localizedDescription, .error)
180180
}
181181
}
182182
}) {
@@ -195,7 +195,7 @@ struct LaunchAgentView: View {
195195
try await LaunchAgentManager().reloadLaunchAgent()
196196
isDidRestartLaunchAgentAlertPresented = true
197197
} catch {
198-
toast(Text(error.localizedDescription), .error)
198+
toast(error.localizedDescription, .error)
199199
}
200200
}
201201
}) {

0 commit comments

Comments
 (0)