Skip to content

Commit cc577c3

Browse files
committed
Merge branch 'release/0.5.0'
2 parents 3c86c6f + 9e33c98 commit cc577c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+471
-179
lines changed

.swiftformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
--hexliteralcase uppercase
2121
--ifdef no-indent
2222
--importgrouping testable-bottom
23-
--indent 2
23+
--indent 4
2424
--indentcase false
2525
--lifecycle
2626
--linebreaks lf

Config.debug.xcconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
#include "Version.xcconfig"
2+
13
BUNDLE_IDENTIFIER_BASE = dev.com.intii.CopilotForXcode
24
EXTENSION_BUNDLE_NAME = Copilot Dev

Config.xcconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
#include "Version.xcconfig"
2+
13
BUNDLE_IDENTIFIER_BASE = com.intii.CopilotForXcode
24
EXTENSION_BUNDLE_NAME = Copilot

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
C8009BFF2941C551007AA7E8 /* TurnOnRealtimeSuggestionsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8009BFE2941C551007AA7E8 /* TurnOnRealtimeSuggestionsCommand.swift */; };
1111
C8009C012941C56C007AA7E8 /* TurnOffRealtimeSuggestionsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8009C002941C56C007AA7E8 /* TurnOffRealtimeSuggestionsCommand.swift */; };
1212
C8009C032941C576007AA7E8 /* RealtimeSuggestionCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8009C022941C576007AA7E8 /* RealtimeSuggestionCommand.swift */; };
13+
C800DBB1294C624D00B04CAC /* PrefetchSuggestionsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C800DBB0294C624D00B04CAC /* PrefetchSuggestionsCommand.swift */; };
1314
C814588F2939EFDC00135263 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C814588E2939EFDC00135263 /* Cocoa.framework */; };
1415
C81458942939EFDC00135263 /* SourceEditorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81458932939EFDC00135263 /* SourceEditorExtension.swift */; };
1516
C81458962939EFDC00135263 /* GetSuggestionsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81458952939EFDC00135263 /* GetSuggestionsCommand.swift */; };
@@ -129,6 +130,7 @@
129130
C8009BFE2941C551007AA7E8 /* TurnOnRealtimeSuggestionsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnOnRealtimeSuggestionsCommand.swift; sourceTree = "<group>"; };
130131
C8009C002941C56C007AA7E8 /* TurnOffRealtimeSuggestionsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnOffRealtimeSuggestionsCommand.swift; sourceTree = "<group>"; };
131132
C8009C022941C576007AA7E8 /* RealtimeSuggestionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealtimeSuggestionCommand.swift; sourceTree = "<group>"; };
133+
C800DBB0294C624D00B04CAC /* PrefetchSuggestionsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrefetchSuggestionsCommand.swift; sourceTree = "<group>"; };
132134
C814588C2939EFDC00135263 /* Copilot.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = Copilot.appex; sourceTree = BUILT_PRODUCTS_DIR; };
133135
C814588E2939EFDC00135263 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
134136
C81458902939EFDC00135263 /* XcodeKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XcodeKit.framework; path = Library/Frameworks/XcodeKit.framework; sourceTree = DEVELOPER_DIR; };
@@ -148,6 +150,7 @@
148150
C8189B202938973000C9DCDA /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
149151
C8189B222938973000C9DCDA /* Copilot_for_Xcode.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Copilot_for_Xcode.entitlements; sourceTree = "<group>"; };
150152
C8189B282938979000C9DCDA /* Core */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Core; sourceTree = "<group>"; };
153+
C81E867D296FE4420026E908 /* Version.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
151154
C832A47B2940C71D000989F2 /* copilot */ = {isa = PBXFileReference; lastKnownFileType = folder; name = copilot; path = copilot.vim/copilot; sourceTree = "<group>"; };
152155
C83B2B79293D9C8C00C5ACCD /* LaunchAgentManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchAgentManager.swift; sourceTree = "<group>"; };
153156
C83B2B7B293D9FB400C5ACCD /* CopilotView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopilotView.swift; sourceTree = "<group>"; };
@@ -165,6 +168,7 @@
165168
C87B03B3293B393100C77EAE /* ServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceDelegate.swift; sourceTree = "<group>"; };
166169
C87F3E5F293DC600008523E8 /* Section.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Section.swift; sourceTree = "<group>"; };
167170
C87F3E61293DD004008523E8 /* Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styles.swift; sourceTree = "<group>"; };
171+
C887BC832965D96000931567 /* DEVELOPMENT.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = DEVELOPMENT.md; sourceTree = "<group>"; };
168172
/* End PBXFileReference section */
169173

