Skip to content

Commit 887f789

Browse files
committed
Pre-release 0.27.93
1 parent 3404070 commit 887f789

File tree

10 files changed

+116
-29
lines changed

10 files changed

+116
-29
lines changed

Core/Sources/HostApp/AdvancedSettings/EnterpriseSection.swift

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,42 @@
1+
import Combine
12
import SwiftUI
3+
import Toast
24

35
struct EnterpriseSection: View {
46
@AppStorage(\.gitHubCopilotEnterpriseURI) var gitHubCopilotEnterpriseURI
7+
@Environment(\.toast) var toast
58

69
var body: some View {
710
SettingsSection(title: "Enterprise") {
811
SettingsTextField(
912
title: "Auth provider URL",
10-
prompt: "Leave it blank if none is available.",
11-
text: $gitHubCopilotEnterpriseURI
13+
prompt: "https://your-enterprise.ghe.com",
14+
text: DebouncedBinding($gitHubCopilotEnterpriseURI, handler: urlChanged).binding
1215
)
1316
}
1417
}
18+
19+
func urlChanged(_ url: String) {
20+
if !url.isEmpty {
21+
validateAuthURL(url)
22+
}
23+
NotificationCenter.default.post(
24+
name: .gitHubCopilotShouldRefreshEditorInformation,
25+
object: nil
26+
)
27+
}
28+
29+
func validateAuthURL(_ url: String) {
30+
let maybeURL = URL(string: url)
31+
guard let parsedURl = maybeURL else {
32+
toast("Invalid URL", .error)
33+
return
34+
}
35+
if parsedURl.scheme != "https" {
36+
toast("URL scheme must be https://", .error)
37+
return
38+
}
39+
}
1540
}
1641

1742
#Preview {

Core/Sources/HostApp/AdvancedSettings/ProxySection.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,30 @@ struct ProxySection: View {
1515
SettingsTextField(
1616
title: "Proxy URL",
1717
prompt: "http://host:port",
18-
text: $gitHubCopilotProxyUrl
18+
text: wrapBinding($gitHubCopilotProxyUrl)
1919
)
2020
SettingsTextField(
2121
title: "Proxy username",
2222
prompt: "username",
23-
text: $gitHubCopilotProxyUsername
23+
text: wrapBinding($gitHubCopilotProxyUsername)
2424
)
2525
SettingsSecureField(
2626
title: "Proxy password",
2727
prompt: "password",
28-
text: $gitHubCopilotProxyPassword
28+
text: wrapBinding($gitHubCopilotProxyPassword)
2929
)
3030
SettingsToggle(
3131
title: "Proxy strict SSL",
32-
isOn: $gitHubCopilotUseStrictSSL
32+
isOn: wrapBinding($gitHubCopilotUseStrictSSL)
3333
)
34-
} footer: {
35-
HStack {
36-
Spacer()
37-
Button("Refresh configurations") {
38-
refreshConfiguration()
39-
}
40-
}
4134
}
4235
}
4336

