Skip to content

Commit

Permalink
Pre-release 0.28.95
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 12, 2024
1 parent 8353a90 commit 33b6371
Show file tree
Hide file tree
Showing 32 changed files with 424 additions and 125 deletions.
4 changes: 0 additions & 4 deletions Copilot for Xcode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
3ABBEA2D2C8BA00B00C61D61 /* copilot-language-server in Resources */ = {isa = PBXBuildFile; fileRef = 3ABBEA282C8B9FE100C61D61 /* copilot-language-server */; };
424ACA212CA4697200FA20F2 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 424ACA202CA4697200FA20F2 /* Credits.rtf */; };
427C63282C6E868B000E557C /* OpenSettingsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 427C63272C6E868B000E557C /* OpenSettingsCommand.swift */; };
42888D512C66B10100DEF835 /* AuthStatusChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42888D502C66B10100DEF835 /* AuthStatusChecker.swift */; };
5EC511E32C90CE7400632BAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C8189B1D2938973000C9DCDA /* Assets.xcassets */; };
5EC511E42C90CE9800632BAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C8189B1D2938973000C9DCDA /* Assets.xcassets */; };
5EC511E52C90CFD600632BAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C861E6142994F6080056CB02 /* Assets.xcassets */; };
Expand Down Expand Up @@ -192,7 +191,6 @@
3ABBEA2A2C8BA00300C61D61 /* copilot-language-server-arm64 */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = "copilot-language-server-arm64"; path = "Server/node_modules/@github/copilot-language-server/native/darwin-arm64/copilot-language-server-arm64"; sourceTree = SOURCE_ROOT; };
424ACA202CA4697200FA20F2 /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = "<group>"; };
427C63272C6E868B000E557C /* OpenSettingsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenSettingsCommand.swift; sourceTree = "<group>"; };
42888D502C66B10100DEF835 /* AuthStatusChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthStatusChecker.swift; sourceTree = "<group>"; };
C8009BFE2941C551007AA7E8 /* ToggleRealtimeSuggestionsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleRealtimeSuggestionsCommand.swift; sourceTree = "<group>"; };
C8009C022941C576007AA7E8 /* SyncTextSettingsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncTextSettingsCommand.swift; sourceTree = "<group>"; };
C800DBB0294C624D00B04CAC /* PrefetchSuggestionsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrefetchSuggestionsCommand.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -425,7 +423,6 @@
C81291D52994FE6900196E12 /* Main.storyboard */,
C861E6142994F6080056CB02 /* Assets.xcassets */,
C861E6192994F6080056CB02 /* ExtensionService.entitlements */,
42888D502C66B10100DEF835 /* AuthStatusChecker.swift */,
);
path = ExtensionService;
sourceTree = "<group>";
Expand Down Expand Up @@ -769,7 +766,6 @@
C89E75C32A46FB32000DD64F /* AppDelegate+Menu.swift in Sources */,
C8738B712BE4F8B700609E7F /* XPCController.swift in Sources */,
C861E6202994F63A0056CB02 /* ServiceDelegate.swift in Sources */,
42888D512C66B10100DEF835 /* AuthStatusChecker.swift in Sources */,
C861E6112994F6070056CB02 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
11 changes: 11 additions & 0 deletions Core/Sources/HostApp/GitHubCopilotViewModel.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Foundation
import GitHubCopilotService
import ComposableArchitecture
import Status
import SwiftUI

