Skip to content

Commit

Permalink
Pre-release 0.24.77
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 3, 2024
1 parent 6e05e62 commit b883593
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 105 deletions.
2 changes: 2 additions & 0 deletions Copilot for Xcode/App.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Client
import HostApp
import LaunchAgentManager
import SharedUIComponents
import SwiftUI
import UpdateChecker
import XPCShared
Expand All @@ -21,6 +22,7 @@ struct CopilotForXcodeApp: App {
UserDefaults.setupDefaultSettings()
}
.environment(\.updateChecker, UpdateChecker(hostBundle: Bundle.main))
.copilotIntroSheet()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "copilot.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
12 changes: 12 additions & 0 deletions Copilot for Xcode/Assets.xcassets/CopilotLogo.imageset/copilot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Icon.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties": {
"preserves-vector-representation": true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ struct SuggesionSettingProxyView: View {

class Settings: ObservableObject {
@AppStorage("username") var username: String = ""
@AppStorage(\.gitHubCopilotProxyHost) var gitHubCopilotProxyHost
@AppStorage(\.gitHubCopilotProxyPort) var gitHubCopilotProxyPort
@AppStorage(\.gitHubCopilotProxyUrl) var gitHubCopilotProxyUrl
@AppStorage(\.gitHubCopilotProxyUsername) var gitHubCopilotProxyUsername
@AppStorage(\.gitHubCopilotProxyPassword) var gitHubCopilotProxyPassword
@AppStorage(\.gitHubCopilotUseStrictSSL) var gitHubCopilotUseStrictSSL
Expand Down Expand Up @@ -39,13 +38,10 @@ struct SuggesionSettingProxyView: View {

Form {
TextField(
text: $settings.gitHubCopilotProxyHost,
prompt: Text("xxx.xxx.xxx.xxx, leave it blank to disable proxy.")
text: $settings.gitHubCopilotProxyUrl,
prompt: Text("http://host:port")
) {
Text("Proxy host")
}
TextField(text: $settings.gitHubCopilotProxyPort, prompt: Text("80")) {
Text("Proxy port")
Text("Proxy URL")
}
TextField(text: $settings.gitHubCopilotProxyUsername) {
Text("Proxy username")
Expand Down
18 changes: 1 addition & 17 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,6 @@ Requires Node installed and `npm` available on your system path, e.g.
sudo ln -s `which npm` /usr/local/bin
```

## Local Language Server

To run the language server locally create a `Config.local.xcconfig` file with two config values:

```xcconfig
LANGUAGE_SERVER_PATH=~/code/copilot-client
NODE_PATH=/opt/path/to/node
```

`LANGUAGE_SERVER_PATH` should point to the path where the copilot-client repo is
checked out and `$(LANGUAGE_SERVER_PATH)/dist/language-server.js` must exist
(run `npm run build`).

`NODE_PATH` should point to where node is installed. It can be omitted if
`/usr/bin/env node` will resolves directly.

## Targets

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

## App Versioning

The app version and all targets' version in controlled by `Version.xcconfig`.
The app version and all targets' version in controlled by `Version.xcconfig`.
Binary file modified Docs/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# <img align="center" height="70" src="./Docs/AppIcon.png"/> GitHub Copilot For Xcode

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

GitHub Copilot for Xcode is macOS application and Xcode extension that enables
using GitHub Copilot code completions in Xcode.
Expand Down
8 changes: 4 additions & 4 deletions Server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"description": "Package for downloading @github/copilot-language-server",
"private": true,
"dependencies": {
"@github/copilot-language-server": "^1.234.0"
"@github/copilot-language-server": "^1.235.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,72 +49,41 @@ public struct GitHubCopilotCodeSuggestion: Codable, Equatable {
public var displayText: String
}

enum GitHubCopilotRequest {
// TODO migrate from setEditorInfo to didConfigurationChange
struct SetEditorInfo: GitHubCopilotRequestType {
struct Response: Codable {}

let versionNumber = JSONValue(stringLiteral: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "")
let xcodeVersion = JSONValue(stringLiteral: SystemInfo().xcodeVersion() ?? "")

var networkProxy: JSONValue? {
let host = UserDefaults.shared.value(for: \.gitHubCopilotProxyHost)
if host.isEmpty { return nil }
var port = UserDefaults.shared.value(for: \.gitHubCopilotProxyPort)
if port.isEmpty { port = "80" }
let username = UserDefaults.shared.value(for: \.gitHubCopilotProxyUsername)
if username.isEmpty {
return .hash([
"host": .string(host),
"port": .number(Double(Int(port) ?? 80)),
"rejectUnauthorized": .bool(UserDefaults.shared
.value(for: \.gitHubCopilotUseStrictSSL)),
])
} else {
return .hash([
"host": .string(host),
"port": .number(Double(Int(port) ?? 80)),
"rejectUnauthorized": .bool(UserDefaults.shared
.value(for: \.gitHubCopilotUseStrictSSL)),
"username": .string(username),
"password": .string(UserDefaults.shared
.value(for: \.gitHubCopilotProxyPassword)),

])
}
}

var authProvider: JSONValue? {
var dict: [String: JSONValue] = [:]
let enterpriseURI = UserDefaults.shared.value(for: \.gitHubCopilotEnterpriseURI)
if !enterpriseURI.isEmpty {
dict["url"] = .string(enterpriseURI)
}
public func editorConfiguration() -> JSONValue {
var proxyAuthorization: String? {
let username = UserDefaults.shared.value(for: \.gitHubCopilotProxyUsername)
if username.isEmpty { return nil }
let password = UserDefaults.shared.value(for: \.gitHubCopilotProxyPassword)
return "\(username):\(password)"
}

if dict.isEmpty { return nil }
return .hash(dict)
var http: JSONValue? {
var d: [String: JSONValue] = [:]
let proxy = UserDefaults.shared.value(for: \.gitHubCopilotProxyUrl)
if !proxy.isEmpty {
d["proxy"] = .string(proxy)
}

var request: ClientRequest {
var dict: [String: JSONValue] = [
"editorInfo": .hash([
"name": "Xcode",
"version": xcodeVersion,
]),
"editorPluginInfo": .hash([
"name": "copilot-xcode",
"version": versionNumber,
]),
]

dict["authProvider"] = authProvider
dict["networkProxy"] = networkProxy

return .custom("setEditorInfo", .hash(dict))
if let proxyAuthorization = proxyAuthorization {
d["proxyAuthorization"] = .string(proxyAuthorization)
}
d["proxyStrictSSL"] = .bool(UserDefaults.shared.value(for: \.gitHubCopilotUseStrictSSL))
if d.isEmpty { return nil }
return .hash(d)
}

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

var d: [String: JSONValue] = [:]
if let http { d["http"] = http }
if let authProvider { d["github-enterprise"] = authProvider }
return .hash(d)
}

enum GitHubCopilotRequest {
struct GetVersion: GitHubCopilotRequestType {
struct Response: Codable {
var version: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ public class GitHubCopilotBaseService {

return InitializeParams(
processId: Int(ProcessInfo.processInfo.processIdentifier),
clientInfo: .init(
name: "copilot-xcode",
version: "1.5.0.5206-nightly"
),
locale: nil,
rootPath: projectRootURL.path,
rootUri: projectRootURL.path,
Expand All @@ -188,6 +184,7 @@ public class GitHubCopilotBaseService {
"name": "copilot-xcode",
"version": versionNumber,
],
"editorConfiguration": editorConfiguration(),
],
capabilities: capabilities,
trace: .off,
Expand All @@ -207,11 +204,13 @@ public class GitHubCopilotBaseService {
let notifications = NotificationCenter.default
.notifications(named: .gitHubCopilotShouldRefreshEditorInformation)
Task { [weak self] in
_ = try? await server.sendRequest(GitHubCopilotRequest.SetEditorInfo())

for await _ in notifications {
guard self != nil else { return }
_ = try? await server.sendRequest(GitHubCopilotRequest.SetEditorInfo())
_ = try? await server.sendNotification(
.workspaceDidChangeConfiguration(
.init(settings: editorConfiguration())
)
)
}
}
}
Expand Down
23 changes: 16 additions & 7 deletions Tool/Sources/Preferences/Keys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,23 @@ public struct UserDefaultPreferenceKeys {
)

// MARK: Completion Hint Shown

public let completionHintShown = PreferenceKey(
defaultValue: false,
key: "CompletionHintShown"
)

// MARK: First Time Intro Interface

public let introLastShownVersion = PreferenceKey(
defaultValue: "",
key: "IntroLastShownVersion"
)

public let hideIntro = PreferenceKey(
defaultValue: false,
key: "HideIntro"
)
}

// MARK: - Prompt to Code
Expand Down Expand Up @@ -512,13 +525,9 @@ public extension UserDefaultPreferenceKeys {
// MARK: - Feature

public extension UserDefaultPreferenceKeys {

var gitHubCopilotProxyHost: PreferenceKey<String> {
.init(defaultValue: "", key: "GitHubCopilotProxyHost")
}

var gitHubCopilotProxyPort: PreferenceKey<String> {
.init(defaultValue: "", key: "GitHubCopilotProxyPort")

var gitHubCopilotProxyUrl: PreferenceKey<String> {
.init(defaultValue: "", key: "GitHubCopilotProxyUrl")
}

var gitHubCopilotUseStrictSSL: PreferenceKey<Bool> {
Expand Down
Loading

0 comments on commit b883593

Please sign in to comment.