Skip to content

Commit a1e0678

Browse files
committed
Merge branch 'release/0.13.4'
2 parents 301b131 + da1b8c5 commit a1e0678

11 files changed

Lines changed: 65 additions & 64 deletions

File tree

Copilot for Xcode/App.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ struct CopilotForXcodeApp: App {
1212
.preferredColorScheme(.dark)
1313
.onAppear {
1414
UserDefaults.setupDefaultSettings()
15-
Task {
16-
let service = try getService()
17-
await service.boostQoS()
18-
}
1915
}
2016
.environment(\.updateChecker, UpdateChecker(hostBundle: Bundle.main))
2117
}

Core/Sources/Client/AsyncXPCService.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ public struct AsyncXPCService {
1111
self.service = service
1212
}
1313

14-
public func boostQoS() async {
15-
let service = connection.remoteObjectProxyWithErrorHandler {
16-
Logger.client.error($0)
17-
} as! XPCServiceProtocol
18-
service.boostQoS {
19-
// never reply
20-
}
21-
}
22-
2314
public func checkStatus() async throws -> CopilotStatus {
2415
try await withXPCServiceConnected(connection: connection) {
2516
service, continuation in

Core/Sources/Preferences/UserDefaults.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ public extension UserDefaults {
1111
shared.setupDefaultValue(for: \.suggestionPresentationMode)
1212
shared.setupDefaultValue(for: \.widgetColorScheme)
1313
shared.setupDefaultValue(for: \.customCommands)
14-
shared.setupDefaultValue(
15-
for: \.runNodeWith,
16-
defaultValue: shared.value(for: \.runNodeWithInteractiveLoggedInShell)
17-
? .bash
18-
: .env
19-
)
14+
let runNodeWith: NodeRunner = shared.value(for: \.runNodeWithInteractiveLoggedInShell)
15+
? .bash
16+
: .env
17+
shared.setupDefaultValue(for: \.runNodeWith, defaultValue: runNodeWith)
2018
}
2119
}
2220

@@ -120,7 +118,7 @@ public extension UserDefaults {
120118
) where K.Value: RawRepresentable, K.Value.RawValue == String {
121119
let key = UserDefaultPreferenceKeys()[keyPath: keyPath]
122120
if value(forKey: key.key) == nil {
123-
set(defaultValue ?? key.defaultValue.rawValue, forKey: key.key)
121+
set(defaultValue?.rawValue ?? key.defaultValue.rawValue, forKey: key.key)
124122
}
125123
}
126124

@@ -130,7 +128,7 @@ public extension UserDefaults {
130128
) where K.Value: RawRepresentable, K.Value.RawValue == Int {
131129
let key = UserDefaultPreferenceKeys()[keyPath: keyPath]
132130
if value(forKey: key.key) == nil {
133-
set(defaultValue ?? key.defaultValue.rawValue, forKey: key.key)
131+
set(defaultValue?.rawValue ?? key.defaultValue.rawValue, forKey: key.key)
134132
}
135133
}
136134
}

Core/Sources/Service/XPCService.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ var workspaces = [URL: Workspace]()
2020
var inflightRealtimeSuggestionsTasks = Set<Task<Void, Never>>()
2121