44-
func refreshConfiguration() {
37+
private func wrapBinding<T>(_ b: Binding<T>) -> Binding<T> {
38+
DebouncedBinding(b, handler: refreshConfiguration).binding
39+
}
40+
41+
func refreshConfiguration(_: Any) {
4542
NotificationCenter.default.post(
4643
name: .gitHubCopilotShouldRefreshEditorInformation,
4744
object: nil

Core/Sources/HostApp/GeneralSettings/CopilotConnectionView.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ struct CopilotConnectionView: View {
66
@Environment(\.toast) var toast
77
@StateObject var viewModel = GitHubCopilotViewModel()
88

9-
@State var waitingForSignIn = false
109
let store: StoreOf<General>
1110

1211
var body: some View {
@@ -24,13 +23,13 @@ struct CopilotConnectionView: View {
2423
title: "GitHub Account Status Permissions",
2524
subtitle: "GitHub Connection: \(viewModel.status?.description ?? "Loading...")"
2625
) {
27-
if viewModel.isRunningAction || waitingForSignIn {
26+
if viewModel.isRunningAction || viewModel.waitingForSignIn {
2827
ProgressView().controlSize(.small)
2928
}
3029
Button("Refresh Connection") {
3130
viewModel.checkStatus()
3231
}
33-
if waitingForSignIn {
32+
if viewModel.waitingForSignIn {
3433
Button("Cancel") {
3534
viewModel.cancelWaiting()
3635
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Combine
2+
import SwiftUI
3+
4+
class DebouncedBinding<T> {
5+
private let subject = PassthroughSubject<T, Never>()
6+
private let cancellable: AnyCancellable
7+
private let wrappedBinding: Binding<T>
8+
9+
init(_ binding: Binding<T>, handler: @escaping (T) -> Void) {
10+
self.wrappedBinding = binding
11+
self.cancellable = subject
12+
.debounce(for: .seconds(1.0), scheduler: RunLoop.main)
13+
.sink { handler($0) }
14+
}
15+
16+
var binding: Binding<T> {
17+
return Binding(
18+
get: { self.wrappedBinding.wrappedValue },
19+
set: {
20+
self.wrappedBinding.wrappedValue = $0
21+
self.subject.send($0)
22+
}
23+
)
24+
}
25+
}

DEVELOPMENT.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ Requires Node installed and `npm` available on your system path, e.g.
66

77
```sh
88
sudo ln -s `which npm` /usr/local/bin
9+
sudo ln -s `which node` /usr/local/bin
910
```
1011

12+
For context, this is used by an Xcode run script as part of the build. Run
13+
scripts use a very limited path to resolve commands.
14+
1115
## Targets
1216

1317
### Copilot for Xcode

ExtensionService/AuthStatusChecker.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class AuthStatusChecker {
1515
Task {
1616
do {
1717
let status = try await self.getCurrentAuthStatus()
18-
DispatchQueue.main.async {
18+
Task { @MainActor in
1919
notify(status.description, status == .ok)
2020
}
2121
} catch {
22-
DispatchQueue.main.async {
22+
Task { @MainActor in
2323
notify("\(error)", false)
2424
}
2525
}

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ Use of the GitHub Copilot Xcode Extension is subject to [GitHub's Pre-Release Te
3535
<img alt="Screenshot of downloaded from the internet warning" src="./Docs/downloaded-from-internet.png" width="372" />
3636
</p>
3737

38-
1. A background item will be added for the application to be able to start itself when Xcode starts.
38+
1. A background item will be added to enable Copilot to start when Xcode is opened.
3939
<p align="center">
4040
<img alt="Screenshot of background item" src="./Docs/background-item.png" width="370" />
4141
</p>
4242

43-
1. Two permissions are required: `Accessibility` and `Xcode Source Editor Extension`.
43+
1. Two permissions are required: `Accessibility` and `Xcode Source Editor
44+
Extension`. For more on why these permissions are required see
45+
[TROUBLESHOOTING.md](./TROUBLESHOOTING.md).
4446

4547
The first time the application is run the `Accessibility` permission should be requested:
4648

@@ -57,7 +59,9 @@ Use of the GitHub Copilot Xcode Extension is subject to [GitHub's Pre-Release Te
5759
<img alt="Screenshot of extension permission" src="./Docs/extension-permission.png" width="582" />
5860
</p>
5961

60-
1. After granting the extension permission, please restart Xcode so the `Github Copilot` menu is available under the Xcode `Editor` menu.
62+
1. After granting the extension permission, please restart Xcode to ensure the
63+
`Github Copilot` menu is available and not disabled under the Xcode `Editor`
64+
menu.
6165
<br>
6266
<p align="center">
6367
<img alt="Screenshot of Xcode Editor GitHub Copilot menu item" src="./Docs/xcode-menu.png" width="648" />
@@ -71,7 +75,16 @@ Use of the GitHub Copilot Xcode Extension is subject to [GitHub's Pre-Release Te
7175
<img alt="Screenshot of sign-in popup" src="./Docs/device-code.png" width="372" />
7276
</p>
7377

74-
1. To install updates, click `Check for Updates` from the menu item or in the settings application. After installing a new version, Xcode must be restarted to use the new version correctly. New versions can also be installed from `dmg` files downloaded from the releases page. When installing a new version via `dmg`, the application must be run manually the first time to accept the downloaded from the internet warning.
78+
1. To install updates, click `Check for Updates` from the menu item or in the
79+
settings application.
80+
81+
After installing a new version, Xcode must be restarted to use the new
82+
version correctly.
83+
84+
New versions can also be installed from `dmg` files downloaded from the
85+
releases page. When installing a new version via `dmg`, the application must
86+
be run manually the first time to accept the downloaded from the internet
87+
warning.
7588

7689
1. To avoid confusion, we recommend disabling `Predictive code completion` under
7790
`Xcode` > `Preferences` > `Text Editing` > `Editing`.

TROUBLESHOOTING.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ common issues:
1515
then Xcode needs to be restarted to enable the extension.
1616

1717
3. Need more help? If these steps don't resolve the issue, please [open an
18-
issue](https://github.com/github/CopilotForXcode/issues/new/choose).
18+
issue](https://github.com/github/CopilotForXcode/issues/new/choose). Make
19+
sure to [include logs](#logs) and any other relevant information.
1920

2021
## Extension Permission
2122

@@ -34,8 +35,33 @@ Or you can navigate to the permission manually depending on your OS version:
3435

3536
## Accessibility Permission
3637

37-
GitHub Copilot for Xcode requires accessibility permission to receive
38-
information from the active Xcode editor.
38+
GitHub Copilot for Xcode requires the accessibility permission to receive
39+
real-time updates from the active Xcode editor. [The XcodeKit
40+
API](https://developer.apple.com/documentation/xcodekit)
41+
enabled by the Xcode Source Editor extension permission only provides
42+
information when manually triggered by the user. In order to generate
43+
suggestions as you type, the accessibility permission is used read the
44+
Xcode editor content in real-time.
45+
46+
The accessibility permission is also used to accept suggestions when `tab` is
47+
pressed.
48+
49+
The accessibility permission is __not__ used to read or write to any
50+
applications besides Xcode. There are no granular options for the permission,
51+
but you can audit the usage in this repository: search for `CGEvent` and `AX`*.
3952

4053
Enable in System Settings under `Privacy & Security` > `Accessibility` >
4154
`GitHub Copilot for Xcode Extension` and turn on the toggle.
55+
56+
## Logs
57+
58+
Logs can be found in `~/Library/Logs/GitHubCopilot/` the most recent log file
59+
is:
60+
61+
```
62+
~/Library/Logs/GitHubCopilot/github-copilot-for-xcode.log
63+
```
64+
65+
To enable verbose logging, open the GitHub Copilot for Xcode settings and enable
66+
`Verbose Logging` in the `Advanced` tab. After enabling verbose logging, restart
67+
Copilot for Xcode for the change to take effect.

Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ public func editorConfiguration() -> JSONValue {
6767
d["proxyAuthorization"] = .string(proxyAuthorization)
6868
}
6969
d["proxyStrictSSL"] = .bool(UserDefaults.shared.value(for: \.gitHubCopilotUseStrictSSL))
70-
if d.isEmpty { return nil }
7170
return .hash(d)
7271
}
7372

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

Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public final class GitHubCopilotService: GitHubCopilotBaseService,
314314
tabSize: tabSize,
315315
insertSpaces: !usesTabsForIndentation
316316
),
317-
context: .init(triggerKind: .automatic)
317+
context: .init(triggerKind: .invoked)
318318
)))
319319
.items
320320
.compactMap { (item: _) -> CodeSuggestion? in

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy