Skip to content

Commit c92a944

Browse files
committed
Merge branch 'feature/license-management' into develop
2 parents f8c565a + f5f7343 commit c92a944

22 files changed

Lines changed: 439 additions & 240 deletions

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: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +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-
let toast: (Text, ToastType) -> Void
13-
13+
1414
enum Action: Equatable {
1515
case createNewCommand
1616
case editCommand(CustomCommand)
1717
case editCustomCommand(EditCustomCommand.Action)
1818
case deleteCommand(CustomCommand)
1919
}
20-
20+
21+
@Dependency(\.toastController) var toastController
22+
2123
var body: some ReducerProtocol<State, Action> {
2224
Reduce { state, action in
2325
switch action {
@@ -40,10 +42,10 @@ struct CustomCommandFeature: ReducerProtocol {
4042
return .none
4143
case .editCustomCommand:
4244
return .none
43-
4445
}
4546
}.ifLet(\.editCustomCommand, action: /Action.editCustomCommand) {
46-
EditCustomCommand(settings: settings, toast: toast)
47+
EditCustomCommand(settings: settings)
4748
}
4849
}
4950
}
51+

Core/Sources/HostApp/CustomCommandSettings/CustomCommandView.swift

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ extension List {
1717
let customCommandStore = StoreOf<CustomCommandFeature>(
1818
initialState: .init(),
1919
reducer: CustomCommandFeature(
20-
settings: .init(),
21-
toast: { content, type in
22-
Task { @MainActor in
23-
globalToastController.toast(content: content, type: type)
24-
}
25-
}
20+
settings: .init()
2621
)
2722
)
2823

@@ -247,10 +242,7 @@ struct CustomCommandView_Preview: PreviewProvider {
247242
)
248243
)))
249244
),
250-
reducer: CustomCommandFeature(
251-
settings: settings,
252-
toast: { _, _ in }
253-
)
245+
reducer: CustomCommandFeature(settings: settings)
254246
),
255247
settings: settings
256248
)
@@ -286,10 +278,7 @@ struct CustomCommandView_NoEditing_Preview: PreviewProvider {
286278
initialState: .init(
287279
editCustomCommand: nil
288280
),
289-
reducer: CustomCommandFeature(
290-
settings: settings,
291-
toast: { _, _ in }
292-
)
281+
reducer: CustomCommandFeature(settings: settings)
293282
),
294283
settings: settings
295284
)

Core/Sources/HostApp/CustomCommandSettings/EditCustomCommand.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ struct EditCustomCommand: ReducerProtocol {
8484
}
8585

8686
let settings: CustomCommandView.Settings
87-
let toast: (Text, ToastType) -> Void
87+
88+
@Dependency(\.toast) var toast
8889

8990
var body: some ReducerProtocol<State, Action> {
9091
Scope(state: \.sendMessage, action: /Action.sendMessage) {
@@ -109,7 +110,7 @@ struct EditCustomCommand: ReducerProtocol {
109110
switch action {
110111
case .saveCommand:
111112
guard !state.name.isEmpty else {
112-
toast(Text("Command name cannot be empty."), .error)
113+
toast("Command name cannot be empty.", .error)
113114
return .none
114115
}
115116

@@ -154,7 +155,7 @@ struct EditCustomCommand: ReducerProtocol {
154155
if state.isNewCommand {
155156
settings.customCommands.append(newCommand)
156157
state.isNewCommand = false
157-
toast(Text("The command is created."), .info)
158+
toast("The command is created.", .info)
158159
} else {
159160
if let index = settings.customCommands.firstIndex(where: {
160161
$0.id == newCommand.id
@@ -163,7 +164,7 @@ struct EditCustomCommand: ReducerProtocol {
163164
} else {
164165
settings.customCommands.append(newCommand)
165166
}
166-
toast(Text("The command is updated."), .info)
167+
toast("The command is updated.", .info)
167168
}
168169

169170
return .none

Core/Sources/HostApp/CustomCommandSettings/EditCustomCommandView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ struct EditCustomCommandView_Preview: PreviewProvider {
243243
settings: .init(customCommands: .init(
244244
wrappedValue: [],
245245
"CustomCommandView_Preview"
246-
)),
247-
toast: { _, _ in }
246+
))
248247
)
249248
)
250249
)

0 commit comments

Comments
 (0)