struct SignInResponse {
Expand Down Expand Up @@ -79,6 +81,7 @@ class GitHubCopilotViewModel: ObservableObject {
do {
let service = try getGitHubCopilotAuthService()
status = try await service.signOut()
broadcastStatusChange()
} catch {
toast(error.localizedDescription, .error)
}
Expand Down Expand Up @@ -118,6 +121,7 @@ class GitHubCopilotViewModel: ObservableObject {
waitingForSignIn = false
self.username = username
self.status = status
broadcastStatusChange()
} catch let error as GitHubCopilotError {
if case .languageServerError(.timeout) = error {
// TODO figure out how to extend the default timeout on a Chime LSP request
Expand All @@ -131,4 +135,11 @@ class GitHubCopilotViewModel: ObservableObject {
}
}
}

func broadcastStatusChange() {
DistributedNotificationCenter.default().post(
name: .authStatusDidChange,
object: nil
)
}
}
1 change: 0 additions & 1 deletion Core/Sources/Service/Service.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public final class Service {
let globalShortcutManager: GlobalShortcutManager
let keyBindingManager: KeyBindingManager
let xcodeThemeController: XcodeThemeController = .init()
public var markAsProcessing: (Bool) -> Void = { _ in }

@Dependency(\.toast) var toast
var cancellable = Set<AnyCancellable>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ struct PresentInWindowSuggestionPresenter {
Task { @MainActor in
let controller = Service.shared.guiController.widgetController
controller.markAsProcessing(isProcessing)
Service.shared.markAsProcessing(isProcessing)
}
}

Expand Down
Binary file removed Docs/downloaded-from-internet.png
Binary file not shown.
23 changes: 5 additions & 18 deletions ExtensionService/AppDelegate+Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ extension AppDelegate {
.init("toggleIgnoreLanguageMenuItem")
}

fileprivate var copilotStatusMenuItemIdentifier: NSUserInterfaceItemIdentifier {
.init("copilotStatusMenuItem")
}

@MainActor
@objc func buildStatusBarMenu() {
let statusBar = NSStatusBar.system
Expand All @@ -52,7 +48,7 @@ extension AppDelegate {
keyEquivalent: ""
)

let openCopilotForXcode = NSMenuItem(
let openCopilotForXcodeItem = NSMenuItem(
title: "Open \(hostAppName) Settings",
action: #selector(openCopilotForXcode),
keyEquivalent: ""
Expand Down Expand Up @@ -97,12 +93,11 @@ extension AppDelegate {
)
toggleIgnoreLanguage.identifier = toggleIgnoreLanguageMenuItemIdentifier;

let copilotStatus = NSMenuItem(
authMenuItem = NSMenuItem(
title: "Copilot Connection: Checking...",
action: nil,
action: #selector(openCopilotForXcode),
keyEquivalent: ""
)
copilotStatus.identifier = copilotStatusMenuItemIdentifier

let openDocs = NSMenuItem(
title: "View Copilot Documentation...",
Expand All @@ -116,13 +111,13 @@ extension AppDelegate {
keyEquivalent: ""
)

statusBarMenu.addItem(openCopilotForXcode)
statusBarMenu.addItem(openCopilotForXcodeItem)
statusBarMenu.addItem(.separator())
statusBarMenu.addItem(checkForUpdate)
statusBarMenu.addItem(toggleCompletions)
statusBarMenu.addItem(toggleIgnoreLanguage)
statusBarMenu.addItem(.separator())
statusBarMenu.addItem(copilotStatus)
statusBarMenu.addItem(authMenuItem)
statusBarMenu.addItem(statusMenuItem)
statusBarMenu.addItem(.separator())
statusBarMenu.addItem(openDocs)
Expand Down Expand Up @@ -165,14 +160,6 @@ extension AppDelegate: NSMenuDelegate {
}
}

statusChecker.updateStatusInBackground(notify: { (status: String, isOk: Bool) in
if let statusItem = menu.items.first(where: { item in
item.identifier == self.copilotStatusMenuItemIdentifier
}) {
statusItem.title = "Copilot Connection: \(isOk ? "Connected" : status)"
}
})

case xcodeInspectorDebugMenuIdentifier:
let inspector = XcodeInspector.shared
menu.items.removeAll()
Expand Down
52 changes: 38 additions & 14 deletions ExtensionService/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
let service = Service.shared
var statusBarItem: NSStatusItem!
var statusMenuItem: NSMenuItem!
var authMenuItem: NSMenuItem!
var xpcController: XPCController?
let updateChecker =
UpdateChecker(
hostBundle: Bundle(url: locateHostBundleURL(url: Bundle.main.bundleURL)),
checkerDelegate: ExtensionUpdateCheckerDelegate()
)
let statusChecker: AuthStatusChecker = AuthStatusChecker()
var xpcExtensionService: XPCExtensionService?
private var cancellables = Set<AnyCancellable>()
private var progressView: NSProgressIndicator?
private var idleIcon = NSImage(named: "MenuBarIcon")

func applicationDidFinishLaunching(_: Notification) {
if ProcessInfo.processInfo.environment["IS_UNIT_TEST"] == "YES" { return }
_ = XcodeInspector.shared
service.markAsProcessing = { [weak self] in
guard let self = self else { return }
self.markAsProcessing($0)
}
service.start()
AXIsProcessTrustedWithOptions([
kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true,
Expand All @@ -63,7 +58,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
buildStatusBarMenu()
watchServiceStatus()
watchAXStatus()
updateStatusBarItem() // set the initial status
watchAuthStatus()
setInitialStatusBarStatus()
}

@objc func quit() {
Expand Down Expand Up @@ -183,16 +179,44 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
}
}

func watchAuthStatus() {
let notifications = DistributedNotificationCenter.default().notifications(named: .authStatusDidChange)
Task { [weak self] in
for await _ in notifications {
guard let self else { return }
await self.forceAuthStatusCheck()
}
}
}

func setInitialStatusBarStatus() {
Task {
let authStatus = await Status.shared.getAuthStatus()
if authStatus == .unknown {
// temporarily kick off a language server instance to prime the initial auth status
await forceAuthStatusCheck()
}
updateStatusBarItem()
}
}

func forceAuthStatusCheck() async {
do {
let service = try GitHubCopilotService()
_ = try await service.checkStatus()
try await service.shutdown()
try await service.exit()
} catch {
Logger.service.error("Failed to read auth status: \(error)")
}
}

func updateStatusBarItem() {
Task { @MainActor in
let status = await Status.shared.getStatus()
let image = if status.system {
NSImage(systemSymbolName: status.icon, accessibilityDescription: nil)
} else {
NSImage(named: status.icon)
}
idleIcon = image
let image = status.icon.nsImage
self.statusBarItem.button?.image = image
self.authMenuItem.title = status.authMessage
if let message = status.message {
// TODO switch to attributedTitle to enable line breaks and color.
self.statusMenuItem.title = message
Expand All @@ -201,6 +225,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
} else {
self.statusMenuItem.isHidden = true
}
self.markAsProcessing(status.inProgress)
}
}

Expand All @@ -209,7 +234,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
// No longer in progress
progressView?.removeFromSuperview()
progressView = nil
statusBarItem.button?.image = idleIcon
return
}
if progressView != nil {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
@@ -1,16 +1,17 @@
{
"images" : [
{
"filename" : "copilot-warning-24.png",
"filename" : "copilot-16.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "copilot-warning-48.png",
"filename" : "copilot-32.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "copilot-48.png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,26 @@
{
"images" : [
{
"filename" : "copilot-16.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "copilot-32.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "copilot-48.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
41 changes: 0 additions & 41 deletions ExtensionService/AuthStatusChecker.swift

This file was deleted.

16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ Use of the GitHub Copilot Xcode Extension is subject to [GitHub's Pre-Release Te

## Getting Started

1. Download the `dmg` from
1. Install via [Homebrew](https://brew.sh/):

```sh
brew install --cask github-copilot-for-xcode
```

Or download the `dmg` from
[the latest release](https://github.com/github/CopilotForXcode/releases/latest/download/GitHubCopilotForXcode.dmg).
Updates can be downloaded and installed by the app.
Drag `GitHub Copilot for Xcode` into the `Applications` folder:

1. Open the `dmg` and drag the `GitHub Copilot for Xcode.app` into the `Applications` folder.
<p align="center">
<img alt="Screenshot of opened dmg" src="./Docs/dmg-open.png" width="512" />
</p>

1. On the first opening the application it will warn that it was downloaded from the internet. Click `Open` to proceed.
<p align="center">
<img alt="Screenshot of downloaded from the internet warning" src="./Docs/downloaded-from-internet.png" width="372" />
</p>
Updates can be downloaded and installed by the app.

1. A background item will be added to enable Copilot to start when Xcode is opened.
<p align="center">
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.243.0"
"@github/copilot-language-server": "^1.245.0"
}
}
Loading

0 comments on commit 33b6371

Please sign in to comment.