Skip to content

Commit

Permalink
Release 0.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 26, 2024
1 parent 4a8ae39 commit d0224e8
Show file tree
Hide file tree
Showing 12 changed files with 3,358 additions and 28 deletions.
4 changes: 4 additions & 0 deletions Copilot for Xcode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
3ABBEA2B2C8BA00300C61D61 /* copilot-language-server-arm64 in Resources */ = {isa = PBXBuildFile; fileRef = 3ABBEA2A2C8BA00300C61D61 /* copilot-language-server-arm64 */; };
3ABBEA2C2C8BA00800C61D61 /* copilot-language-server-arm64 in Resources */ = {isa = PBXBuildFile; fileRef = 3ABBEA2A2C8BA00300C61D61 /* copilot-language-server-arm64 */; };
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 */; };
C8009BFF2941C551007AA7E8 /* ToggleRealtimeSuggestionsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8009BFE2941C551007AA7E8 /* ToggleRealtimeSuggestionsCommand.swift */; };
Expand Down Expand Up @@ -185,6 +186,7 @@
/* Begin PBXFileReference section */
3ABBEA282C8B9FE100C61D61 /* copilot-language-server */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = "copilot-language-server"; path = "Server/node_modules/@github/copilot-language-server/native/darwin-x64/copilot-language-server"; sourceTree = SOURCE_ROOT; };
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>"; };
Expand Down Expand Up @@ -379,6 +381,7 @@
C8189B182938972F00C9DCDA /* Copilot for Xcode */ = {
isa = PBXGroup;
children = (
424ACA202CA4697200FA20F2 /* Credits.rtf */,
3ABBEA2A2C8BA00300C61D61 /* copilot-language-server-arm64 */,
3ABBEA282C8B9FE100C61D61 /* copilot-language-server */,
C87B03A3293B24AB00C77EAE /* Copilot-for-Xcode-Info.plist */,
Expand Down Expand Up @@ -655,6 +658,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
424ACA212CA4697200FA20F2 /* Credits.rtf in Resources */,
C8189B212938973000C9DCDA /* Preview Assets.xcassets in Resources */,
C8189B1E2938973000C9DCDA /* Assets.xcassets in Resources */,
3ABBEA292C8B9FE100C61D61 /* copilot-language-server in Resources */,
Expand Down
3,219 changes: 3,219 additions & 0 deletions Copilot for Xcode/Credits.rtf

Large diffs are not rendered by default.

Binary file modified Docs/accessibility-permission.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Docs/dmg-open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Docs/extension-permission.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Docs/xcode-menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,38 @@ As per [GitHub's Terms of Service](https://docs.github.com/en/github/site-policy
Updates can be downloaded and installed by the app.

1. Open the `dmg` and drag the `GitHub Copilot for Xcode.app` into the `Applications` folder.
<br>
<img alt="Screenshot of opened dmg" src="./Docs/dmg-open.png" width="468" />
<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.
<br>
<img alt="Screenshot of downloaded from the internet warning" src="./Docs/downloaded-from-internet.png" width="372" />
<p align="center">
<img alt="Screenshot of downloaded from the internet warning" src="./Docs/downloaded-from-internet.png" width="372" />
</p>

1. A background item will be added for the application to be able to start itself when Xcode starts.
<br>
<img alt="Screenshot of background item" src="./Docs/background-item.png" width="370" />
<p align="center">
<img alt="Screenshot of background item" src="./Docs/background-item.png" width="370" />
</p>

1. Two important permissions are required for the application to operate well: `Accessibility` and `Xcode Source Editor Extension`. The first time the application is run these permissions should be requested. You may need to click `Refresh` in the settings if not prompted.
<br>
<img alt="Screenshot of accessibility permission request" src="./Docs/accessibility-permission-request.png" width="529" />
<img alt="Screenshot of accessibility permission" src="./Docs/accessibility-permission.png" width="827" />
<img alt="Screenshot of extension permission" src="./Docs/extension-permission.png" width="827" />
<p align="center">
<img alt="Screenshot of accessibility permission request" src="./Docs/accessibility-permission-request.png" width="529" />
<img alt="Screenshot of extension permission" src="./Docs/extension-permission.png" width="582" />
</p>

1. After granting the extension permission, please restart Xcode so the `Github Copilot` menu is available under the Xcode `Editor` menu.
<br>
<br>
<img alt="Screenshot of Xcode Editor GitHub Copilot menu item" src="./Docs/xcode-menu.png" width="703" />
<p align="center">
<img alt="Screenshot of Xcode Editor GitHub Copilot menu item" src="./Docs/xcode-menu.png" width="648" />
</p>

1. To sign into GitHub Copilot, click the `Sign in` button in the settings application. This will open a browser window and copy a code to the clipboard. Paste the code into the GitHub login page and authorize the application.
<br>
<img alt="Screenshot of sign-in popup" src="./Docs/device-code.png" width="372" />
<p align="center">
<img alt="Screenshot of sign-in popup" src="./Docs/device-code.png" width="372" />
</p>

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.
<br>
<image alt="Screenshot of update message" src="./Docs/update-message.png" width="372" />

## License

Expand All @@ -67,4 +70,4 @@ forum](https://github.com/orgs/community/discussions/categories/copilot).

## Acknowledgement

Thank you to @intitni for creating the original that this project is based on.
Thank you to @intitni for creating the original that this project is based on.
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.232.0"
"@github/copilot-language-server": "^1.234.0"
}
}
55 changes: 54 additions & 1 deletion Tool/Sources/AXExtension/AXUIElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public extension AXUIElement {
var value: String {
(try? copyValue(key: kAXValueAttribute)) ?? ""
}

var intValue: Int? {
(try? copyValue(key: kAXValueAttribute))
}
Expand Down Expand Up @@ -187,6 +187,16 @@ public extension AXUIElement {
return nil
}

/// Get children that match the requirement
///
/// - important: If the element has a lot of descendant nodes, it will heavily affect the
/// **performance of Xcode**. Please make use ``AXUIElement\traverse(_:)`` instead.
@available(
*,
deprecated,
renamed: "traverse(_:)",
message: "Please make use ``AXUIElement\traverse(_:)`` instead."
)
func children(where match: (AXUIElement) -> Bool) -> [AXUIElement] {
var all = [AXUIElement]()
for child in children {
Expand Down Expand Up @@ -229,6 +239,49 @@ public extension AXUIElement {
}
}

public extension AXUIElement {
enum SearchNextStep {
case skipDescendants
case skipSiblings
case skipDescendantsAndSiblings
case continueSearching
case stopSearching
}
/// Traversing the element tree.
///
/// - important: Traversing the element tree is resource consuming and will affect the
/// **performance of Xcode**. Please make sure to skip as much as possible.
///
/// - todo: Make it not recursive.
func traverse(_ handle: (_ element: AXUIElement, _ level: Int) -> SearchNextStep) {
func _traverse(
element: AXUIElement,
level: Int,
handle: (AXUIElement, Int) -> SearchNextStep
) -> SearchNextStep {
let nextStep = handle(element, level)
switch nextStep {
case .stopSearching: return .stopSearching
case .skipDescendants: return .continueSearching
case .skipDescendantsAndSiblings: return .skipSiblings
case .continueSearching, .skipSiblings:
for child in element.children {
switch _traverse(element: child, level: level + 1, handle: handle) {
case .skipSiblings, .skipDescendantsAndSiblings:
break
case .stopSearching:
return .stopSearching
case .continueSearching, .skipDescendants:
continue
}
}
return nextStep
}
}
_ = _traverse(element: self, level: 0, handle: handle)
}
}

// MARK: - Helper

public extension AXUIElement {
Expand Down
3 changes: 2 additions & 1 deletion Tool/Sources/SharedUIComponents/SyntaxHighlighting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ public enum CodeHighlighting {
func isEmptyLine(_ line: String) -> Bool {
if line.isEmpty { return true }
guard let regex = try? NSRegularExpression(pattern: #"^\s*\n?$"#) else { return false }
let ns = NSString(string: line)
if regex.firstMatch(
in: line,
options: [],
range: NSMakeRange(0, line.utf16.count)
range: NSMakeRange(0, ns.length)
) != nil {
return true
}
Expand Down
58 changes: 54 additions & 4 deletions Tool/Sources/XcodeInspector/Apps/XcodeAppInstanceInspector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,21 @@ extension XcodeAppInstanceInspector {

for window in windows {
let workspaceIdentifier = workspaceIdentifier(window)
var traverseCount = 0

let tabs = {
guard let editArea = window.firstChild(where: { $0.description == "editor area" })
else { return Set<String>() }
var allTabs = Set<String>()
let tabBars = editArea.children { $0.description == "tab bar" }
let tabBars = editArea.tabBars
for tabBar in tabBars {
let tabs = tabBar.children { $0.roleDescription == "tab" }
for tab in tabs {
allTabs.insert(tab.title)
tabBar.traverse { element, _ in
traverseCount += 1
if element.roleDescription == "tab" {
allTabs.insert(element.title)
return .skipDescendants
}
return .continueSearching
}
}
return allTabs
Expand Down Expand Up @@ -398,3 +403,48 @@ extension XcodeAppInstanceInspector {
}
}

public extension AXUIElement {
var tabBars: [AXUIElement] {
// Searching by traversing with AXUIElement is (Xcode) resource consuming, we should skip
// as much as possible!

guard let editArea: AXUIElement = {
if description == "editor area" { return self }
return firstChild(where: { $0.description == "editor area" })
}() else { return [] }

var tabBars = [AXUIElement]()
editArea.traverse { element, _ in
let description = element.description
if description == "Tab Bar" {
element.traverse { element, _ in
if element.description == "tab bar" {
tabBars.append(element)
return .stopSearching
}
return .continueSearching
}
return .skipDescendantsAndSiblings
}

if element.identifier == "editor context" {
return .skipDescendantsAndSiblings
}
if element.isSourceEditor {
return .skipDescendantsAndSiblings
}
if description == "Code Coverage Ribbon" {
return .skipDescendants
}
if description == "Debug Area" {
return .skipDescendants
}

if description == "debug bar" {
return .skipDescendants
}
return .continueSearching
}
return tabBars
}
}

0 comments on commit d0224e8

Please sign in to comment.