Skip to content

Commit d849234

Browse files
committed
Merge branch 'release/0.8.1'
2 parents 3f04b30 + 82a4252 commit d849234

File tree

10 files changed

+58
-46
lines changed

10 files changed

+58
-46
lines changed

Copilot for Xcode.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
C87F3E62293DD004008523E8 /* Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = C87F3E61293DD004008523E8 /* Styles.swift */; };
4646
C882175A294187E100A22FD3 /* Client in Frameworks */ = {isa = PBXBuildFile; productRef = C8821759294187E100A22FD3 /* Client */; };
4747
C882175C294187EF00A22FD3 /* Client in Frameworks */ = {isa = PBXBuildFile; productRef = C882175B294187EF00A22FD3 /* Client */; };
48-
C8C8B60929AFA35F00034BEE /* CopilotForXcodeExtensionService.app in Embed Service */ = {isa = PBXBuildFile; fileRef = C861E60E2994F6070056CB02 /* CopilotForXcodeExtensionService.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
48+
C8C8B60929AFA35F00034BEE /* CopilotForXcodeExtensionService.app in Embed XPCService */ = {isa = PBXBuildFile; fileRef = C861E60E2994F6070056CB02 /* CopilotForXcodeExtensionService.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
4949
/* End PBXBuildFile section */
5050

5151
/* Begin PBXContainerItemProxy section */
@@ -111,6 +111,7 @@
111111
dstSubfolderSpec = 6;
112112
files = (
113113
C8216B802980378300AD38C7 /* Helper in Embed XPCService */,
114+
C8C8B60929AFA35F00034BEE /* CopilotForXcodeExtensionService.app in Embed XPCService */,
114115
);
115116
name = "Embed XPCService";
116117
runOnlyForDeploymentPostprocessing = 0;
@@ -132,7 +133,6 @@
132133
dstPath = "$(CONTENTS_FOLDER_PATH)/XPCServices";
133134
dstSubfolderSpec = 16;
134135
files = (
135-
C8C8B60929AFA35F00034BEE /* CopilotForXcodeExtensionService.app in Embed Service */,
136136
);
137137
name = "Embed Service";
138138
runOnlyForDeploymentPostprocessing = 0;

Copilot for Xcode/LaunchAgentManager.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension LaunchAgentManager {
99
".ExtensionService",
1010
executablePath: Bundle.main.bundleURL
1111
.appendingPathComponent("Contents")
12-
.appendingPathComponent("XPCServices")
12+
.appendingPathComponent("Applications")
1313
.appendingPathComponent(
1414
"CopilotForXcodeExtensionService.app/Contents/MacOS/CopilotForXcodeExtensionService"
1515
)

Copilot for Xcode/LaunchAgentView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct LaunchAgentView: View {
9797
let workspace = NSWorkspace.shared
9898
let url = Bundle.main.bundleURL
9999
.appendingPathComponent("Contents")
100-
.appendingPathComponent("XPCServices")
100+
.appendingPathComponent("Applications")
101101
.appendingPathComponent("CopilotForXcodeExtensionService.app")
102102
workspace.activateFileViewerSelecting([url])
103103
}

Core/Sources/Environment/Environment.swift

+36-31
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,44 @@ public enum Environment {
4040
}
4141
}
4242

43+
#warning("""
44+
The current version causes an issue in real-time suggestion that when completion panel is own,
45+
the command handler can not find the correct workspace, so we are not using it for now.
46+
""")
4347
public static var fetchCurrentProjectRootURL: (_ fileURL: URL?) async throws
4448
-> URL? = { fileURL in
45-
let appleScript = """
46-
tell application "Xcode"
47-
return path of document of the first window
48-
end tell
49-
"""
50-
51-
let path = (try? await runAppleScript(appleScript)) ?? ""
52-
if !path.isEmpty {
53-
let trimmedNewLine = path.trimmingCharacters(in: .newlines)
54-
var url = URL(fileURLWithPath: trimmedNewLine)
55-
while !FileManager.default.fileIsDirectory(atPath: url.path) ||
56-
!url.pathExtension.isEmpty
57-
{
58-
url = url.deletingLastPathComponent()
59-
}
60-
return url
61-
}
62-
63-
guard var currentURL = fileURL else { return nil }
64-
var firstDirectoryURL: URL?
65-
while currentURL.pathComponents.count > 1 {
66-
defer { currentURL.deleteLastPathComponent() }
67-
guard FileManager.default.fileIsDirectory(atPath: currentURL.path) else { continue }
68-
if firstDirectoryURL == nil { firstDirectoryURL = currentURL }
69-
let gitURL = currentURL.appendingPathComponent(".git")
70-
if FileManager.default.fileIsDirectory(atPath: gitURL.path) {
71-
return currentURL
72-
}
73-
}
74-
75-
return firstDirectoryURL ?? fileURL
49+
return URL(fileURLWithPath: "/")
50+
// let appleScript = """
51+
// tell application "Xcode"
52+
// return path of document of the first window
53+
// end tell
54+
// """
55+
//
56+
// let path = (try? await runAppleScript(appleScript)) ?? ""
57+
// if !path.isEmpty {
58+
// let trimmedNewLine = path.trimmingCharacters(in: .newlines)
59+
// var url = URL(fileURLWithPath: trimmedNewLine)
60+
// while !FileManager.default.fileIsDirectory(atPath: url.path) ||
61+
// !url.pathExtension.isEmpty
62+
// {
63+
// url = url.deletingLastPathComponent()
64+
// }
65+
// return url
66+
// }
67+
//
68+
// guard var currentURL = fileURL else { return nil }
69+
// var firstDirectoryURL: URL?
70+
// while currentURL.pathComponents.count > 1 {
71+
// defer { currentURL.deleteLastPathComponent() }
72+
// guard FileManager.default.fileIsDirectory(atPath: currentURL.path) else { continue }
73+
// if firstDirectoryURL == nil { firstDirectoryURL = currentURL }
74+
// let gitURL = currentURL.appendingPathComponent(".git")
75+
// if FileManager.default.fileIsDirectory(atPath: gitURL.path) {
76+
// return currentURL
77+
// }
78+
// }
79+
//
80+
// return firstDirectoryURL ?? fileURL
7681
}
7782

7883
public static var fetchCurrentFileURL: () async throws -> URL = {

Core/Sources/Service/SuggestionCommandHandler/WindowBaseCommandHandler.swift

+10-4
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,17 @@ struct WindowBaseCommandHandler: SuggestionCommandHandler {
139139
func acceptSuggestion(editor: EditorContent) async throws -> UpdatedContent? {
140140
presenter.markAsProcessing(true)
141141
defer { presenter.markAsProcessing(false) }
142-
Task {
143-
let fileURL = try await Environment.fetchCurrentFileURL()
144-
presenter.discardSuggestion(fileURL: fileURL)
142+
143+
do {
144+
let result = try await CommentBaseCommandHandler().acceptSuggestion(editor: editor)
145+
Task {
146+
let fileURL = try await Environment.fetchCurrentFileURL()
147+
presenter.discardSuggestion(fileURL: fileURL)
148+
}
149+
return result
150+
} catch {
151+
throw error
145152
}
146-
return try await CommentBaseCommandHandler().acceptSuggestion(editor: editor)
147153
}
148154

149155
func presentRealtimeSuggestions(editor: EditorContent) async throws -> UpdatedContent? {

Core/Sources/Service/Workspace.swift

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ extension Workspace {
138138
)
139139

140140
filespace.suggestions = completions
141+
filespace.suggestionIndex = 0
141142

142143
return completions
143144
}

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ Then set it up with the following steps:
6767

6868
The first time the app is open and command run, the extension will ask for the necessary permissions. (except Input Monitoring, you have to enable it manually)
6969

70-
Alternatively, you may manually grant the required permissions by navigating to the `Privacy & Security` tab in the `System Settings.app`. Please note that different permissions must be assigned to different apps.
70+
Alternatively, you may manually grant the required permissions by navigating to the `Privacy & Security` tab in the `System Settings.app`.
7171

7272
- To grant permissions for the Accessibility API, click `Accessibility`, and drag `CopilotForXcodeExtensionService.app` to the list. You can locate the extension app by clicking `Reveal Extension App in Finder` in the host app.
7373

74-
![Accessibility API](/accessibility_api_permision.png)
74+
<img alt="Accessibility API" src="/accessibility_api_permission.png" width="500px">
7575

76-
- To enable Input Monitoring (for real-time suggestions cancellation by pressing esc, arrow keys or clicking the mouse), click `Input Monitoring`, and add `Copilot for Xcode.app` to the list.
76+
- To enable Input Monitoring (for real-time suggestions cancellation by pressing esc, arrow keys or clicking the mouse), click `Input Monitoring`, and drag `CopilotForXcodeExtensionService.app` to the list. You can locate the extension app by clicking `Reveal Extension App in Finder` in the host app.
7777

78-
![Input Monitoring](/input_monitoring_permission.png)
78+
<img alt="Input Monitoring" src="/input_monitoring_permission.png" width="500px">
7979

8080
If you encounter an alert requesting permission that you have previously granted, please remove the permission from the list and add it again to re-grant the necessary permissions.
8181

@@ -95,7 +95,7 @@ brew upgrade --cask copilot-for-xcode
9595

9696
Alternatively, You can download the latest version manually from the latest [release](https://github.com/intitni/CopilotForXcode/releases).
9797

98-
If you are upgrading from a version lower than **0.8.0**, please run `Copilot for Xcode.app` at least once to let it set up the new launch agent for you and re-grant the permissions according to the new rules.
98+
If you are upgrading from a version lower than **0.7.0**, please run `Copilot for Xcode.app` at least once to let it set up the new launch agent for you and re-grant the permissions according to the new rules.
9999

100100
If you want to keep track of the new releases, you can watch the releases of this repo to get notifications about updates.
101101

Version.xcconfig

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
APP_VERSION = 0.8.0
2-
APP_BUILD = 40
1+
APP_VERSION = 0.8.1
2+
APP_BUILD = 41
File renamed without changes.

input_monitoring_permission.png

2.73 KB
Loading

0 commit comments

Comments
 (0)