170174
/* Begin PBXFrameworksBuildPhase section */
@@ -219,6 +223,7 @@
219223
C8009BFE2941C551007AA7E8 /* TurnOnRealtimeSuggestionsCommand.swift */,
220224
C8009C002941C56C007AA7E8 /* TurnOffRealtimeSuggestionsCommand.swift */,
221225
C8009C022941C576007AA7E8 /* RealtimeSuggestionCommand.swift */,
226+
C800DBB0294C624D00B04CAC /* PrefetchSuggestionsCommand.swift */,
222227
C81458972939EFDC00135263 /* Info.plist */,
223228
C81458982939EFDC00135263 /* EditorExtension.entitlements */,
224229
);
@@ -241,6 +246,8 @@
241246
children = (
242247
C832A47B2940C71D000989F2 /* copilot */,
243248
C8520308293D805800460097 /* README.md */,
249+
C887BC832965D96000931567 /* DEVELOPMENT.md */,
250+
C81E867D296FE4420026E908 /* Version.xcconfig */,
244251
C81458AD293A009600135263 /* Config.xcconfig */,
245252
C81458AE293A009800135263 /* Config.debug.xcconfig */,
246253
C8189B282938979000C9DCDA /* Core */,
@@ -434,6 +441,7 @@
434441
C87B03AB293B262E00C77EAE /* PreviousSuggestionCommand.swift in Sources */,
435442
C87B03A7293B261900C77EAE /* RejectSuggestionCommand.swift in Sources */,
436443
C8009C032941C576007AA7E8 /* RealtimeSuggestionCommand.swift in Sources */,
444+
C800DBB1294C624D00B04CAC /* PrefetchSuggestionsCommand.swift in Sources */,
437445
C81458962939EFDC00135263 /* GetSuggestionsCommand.swift in Sources */,
438446
);
439447
runOnlyForDeploymentPostprocessing = 0;
@@ -485,7 +493,7 @@
485493
CODE_SIGN_ENTITLEMENTS = EditorExtension/EditorExtension.entitlements;
486494
CODE_SIGN_STYLE = Automatic;
487495
COMBINE_HIDPI_IMAGES = YES;
488-
CURRENT_PROJECT_VERSION = 1;
496+
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
489497
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
490498
ENABLE_HARDENED_RUNTIME = YES;
491499
INFOPLIST_FILE = EditorExtension/Info.plist;
@@ -497,7 +505,7 @@
497505
"@executable_path/../../../../Frameworks",
498506
);
499507
MACOSX_DEPLOYMENT_TARGET = 12.0;
500-
MARKETING_VERSION = 1.0;
508+
MARKETING_VERSION = "$(APP_VERSION)";
501509
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).EditorExtension";
502510
PRODUCT_NAME = Copilot;
503511
SKIP_INSTALL = YES;
@@ -512,7 +520,7 @@
512520
CODE_SIGN_ENTITLEMENTS = EditorExtension/EditorExtension.entitlements;
513521
CODE_SIGN_STYLE = Automatic;
514522
COMBINE_HIDPI_IMAGES = YES;
515-
CURRENT_PROJECT_VERSION = 1;
523+
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
516524
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
517525
ENABLE_HARDENED_RUNTIME = YES;
518526
INFOPLIST_FILE = EditorExtension/Info.plist;
@@ -524,7 +532,7 @@
524532
"@executable_path/../../../../Frameworks",
525533
);
526534
MACOSX_DEPLOYMENT_TARGET = 12.0;
527-
MARKETING_VERSION = 1.0;
535+
MARKETING_VERSION = "$(APP_VERSION)";
528536
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).EditorExtension";
529537
PRODUCT_NAME = Copilot;
530538
SKIP_INSTALL = YES;
@@ -695,7 +703,7 @@
695703
CODE_SIGN_ENTITLEMENTS = "Copilot for Xcode/Copilot_for_Xcode.entitlements";
696704
CODE_SIGN_STYLE = Automatic;
697705
COMBINE_HIDPI_IMAGES = YES;
698-
CURRENT_PROJECT_VERSION = 13;
706+
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
699707
DEVELOPMENT_ASSET_PATHS = "\"Copilot for Xcode/Preview Content\"";
700708
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
701709
ENABLE_HARDENED_RUNTIME = YES;
@@ -709,7 +717,7 @@
709717
"@executable_path/../Frameworks",
710718
);
711719
MACOSX_DEPLOYMENT_TARGET = 12.0;
712-
MARKETING_VERSION = 0.4.0;
720+
MARKETING_VERSION = "$(APP_VERSION)";
713721
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE)";
714722
PRODUCT_MODULE_NAME = Copilot_for_Xcode;
715723
PRODUCT_NAME = "Copilot for Xcode Dev";
@@ -727,7 +735,7 @@
727735
CODE_SIGN_ENTITLEMENTS = "Copilot for Xcode/Copilot_for_Xcode.entitlements";
728736
CODE_SIGN_STYLE = Automatic;
729737
COMBINE_HIDPI_IMAGES = YES;
730-
CURRENT_PROJECT_VERSION = 13;
738+
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
731739
DEVELOPMENT_ASSET_PATHS = "\"Copilot for Xcode/Preview Content\"";
732740
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
733741
ENABLE_HARDENED_RUNTIME = YES;
@@ -741,7 +749,7 @@
741749
"@executable_path/../Frameworks",
742750
);
743751
MACOSX_DEPLOYMENT_TARGET = 12.0;
744-
MARKETING_VERSION = 0.4.0;
752+
MARKETING_VERSION = "$(APP_VERSION)";
745753
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE)";
746754
PRODUCT_NAME = "Copilot for Xcode";
747755
SWIFT_EMIT_LOC_STRINGS = YES;

