Skip to content

Commit a31256a

Browse files
committed
Merge tag '0.22.0' into develop
2 parents 64728cd + 44f5614 commit a31256a

12 files changed

Lines changed: 91 additions & 22 deletions

File tree

Core/Package.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ let package = Package(
180180
// context collectors
181181
"WebChatContextCollector",
182182
"ActiveDocumentChatContextCollector",
183+
"SystemInfoChatContextCollector",
183184

184185
.product(name: "AppMonitoring", package: "Tool"),
185186
.product(name: "Environment", package: "Tool"),
@@ -346,6 +347,15 @@ let package = Package(
346347
path: "Sources/ChatContextCollectors/WebChatContextCollector"
347348
),
348349

350+
.target(
351+
name: "SystemInfoChatContextCollector",
352+
dependencies: [
353+
"ChatContextCollector",
354+
.product(name: "OpenAIService", package: "Tool"),
355+
],
356+
path: "Sources/ChatContextCollectors/SystemInfoChatContextCollector"
357+
),
358+
349359
.target(
350360
name: "ActiveDocumentChatContextCollector",
351361
dependencies: [
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import ChatContextCollector
2+
import Foundation
3+
import OpenAIService
4+
5+
public final class SystemInfoChatContextCollector: ChatContextCollector {
6+
static let dateFormatter: DateFormatter = {
7+
let formatter = DateFormatter()
8+
formatter.dateFormat = "EEEE, yyyy-MM-dd HH:mm:ssZ"
9+
return formatter
10+
}()
11+
12+
public init() {}
13+
14+
public func generateContext(
15+
history: [ChatMessage],
16+
scopes: Set<String>,
17+
content: String
18+
) -> ChatContext? {
19+
return .init(
20+
systemPrompt: """
21+
Current Time: \(Self.dateFormatter.string(from: Date())) (You can use it to calculate time in another time zone)
22+
""",
23+
functions: []
24+
)
25+
}
26+
}
27+

Core/Sources/ChatService/AllContextCollector.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import ActiveDocumentChatContextCollector
22
import ChatContextCollector
3+
import SystemInfoChatContextCollector
34
import WebChatContextCollector
45

56
let allContextCollectors: [any ChatContextCollector] = [
7+
SystemInfoChatContextCollector(),
68
ActiveDocumentChatContextCollector(),
79
WebChatContextCollector(),
810
]

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+

Pro

Submodule Pro updated from 91df9a2 to 1cbe7ec

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ It looks like there is no way to add default key bindings to commands, but you c
105105

106106
A [recommended setup](https://github.com/intitni/CopilotForXcode/issues/14) that should cause no conflict is
107107

108-
| Command | Key Binding |
109-
| ------------------- | ----------- |
110-
| Accept Suggestions | `⌥}` |
111-
| Reject Suggestion | `⌥{` |
112-
| Next Suggestion | `⌥>` |
113-
| Previous Suggestion | `⌥<` |
114-
| Open Chat | `⌥"` |
115-
| Explain Selection | `⌥\|` |
108+
| Command | Key Binding |
109+
| ------------------- | ------------------------------------------------------ |
110+
| Accept Suggestions | `⌥}` (Or accept with Tab if Plus license is available) |
111+
| Reject Suggestion | `⌥{` |
112+
| Next Suggestion | `⌥>` |
113+
| Previous Suggestion | `⌥<` |
114+
| Open Chat | `⌥"` |
115+
| Explain Selection | `⌥\|` |
116116

117117
Essentially using `⌥⇧` as the "access" key combination for all bindings.
118118

@@ -316,6 +316,7 @@ The currently available Plus features include:
316316
- Unlimited custom commands.
317317

318318
Since the app needs to manage license keys, it will send network request to `https://copilotforxcode-license.intii.com`,
319+
319320
- when you activate the license key
320321
- when you deactivate the license key
321322
- when you open the host app or the service app if a license key is available

Tool/Sources/ActiveApplicationMonitor/ActiveApplicationMonitor.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ public final class ActiveApplicationMonitor {
5050
.init { continuation in
5151
let id = UUID()
5252
Task { @MainActor in
53-
// not sure why,
54-
// but we need to wrap the addContinuation in this task to make it not crash
5553
continuation.onTermination = { _ in
5654
self.removeContinuation(id: id)
5755
}

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)