Skip to content

Commit ae0f411

Browse files
committed
Add new request types
1 parent 5475981 commit ae0f411

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,14 @@ enum GitHubCopilotRequest {
135135
}
136136

137137
var request: ClientRequest {
138+
let pretendToBeVSCode = UserDefaults.shared
139+
.value(for: \.gitHubCopilotPretendIDEToBeVSCode)
138140
var dict: [String: JSONValue] = [
139-
"editorInfo": .hash([
140-
"name": "Xcode",
141+
"editorInfo": pretendToBeVSCode ? .hash([
142+
"name": "vscode",
143+
"version": "1.89.1",
144+
]) : .hash([
145+
"name": "xcode",
141146
"version": "",
142147
]),
143148
"editorPluginInfo": .hash([
@@ -348,7 +353,7 @@ enum GitHubCopilotRequest {
348353
var response: String?
349354
}
350355

351-
var capabilities: [Capabilities]; struct Capabilities: Codable {
356+
var capabilities: Capabilities; struct Capabilities: Codable {
352357
var allSkills: Bool?
353358
var skills: [String]
354359
}
@@ -374,9 +379,7 @@ enum GitHubCopilotRequest {
374379
var request: ClientRequest {
375380
let data = (try? JSONEncoder().encode(requestBody)) ?? Data()
376381
let dict = (try? JSONDecoder().decode(JSONValue.self, from: data)) ?? .hash([:])
377-
return .custom("conversation/create", .hash([
378-
"doc": dict,
379-
]))
382+
return .custom("conversation/create", dict)
380383
}
381384
}
382385

@@ -412,12 +415,10 @@ enum GitHubCopilotRequest {
412415
var request: ClientRequest {
413416
let data = (try? JSONEncoder().encode(requestBody)) ?? Data()
414417
let dict = (try? JSONDecoder().decode(JSONValue.self, from: data)) ?? .hash([:])
415-
return .custom("conversation/turn", .hash([
416-
"doc": dict,
417-
]))
418+
return .custom("conversation/turn", dict)
418419
}
419420
}
420-
421+
421422
struct ConversationTurnDelete: GitHubCopilotRequestType {
422423
struct Response: Codable {}
423424

@@ -433,12 +434,10 @@ enum GitHubCopilotRequest {
433434
var request: ClientRequest {
434435
let data = (try? JSONEncoder().encode(requestBody)) ?? Data()
435436
let dict = (try? JSONDecoder().decode(JSONValue.self, from: data)) ?? .hash([:])
436-
return .custom("conversation/turnDelete", .hash([
437-
"doc": dict,
438-
]))
437+
return .custom("conversation/turnDelete", dict)
439438
}
440439
}
441-
440+
442441
struct ConversationDestroy: GitHubCopilotRequestType {
443442
struct Response: Codable {}
444443

Tool/Sources/Preferences/Keys.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ public extension UserDefaultPreferenceKeys {
191191
var gitHubCopilotLoadKeyChainCertificates: PreferenceKey<Bool> {
192192
.init(defaultValue: false, key: "GitHubCopilotLoadKeyChainCertificates")
193193
}
194+
195+
var gitHubCopilotPretendIDEToBeVSCode: PreferenceKey<Bool> {
196+
.init(defaultValue: false, key: "GitHubCopilotPretendIDEToBeVSCode")
197+
}
194198
}
195199

196200
// MARK: - Codeium Settings

0 commit comments

Comments
 (0)