Skip to content

Commit b883593

Browse files
committed
Pre-release 0.24.77
1 parent 6e05e62 commit b883593

File tree

15 files changed

+222
-105
lines changed

15 files changed

+222
-105
lines changed

Copilot for Xcode/App.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Client
22
import HostApp
33
import LaunchAgentManager
4+
import SharedUIComponents
45
import SwiftUI
56
import UpdateChecker
67
import XPCShared
@@ -21,6 +22,7 @@ struct CopilotForXcodeApp: App {
2122
UserDefaults.setupDefaultSettings()
2223
}
2324
.environment(\.updateChecker, UpdateChecker(hostBundle: Bundle.main))
25+
.copilotIntroSheet()
2426
}
2527
}
2628
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "copilot.svg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
},
12+
"properties" : {
13+
"preserves-vector-representation" : true
14+
}
15+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "Icon.svg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
},
12+
"properties": {
13+
"preserves-vector-representation": true
14+
}
15+
}
Loading

Core/Sources/HostApp/FeatureSettings/Suggestion/SuggesionSettingProxyView.swift

+4-8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ struct SuggesionSettingProxyView: View {
99

1010
class Settings: ObservableObject {
1111
@AppStorage("username") var username: String = ""
12-
@AppStorage(\.gitHubCopilotProxyHost) var gitHubCopilotProxyHost
13-
@AppStorage(\.gitHubCopilotProxyPort) var gitHubCopilotProxyPort
12+
@AppStorage(\.gitHubCopilotProxyUrl) var gitHubCopilotProxyUrl
1413
@AppStorage(\.gitHubCopilotProxyUsername) var gitHubCopilotProxyUsername
1514
@AppStorage(\.gitHubCopilotProxyPassword) var gitHubCopilotProxyPassword
1615
@AppStorage(\.gitHubCopilotUseStrictSSL) var gitHubCopilotUseStrictSSL
@@ -39,13 +38,10 @@ struct SuggesionSettingProxyView: View {
3938

4039
Form {
4140
TextField(
42-
text: $settings.gitHubCopilotProxyHost,
43-
prompt: Text("xxx.xxx.xxx.xxx, leave it blank to disable proxy.")
41+
text: $settings.gitHubCopilotProxyUrl,
42+
prompt: Text("http://host:port")
4443
) {
45-
Text("Proxy host")
46-
}
47-
TextField(text: $settings.gitHubCopilotProxyPort, prompt: Text("80")) {
48-
Text("Proxy port")
44+
Text("Proxy URL")
4945
}
5046
TextField(text: $settings.gitHubCopilotProxyUsername) {
5147
Text("Proxy username")

DEVELOPMENT.md

+1-17
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@ Requires Node installed and `npm` available on your system path, e.g.
88
sudo ln -s `which npm` /usr/local/bin
99
```
1010

11-
## Local Language Server
12-
13-
To run the language server locally create a `Config.local.xcconfig` file with two config values:
14-
15-
```xcconfig
16-
LANGUAGE_SERVER_PATH=~/code/copilot-client
17-
NODE_PATH=/opt/path/to/node
18-
```
19-
20-
`LANGUAGE_SERVER_PATH` should point to the path where the copilot-client repo is
21-
checked out and `$(LANGUAGE_SERVER_PATH)/dist/language-server.js` must exist
22-
(run `npm run build`).
23-
24-
`NODE_PATH` should point to where node is installed. It can be omitted if
25-
`/usr/bin/env node` will resolves directly.
26-
2711
## Targets
2812

2913
### Copilot for Xcode
@@ -79,4 +63,4 @@ The source code mostly follows the [Ray Wenderlich Style Guide](https://github.c
7963

8064
## App Versioning
8165

82-
The app version and all targets' version in controlled by `Version.xcconfig`.
66+
The app version and all targets' version in controlled by `Version.xcconfig`.

Docs/demo.gif

847 KB
Loading

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# <img align="center" height="70" src="./Docs/AppIcon.png"/> GitHub Copilot For Xcode
22

3-
<img alt="Demo of GitHub Copilot for Xcode" src="./Docs/demo.gif" width="577" />
3+
<img alt="Demo of GitHub Copilot for Xcode" src="./Docs/demo.gif" width="800" />
44

55
GitHub Copilot for Xcode is macOS application and Xcode extension that enables
66
using GitHub Copilot code completions in Xcode.

Server/package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"description": "Package for downloading @github/copilot-language-server",
55
"private": true,
66
"dependencies": {
7-
"@github/copilot-language-server": "^1.234.0"
7+
"@github/copilot-language-server": "^1.235.0"
88
}
99
}

Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift

+29-60
Original file line numberDiff line numberDiff line change
@@ -49,72 +49,41 @@ public struct GitHubCopilotCodeSuggestion: Codable, Equatable {
4949
public var displayText: String
5050
}
5151

52-
enum GitHubCopilotRequest {
53-
// TODO migrate from setEditorInfo to didConfigurationChange
54-
struct SetEditorInfo: GitHubCopilotRequestType {
55-
struct Response: Codable {}
56-
57-
let versionNumber = JSONValue(stringLiteral: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "")
58-
let xcodeVersion = JSONValue(stringLiteral: SystemInfo().xcodeVersion() ?? "")
59-
60-
var networkProxy: JSONValue? {
61-
let host = UserDefaults.shared.value(for: \.gitHubCopilotProxyHost)
62-
if host.isEmpty { return nil }
63-
var port = UserDefaults.shared.value(for: \.gitHubCopilotProxyPort)
64-
if port.isEmpty { port = "80" }
65-
let username = UserDefaults.shared.value(for: \.gitHubCopilotProxyUsername)
66-
if username.isEmpty {
67-
return .hash([
68-
"host": .string(host),
69-
"port": .number(Double(Int(port) ?? 80)),
70-
"rejectUnauthorized": .bool(UserDefaults.shared
71-
.value(for: \.gitHubCopilotUseStrictSSL)),
72-
])
73-
} else {
74-
return .hash([
75-
"host": .string(host),
76-
"port": .number(Double(Int(port) ?? 80)),
77-
"rejectUnauthorized": .bool(UserDefaults.shared
78-
.value(for: \.gitHubCopilotUseStrictSSL)),
79-
"username": .string(username),
80-
"password": .string(UserDefaults.shared
81-
.value(for: \.gitHubCopilotProxyPassword)),
82-
83-
])
84-
}
85-
}
86-
87-
var authProvider: JSONValue? {
88-
var dict: [String: JSONValue] = [:]
89-
let enterpriseURI = UserDefaults.shared.value(for: \.gitHubCopilotEnterpriseURI)
90-
if !enterpriseURI.isEmpty {
91-
dict["url"] = .string(enterpriseURI)
92-
}
52+
public func editorConfiguration() -> JSONValue {
53+
var proxyAuthorization: String? {
54+
let username = UserDefaults.shared.value(for: \.gitHubCopilotProxyUsername)
55+
if username.isEmpty { return nil }
56+
let password = UserDefaults.shared.value(for: \.gitHubCopilotProxyPassword)
57+
return "\(username):\(password)"
58+
}
9359

94-
if dict.isEmpty { return nil }
95-
return .hash(dict)
60+
var http: JSONValue? {
61+
var d: [String: JSONValue] = [:]
62+
let proxy = UserDefaults.shared.value(for: \.gitHubCopilotProxyUrl)
63+
if !proxy.isEmpty {
64+
d["proxy"] = .string(proxy)
9665
}
97-
98-
var request: ClientRequest {
99-
var dict: [String: JSONValue] = [
100-
"editorInfo": .hash([
101-
"name": "Xcode",
102-
"version": xcodeVersion,
103-
]),
104-
"editorPluginInfo": .hash([
105-
"name": "copilot-xcode",
106-
"version": versionNumber,
107-
]),
108-
]
109-
110-
dict["authProvider"] = authProvider
111-
dict["networkProxy"] = networkProxy
112-
113-
return .custom("setEditorInfo", .hash(dict))
66+
if let proxyAuthorization = proxyAuthorization {
67+
d["proxyAuthorization"] = .string(proxyAuthorization)
11468
}
69+
d["proxyStrictSSL"] = .bool(UserDefaults.shared.value(for: \.gitHubCopilotUseStrictSSL))
70+
if d.isEmpty { return nil }
71+
return .hash(d)
72+
}
11573

74+
var authProvider: JSONValue? {
75+
let enterpriseURI = UserDefaults.shared.value(for: \.gitHubCopilotEnterpriseURI)
76+
if enterpriseURI.isEmpty { return nil }
77+
return .hash([ "uri": .string(enterpriseURI) ])
11678
}
11779

80+
var d: [String: JSONValue] = [:]
81+
if let http { d["http"] = http }
82+
if let authProvider { d["github-enterprise"] = authProvider }
83+
return .hash(d)
84+
}
85+
86+
enum GitHubCopilotRequest {
11887
struct GetVersion: GitHubCopilotRequestType {
11988
struct Response: Codable {
12089
var version: String

Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotService.swift

+6-7
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ public class GitHubCopilotBaseService {
172172

173173
return InitializeParams(
174174
processId: Int(ProcessInfo.processInfo.processIdentifier),
175-
clientInfo: .init(
176-
name: "copilot-xcode",
177-
version: "1.5.0.5206-nightly"
178-
),
179175
locale: nil,
180176
rootPath: projectRootURL.path,
181177
rootUri: projectRootURL.path,
@@ -188,6 +184,7 @@ public class GitHubCopilotBaseService {
188184
"name": "copilot-xcode",
189185
"version": versionNumber,
190186
],
187+
"editorConfiguration": editorConfiguration(),
191188
],
192189
capabilities: capabilities,
193190
trace: .off,
@@ -207,11 +204,13 @@ public class GitHubCopilotBaseService {
207204
let notifications = NotificationCenter.default
208205
.notifications(named: .gitHubCopilotShouldRefreshEditorInformation)
209206
Task { [weak self] in
210-
_ = try? await server.sendRequest(GitHubCopilotRequest.SetEditorInfo())
211-
212207
for await _ in notifications {
213208
guard self != nil else { return }
214-
_ = try? await server.sendRequest(GitHubCopilotRequest.SetEditorInfo())
209+
_ = try? await server.sendNotification(
210+
.workspaceDidChangeConfiguration(
211+
.init(settings: editorConfiguration())
212+
)
213+
)
215214
}
216215
}
217216
}

Tool/Sources/Preferences/Keys.swift

+16-7
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,23 @@ public struct UserDefaultPreferenceKeys {
9494
)
9595

9696
// MARK: Completion Hint Shown
97+
9798
public let completionHintShown = PreferenceKey(
9899
defaultValue: false,
99100
key: "CompletionHintShown"
100101
)
102+
103+
// MARK: First Time Intro Interface
104+
105+
public let introLastShownVersion = PreferenceKey(
106+
defaultValue: "",
107+
key: "IntroLastShownVersion"
108+
)
109+
110+
public let hideIntro = PreferenceKey(
111+
defaultValue: false,
112+
key: "HideIntro"
113+
)
101114
}
102115

103116
// MARK: - Prompt to Code
@@ -512,13 +525,9 @@ public extension UserDefaultPreferenceKeys {
512525
// MARK: - Feature
513526

514527
public extension UserDefaultPreferenceKeys {
515-
516-
var gitHubCopilotProxyHost: PreferenceKey<String> {
517-
.init(defaultValue: "", key: "GitHubCopilotProxyHost")
518-
}
519-
520-
var gitHubCopilotProxyPort: PreferenceKey<String> {
521-
.init(defaultValue: "", key: "GitHubCopilotProxyPort")
528+
529+
var gitHubCopilotProxyUrl: PreferenceKey<String> {
530+
.init(defaultValue: "", key: "GitHubCopilotProxyUrl")
522531
}
523532

524533
var gitHubCopilotUseStrictSSL: PreferenceKey<Bool> {

0 commit comments

Comments
 (0)