Copilot for Xcode/App.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SwiftUI
33
@main
44
struct CopilotForXcodeApp: App {
55
var body: some Scene {
6-
return WindowGroup {
6+
WindowGroup {
77
ContentView()
88
.frame(minWidth: 500, maxWidth: .infinity, minHeight: 700)
99
}

Copilot for Xcode/AppInfoView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SwiftUI
22

33
struct AppInfoView: View {
44
@State var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
5-
5+
66
var body: some View {
77
Section {
88
VStack(alignment: .leading) {
@@ -12,7 +12,7 @@ struct AppInfoView: View {
1212
Text(appVersion ?? "")
1313
.font(.footnote)
1414
.foregroundColor(.white.opacity(0.5))
15-
15+
1616
Spacer()
1717
}
1818

Copilot for Xcode/CopilotView.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ struct CopilotView: View {
1212
@State var version: String?
1313
@State var isRunningAction: Bool = false
1414
@State var isUserCodeCopiedAlertPresented = false
15+
@State var xpcServiceVersion: String?
16+
var shouldRestartXPCService: Bool {
17+
xpcServiceVersion != (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String)
18+
}
1519

1620
var body: some View {
1721
Section {
@@ -20,7 +24,8 @@ struct CopilotView: View {
2024
Text("Copilot")
2125
.font(.title)
2226
.padding(.bottom, 12)
23-
Text("Version: \(version ?? "Loading..")")
27+
Text("XPCService Version: \(xpcServiceVersion ?? "Loading..")")
28+
Text("Copilot Version: \(version ?? "Loading..")")
2429
Text("Status: \(copilotStatus?.description ?? "Loading..")")
2530
HStack(alignment: .center) {
2631
Button("Refresh") { checkStatus() }
@@ -29,13 +34,17 @@ struct CopilotView: View {
2934
.alert(isPresented: $isUserCodeCopiedAlertPresented) {
3035
Alert(
3136
title: Text(userCode ?? ""),
32-
message: Text("The user code is pasted into your clipboard, please paste it in the opened website to login.\nAfter that, click \"Confirm Sign-in\" to finish."),
37+
message: Text(
38+
"The user code is pasted into your clipboard, please paste it in the opened website to login.\nAfter that, click \"Confirm Sign-in\" to finish."
39+
),
3340
dismissButton: .default(Text("OK"))
3441
)
3542
}
3643
Button("Confirm Sign-in") { confirmSignIn() }
3744
}
38-
if copilotStatus == .ok || copilotStatus == .alreadySignedIn || copilotStatus == .notAuthorized {
45+
if copilotStatus == .ok || copilotStatus == .alreadySignedIn ||
46+
copilotStatus == .notAuthorized
47+
{
3948
Button("Sign Out") { signOut() }
4049
}
4150
if isRunningAction {
@@ -70,9 +79,12 @@ struct CopilotView: View {
7079
defer { isRunningAction = false }
7180
do {
7281
let service = try getService()
82+
xpcServiceVersion = try await service.getXPCServiceVersion().version
7383
copilotStatus = try await service.checkStatus()
7484
version = try await service.getVersion()
75-
message = nil
85+
message = shouldRestartXPCService
86+
? "Please restart XPC Service to update it to the latest version."
87+
: nil
7688
isRunningAction = false
7789
} catch {
7890
message = error.localizedDescription
@@ -155,9 +167,9 @@ struct ActivityIndicatorView: NSViewRepresentable {
155167
struct CopilotView_Previews: PreviewProvider {
156168
static var previews: some View {
157169
VStack(alignment: .leading, spacing: 8) {
158-
CopilotView(copilotStatus: .notSignedIn, version: "1.0.0")
170+
CopilotView(copilotStatus: .notSignedIn, version: "1.0.0", xpcServiceVersion: "0.0.0")
159171

160-
CopilotView(copilotStatus: .alreadySignedIn, message: "Error")
172+
CopilotView(copilotStatus: .alreadySignedIn, message: "Error", xpcServiceVersion: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "")
161173

162174
CopilotView(copilotStatus: .alreadySignedIn, isRunningAction: true)
163175
}

Copilot for Xcode/InstructionView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct InstructionView: View {
55
Section {
66
HStack {
77
VStack(alignment: .leading, spacing: 8) {
8-
// swiftformat: disable indent
8+
// swiftformat:disable indent
99
Text("Instruction")
1010
.font(.title)
1111
.padding(.bottom, 12)
@@ -28,7 +28,7 @@ Text("""
2828
1. Optionally sign out of GitHub Copilot.
2929
2. Click `Remove Launch Agent`.
3030
""")
31-
// swiftformat: enable indent
31+
// swiftformat:enable indent
3232
Spacer()
3333
}
3434
Spacer()

Copilot for Xcode/LaunchAgentManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct LaunchAgentManager {
5858
launchctl("unload", launchAgentPath)
5959
try FileManager.default.removeItem(atPath: launchAgentPath)
6060
}
61-
61+
6262
func restartLaunchAgent() {
6363
launchctl("unload", launchAgentPath)
6464
launchctl("load", launchAgentPath)

Core/Sources/Client/AsyncXPCService.swift

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import XPCShared
44

55
public struct AsyncXPCService {
66
let connection: NSXPCConnection
7-
7+
88
public init(connection: NSXPCConnection) {
99
self.connection = connection
1010
}
@@ -24,6 +24,15 @@ public struct AsyncXPCService {
2424
}
2525
}
2626
}
27+
28+
public func getXPCServiceVersion() async throws -> (version: String, build: String) {
29+
try await withXPCServiceConnected(connection: connection) {
30+
service, continuation in
31+
service.getXPCServiceVersion { version, build in
32+
continuation.resume((version, build))
33+
}
34+
}
35+
}
2736

2837
public func getVersion() async throws -> String {
2938
try await withXPCServiceConnected(connection: connection) {
@@ -51,7 +60,9 @@ public struct AsyncXPCService {
5160
}
5261
}
5362

54-
public func signInConfirm(userCode: String) async throws -> (username: String, status: CopilotStatus) {
63+
public func signInConfirm(userCode: String) async throws
64+
-> (username: String, status: CopilotStatus)
65+
{
5566
try await withXPCServiceConnected(connection: connection) {
5667
service, continuation in
5768
service.signInConfirm(userCode: userCode) { username, status, error in
@@ -75,7 +86,8 @@ public struct AsyncXPCService {
7586
continuation.reject(error)
7687
return
7788
}
78-
continuation.resume(finishstatus.flatMap(CopilotStatus.init(rawValue:)) ?? .notSignedIn)
89+
continuation
90+
.resume(finishstatus.flatMap(CopilotStatus.init(rawValue:)) ?? .notSignedIn)
7991
}
8092
}
8193
}
@@ -96,31 +108,39 @@ public struct AsyncXPCService {
96108
)
97109
}
98110

99-
public func getPreviousSuggestedCode(editorContent: EditorContent) async throws -> UpdatedContent? {
111+
public func getPreviousSuggestedCode(editorContent: EditorContent) async throws
112+
-> UpdatedContent?
113+
{
100114
try await suggestionRequest(
101115
connection,
102116
editorContent,
103117
{ $0.getPreviousSuggestedCode }
104118
)
105119
}
106120

107-
public func getSuggestionAcceptedCode(editorContent: EditorContent) async throws -> UpdatedContent? {
121+
public func getSuggestionAcceptedCode(editorContent: EditorContent) async throws
122+
-> UpdatedContent?
123+
{
108124
try await suggestionRequest(
109125
connection,
110126
editorContent,
111127
{ $0.getSuggestionAcceptedCode }
112128
)
113129
}
114130

115-
public func getSuggestionRejectedCode(editorContent: EditorContent) async throws -> UpdatedContent? {
131+
public func getSuggestionRejectedCode(editorContent: EditorContent) async throws
132+
-> UpdatedContent?
133+
{
116134
try await suggestionRequest(
117135
connection,
118136
editorContent,
119137
{ $0.getSuggestionRejectedCode }
120138
)
121139
}
122-
123-
public func getRealtimeSuggestedCode(editorContent: EditorContent) async throws -> UpdatedContent? {
140+
141+
public func getRealtimeSuggestedCode(editorContent: EditorContent) async throws
142+
-> UpdatedContent?
143+
{
124144
try await suggestionRequest(
125145
connection,
126146
editorContent,
@@ -129,7 +149,7 @@ public struct AsyncXPCService {
129149
}
130150

131151
public func setAutoSuggestion(enabled: Bool) async throws {
132-
return try await withXPCServiceConnected(connection: connection) {
152+
try await withXPCServiceConnected(connection: connection) {
133153
service, continuation in
134154
service.setAutoSuggestion(enabled: enabled) { error in
135155
if let error {
@@ -138,6 +158,15 @@ public struct AsyncXPCService {
138158
}
139159
continuation.resume(())
140160
}
161+
} as Void
162+
}
163+
164+
public func prefetchRealtimeSuggestions(editorContent: EditorContent) async {
165+
guard let data = try? JSONEncoder().encode(editorContent) else { return }
166+
try? await withXPCServiceConnected(connection: connection) { service, continuation in
167+
service.prefetchRealtimeSuggestions(editorContent: data) {
168+
continuation.resume(())
169+
}
141170
}
142171
}
143172
}

0 commit comments

Comments
 (0)