Skip to content

Commit 079ad69

Browse files
committed
Support refreshing configuration
1 parent 65043e0 commit 079ad69

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

Core/Sources/HostApp/AccountSettings/GitHubCopilotView.swift

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ struct GitHubCopilotView: View {
158158
) {
159159
Text("Path to Node (v18+)")
160160
}
161-
161+
162162
Text(
163163
"Provide the path to the executable if it can't be found by the app, shim executable is not supported"
164164
)
165165
.lineLimit(10)
166166
.foregroundColor(.secondary)
167167
.font(.callout)
168168
.dynamicHeightTextInFormWorkaround()
169-
169+
170170
Picker(selection: $settings.runNodeWith) {
171171
ForEach(NodeRunner.allCases, id: \.rawValue) { runner in
172172
switch runner {
@@ -181,7 +181,7 @@ struct GitHubCopilotView: View {
181181
} label: {
182182
Text("Run Node with")
183183
}
184-
184+
185185
Group {
186186
switch settings.runNodeWith {
187187
case .env:
@@ -258,6 +258,10 @@ struct GitHubCopilotView: View {
258258
}
259259
.opacity(isRunningAction ? 0.8 : 1)
260260
.disabled(isRunningAction)
261+
262+
Button("Refresh Configuration for Enterprise and Proxy") {
263+
refreshConfiguration()
264+
}
261265
}
262266

263267
SettingsDivider("Advanced")
@@ -276,9 +280,9 @@ struct GitHubCopilotView: View {
276280
.dynamicHeightTextInFormWorkaround()
277281
Toggle("Verbose Log", isOn: $settings.gitHubCopilotVerboseLog)
278282
}
279-
283+
280284
SettingsDivider("Enterprise")
281-
285+
282286
Form {
283287
TextField(
284288
text: $settings.gitHubCopilotEnterpriseURI,
@@ -415,6 +419,25 @@ struct GitHubCopilotView: View {
415419
}
416420
}
417421
}
422+
423+
func refreshConfiguration() {
424+
NotificationCenter.default.post(
425+
name: .gitHubCopilotShouldRefreshEditorInformation,
426+
object: nil
427+
)
428+
429+
Task {
430+
let service = try getService()
431+
do {
432+
try await service.postNotification(
433+
name: Notification.Name
434+
.gitHubCopilotShouldRefreshEditorInformation.rawValue
435+
)
436+
} catch {
437+
toast(error.localizedDescription, .error)
438+
}
439+
}
440+
}
418441
}
419442

420443
struct ActivityIndicatorView: NSViewRepresentable {

Pro

Submodule Pro updated from 67da617 to 528831a

Tool/Sources/GitHubCopilotService/GitHubCopilotService.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import AppKit
12
import Foundation
23
import LanguageClient
34
import LanguageServerProtocol
@@ -51,6 +52,11 @@ enum GitHubCopilotError: Error, LocalizedError {
5152
}
5253
}
5354

55+
public extension Notification.Name {
56+
static let gitHubCopilotShouldRefreshEditorInformation = Notification
57+
.Name("com.intii.CopilotForXcode.GitHubCopilotShouldRefreshEditorInformation")
58+
}
59+
5460
public class GitHubCopilotBaseService {
5561
let projectRootURL: URL
5662
var server: GitHubCopilotLSP
@@ -160,8 +166,16 @@ public class GitHubCopilotBaseService {
160166
self.server = server
161167
localProcessServer = localServer
162168

163-
Task {
164-
try await server.sendRequest(GitHubCopilotRequest.SetEditorInfo())
169+
Task { [weak self] in
170+
_ = try? await server.sendRequest(GitHubCopilotRequest.SetEditorInfo())
171+
172+
for await notification in NotificationCenter.default
173+
.notifications(named: .gitHubCopilotShouldRefreshEditorInformation)
174+
{
175+
print("Yes!")
176+
guard let self else { return }
177+
_ = try? await server.sendRequest(GitHubCopilotRequest.SetEditorInfo())
178+
}
165179
}
166180
}
167181

0 commit comments

Comments
 (0)