Skip to content

Commit 9da3656

Browse files
committed
Add advanced settings for debug
1 parent 6a3d377 commit 9da3656

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

Core/Sources/GitHubCopilotService/GitHubCopilotService.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,15 @@ public class GitHubCopilotBaseService {
178178
executableURL: URL,
179179
supportURL: URL
180180
) {
181-
let supportURL = FileManager.default.urls(
181+
guard let supportURL = FileManager.default.urls(
182182
for: .applicationSupportDirectory,
183183
in: .userDomainMask
184-
).first!.appendingPathComponent(
184+
).first?.appendingPathComponent(
185185
Bundle.main
186186
.object(forInfoDictionaryKey: "APPLICATION_SUPPORT_FOLDER") as! String
187-
)
187+
) else {
188+
throw CancellationError()
189+
}
188190

189191
if !FileManager.default.fileExists(atPath: supportURL.path) {
190192
try? FileManager.default

Core/Sources/HostApp/AccountSettings/CopilotView.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ struct CopilotView: View {
2020
@AppStorage(\.gitHubCopilotUseStrictSSL) var gitHubCopilotUseStrictSSL
2121
@AppStorage(\.gitHubCopilotIgnoreTrailingNewLines)
2222
var gitHubCopilotIgnoreTrailingNewLines
23+
@AppStorage(\.disableGitHubCopilotSettingsAutoRefreshOnAppear)
24+
var disableGitHubCopilotSettingsAutoRefreshOnAppear
2325
init() {}
2426
}
2527

2628
class ViewModel: ObservableObject {
2729
let installationManager = GitHubCopilotInstallationManager()
2830

29-
@Published var installationStatus: GitHubCopilotInstallationManager.InstallationStatus
31+
@Published var installationStatus: GitHubCopilotInstallationManager.InstallationStatus?
3032
@Published var installationStep: GitHubCopilotInstallationManager.InstallationStep?
3133

32-
init() {
33-
installationStatus = installationManager.checkInstallation()
34-
}
35-
34+
init() {}
35+
3636
init(
3737
installationStatus: GitHubCopilotInstallationManager.InstallationStatus,
3838
installationStep: GitHubCopilotInstallationManager.InstallationStep?
@@ -172,6 +172,8 @@ struct CopilotView: View {
172172
VStack(alignment: .leading) {
173173
HStack {
174174
switch viewModel.installationStatus {
175+
case .none:
176+
Text("Copilot.Vim Version: Loading..")
175177
case .notInstalled:
176178
Text("Copilot.Vim Version: Not Installed")
177179
installButton
@@ -194,7 +196,10 @@ struct CopilotView: View {
194196
Text("Status: \(status?.description ?? "Loading..")")
195197

196198
HStack(alignment: .center) {
197-
Button("Refresh") { checkStatus() }
199+
Button("Refresh") {
200+
viewModel.refreshInstallationStatus()
201+
checkStatus()
202+
}
198203
if status == .notSignedIn {
199204
Button("Sign In") { signIn() }
200205
.alert(isPresented: $isUserCodeCopiedAlertPresented) {
@@ -261,6 +266,8 @@ struct CopilotView: View {
261266
Spacer()
262267
}.onAppear {
263268
if isPreview { return }
269+
if settings.disableGitHubCopilotSettingsAutoRefreshOnAppear { return }
270+
viewModel.refreshInstallationStatus()
264271
checkStatus()
265272
}.onChange(of: settings.runNodeWith) { _ in
266273
Self.copilotAuthService = nil

Core/Sources/HostApp/DebugView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ final class DebugSettings: ObservableObject {
1212
var alwaysAcceptSuggestionWithAccessibilityAPI
1313
@AppStorage(\.enableXcodeInspectorDebugMenu) var enableXcodeInspectorDebugMenu
1414
@AppStorage(\.disableFunctionCalling) var disableFunctionCalling
15+
@AppStorage(\.disableGitHubCopilotSettingsAutoRefreshOnAppear)
16+
var disableGitHubCopilotSettingsAutoRefreshOnAppear
1517
init() {}
1618
}
1719

@@ -48,6 +50,9 @@ struct DebugSettingsView: View {
4850
Toggle(isOn: $settings.disableFunctionCalling) {
4951
Text("Disable function calling for chat feature")
5052
}
53+
Toggle(isOn: $settings.disableGitHubCopilotSettingsAutoRefreshOnAppear) {
54+
Text("Disable GitHub Copilot settings auto refresh status on appear")
55+
}
5156
}
5257
.padding()
5358
}
@@ -60,3 +65,4 @@ struct DebugSettingsView_Preview: PreviewProvider {
6065
}
6166
}
6267

68+

Tool/Sources/Preferences/Keys.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,5 +413,9 @@ public extension UserDefaultPreferenceKeys {
413413
var disableFunctionCalling: FeatureFlag {
414414
.init(defaultValue: false, key: "FeatureFlag-DisableFunctionCalling")
415415
}
416+
417+
var disableGitHubCopilotSettingsAutoRefreshOnAppear: FeatureFlag {
418+
.init(defaultValue: false, key: "FeatureFlag-DisableGitHubCopilotSettingsAutoRefreshOnAppear")
419+
}
416420
}
417421

0 commit comments

Comments
 (0)