2222
public class XPCService: NSObject, XPCServiceProtocol {
23-
var boostQoS = [Any]()
24-
25-
public func boostQoS(withReply reply: @escaping () -> Void) {
26-
boostQoS.append(reply)
27-
}
28-
2923
// MARK: - Service
3024

3125
public func getXPCServiceVersion(withReply reply: @escaping (String, String) -> Void) {

Core/Sources/XPCShared/XPCServiceProtocol.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import Foundation
33

44
@objc(XPCServiceProtocol)
55
public protocol XPCServiceProtocol {
6-
func boostQoS(withReply reply: @escaping () -> Void)
76
func checkStatus(withReply reply: @escaping (String?, Error?) -> Void)
87
func signInInitiate(withReply reply: @escaping (String?, String?, Error?) -> Void)
98
func signInConfirm(

EditorExtension/AcceptSuggestionCommand.swift

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ class AcceptSuggestionCommand: NSObject, XCSourceEditorCommand, CommandType {
1313
) {
1414
Task {
1515
do {
16-
let service = try getService()
17-
if let content = try await service.getSuggestionAcceptedCode(
18-
editorContent: .init(invocation)
19-
) {
20-
invocation.accept(content)
21-
}
22-
completionHandler(nil)
16+
try await (Task(timeout: 7) {
17+
let service = try getService()
18+
if let content = try await service.getSuggestionAcceptedCode(
19+
editorContent: .init(invocation)
20+
) {
21+
invocation.accept(content)
22+
}
23+
completionHandler(nil)
24+
}.value)
2325
} catch is CancellationError {
2426
completionHandler(nil)
2527
} catch {
@@ -28,3 +30,33 @@ class AcceptSuggestionCommand: NSObject, XCSourceEditorCommand, CommandType {
2830
}
2931
}
3032
}
33+
34+
/// https://gist.github.com/swhitty/9be89dfe97dbb55c6ef0f916273bbb97
35+
extension Task where Failure == Error {
36+
// Start a new Task with a timeout. If the timeout expires before the operation is
37+
// completed then the task is cancelled and an error is thrown.
38+
init(
39+
priority: TaskPriority? = nil,
40+
timeout: TimeInterval,
41+
operation: @escaping @Sendable () async throws -> Success
42+
) {
43+
self = Task(priority: priority) {
44+
try await withThrowingTaskGroup(of: Success.self) { group -> Success in
45+
group.addTask(operation: operation)
46+
group.addTask {
47+
try await _Concurrency.Task.sleep(nanoseconds: UInt64(timeout * 1_000_000_000))
48+
throw TimeoutError()
49+
}
50+
guard let success = try await group.next() else {
51+
throw _Concurrency.CancellationError()
52+
}
53+
group.cancelAll()
54+
return success
55+
}
56+
}
57+
}
58+
}
59+
60+
private struct TimeoutError: LocalizedError {
61+
var errorDescription: String? = "Task timed out before completion"
62+
}

EditorExtension/ChatWithSelection.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,10 @@ class ChatWithSelectionCommand: NSObject, XCSourceEditorCommand, CommandType {
1010
with invocation: XCSourceEditorCommandInvocation,
1111
completionHandler: @escaping (Error?) -> Void
1212
) {
13+
completionHandler(nil)
1314
Task {
14-
do {
15-
let service = try getService()
16-
if let content = try await service.chatWithSelection(
17-
editorContent: .init(invocation)
18-
) {
19-
invocation.accept(content)
20-
}
21-
completionHandler(nil)
22-
} catch is CancellationError {
23-
completionHandler(nil)
24-
} catch {
25-
completionHandler(error)
26-
}
15+
let service = try getService()
16+
_ = try await service.chatWithSelection(editorContent: .init(invocation))
2717
}
2818
}
2919
}

EditorExtension/PromptToCodeCommand.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,10 @@ class PromptToCodeCommand: NSObject, XCSourceEditorCommand, CommandType {
1010
with invocation: XCSourceEditorCommandInvocation,
1111
completionHandler: @escaping (Error?) -> Void
1212
) {
13+
completionHandler(nil)
1314
Task {
14-
do {
15-
let service = try getService()
16-
if let content = try await service.promptToCode(
17-
editorContent: .init(invocation)
18-
) {
19-
invocation.accept(content)
20-
}
21-
completionHandler(nil)
22-
} catch is CancellationError {
23-
completionHandler(nil)
24-
} catch {
25-
completionHandler(error)
26-
}
15+
let service = try getService()
16+
_ = try await service.promptToCode(editorContent: .init(invocation))
2717
}
2818
}
2919
}

EditorExtension/SourceEditorExtension.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class SourceEditorExtension: NSObject, XCSourceEditorExtension {
3939
try await Task.sleep(nanoseconds: 1_000_000_000)
4040
let service = try getService()
4141
_ = try await service.checkStatus()
42-
await service.boostQoS()
4342
}
4443
#endif
4544
}

Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
APP_VERSION = 0.13.3
2-
APP_BUILD = 108
1+
APP_VERSION = 0.13.4
2+
APP_BUILD = 110

0 commit comments

Comments
 (0)