Skip to content

Commit d49345b

Browse files
committed
Merge branch 'release/0.7.0'
2 parents 392e702 + 30c35f0 commit d49345b

File tree

60 files changed

+1421
-598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1421
-598
lines changed

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 198 additions & 167 deletions
Large diffs are not rendered by default.

Copilot for Xcode.xcodeproj/xcshareddata/xcschemes/XPCService.xcscheme

Lines changed: 0 additions & 79 deletions
This file was deleted.

Copilot for Xcode/App.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ struct CopilotForXcodeApp: App {
55
var body: some Scene {
66
WindowGroup {
77
ContentView()
8-
.frame(minWidth: 500, maxWidth: .infinity, minHeight: 700)
8+
.frame(minWidth: 500, minHeight: 700)
9+
.preferredColorScheme(.dark)
910
}
1011
.windowStyle(.hiddenTitleBar)
1112
}

Copilot for Xcode/ContentView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct ContentView: View {
1515
AppInfoView()
1616
LaunchAgentView()
1717
CopilotView()
18+
SettingsView()
1819
InstructionView()
1920
Spacer()
2021
}

Copilot for Xcode/CopilotView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,12 @@ struct CopilotView_Previews: PreviewProvider {
169169
VStack(alignment: .leading, spacing: 8) {
170170
CopilotView(copilotStatus: .notSignedIn, version: "1.0.0", xpcServiceVersion: "0.0.0")
171171

172-
CopilotView(copilotStatus: .alreadySignedIn, message: "Error", xpcServiceVersion: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "")
172+
CopilotView(
173+
copilotStatus: .alreadySignedIn,
174+
message: "Error",
175+
xpcServiceVersion: Bundle.main
176+
.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
177+
)
173178

174179
CopilotView(copilotStatus: .alreadySignedIn, isRunningAction: true)
175180
}

Copilot for Xcode/InstructionView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ Text("Instruction")
1212
Text("Enable Extension")
1313
.font(.title3)
1414
Text("""
15-
1. Install Node.
16-
2. Click `Set Up Launch Agent` to set up an XPC service to run in the background.
15+
1. Install Node. Correctly setup the node path.
16+
2. Launching the app for the first time, it will automatically setup a launch agent.
1717
3. Refresh Copilot status (it may fail the first time).
1818
4. Click `Sign In` to sign into your GitHub account.
1919
5. After submitting your user code to the verification site, click `Confirm Sign-in` to complete the sign-in.
2020
6. Go to `System Settings.app > Privacy & Security > Extensions > Xcode Source Editor` , check the **Copilot** checkbox to enable the extension.
2121
7. Restart Xcode, the Copilot commands should be available in the menu bar.
2222
""")
23-
23+
2424
Text("Granting Permissions")
2525
.font(.title3)
2626
Text("""
27-
The app needs at least **Accessibility API** permissions to work. If you are using real-time suggestions, **Input Monitoring** is also needed.
27+
The app needs at least **Accessibility API** permissions to work. If you are using real-time suggestions, please also enabling **Input Monitoring**..
2828
2929
please visit the [project's GitHub page](https://github.com/intitni/CopilotForXcode#granting-permissions-to-the-app) for instructions.
3030
""")

Copilot for Xcode/LaunchAgentManager.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ extension LaunchAgentManager {
66
self.init(
77
serviceIdentifier: Bundle.main
88
.object(forInfoDictionaryKey: "BUNDLE_IDENTIFIER_BASE") as! String +
9-
".XPCService",
10-
executablePath: Bundle.main.executableURL?.deletingLastPathComponent()
11-
.appendingPathComponent("CopilotForXcodeXPCService").path ?? ""
9+
".ExtensionService",
10+
executablePath: Bundle.main.bundleURL
11+
.appendingPathComponent("Contents")
12+
.appendingPathComponent("Applications")
13+
.appendingPathComponent(
14+
"CopilotForXcodeExtensionService.app/Contents/MacOS/CopilotForXcodeExtensionService"
15+
)
16+
.path
1217
)
1318
}
1419
}

Copilot for Xcode/LaunchAgentView.swift

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct LaunchAgentView: View {
2323
}
2424
}
2525
}) {
26-
Text("Set Up Launch Agent for XPC Service")
26+
Text("Set Up Launch Agent")
2727
}
2828
.alert(isPresented: $isDidSetupLaunchAgentAlertPresented) {
2929
.init(
@@ -57,17 +57,17 @@ struct LaunchAgentView: View {
5757
Button(action: {
5858
Task {
5959
do {
60-
try await LaunchAgentManager().restartLaunchAgent()
60+
try await LaunchAgentManager().reloadLaunchAgent()
6161
isDidRestartLaunchAgentAlertPresented = true
6262
} catch {
6363
errorMessage = error.localizedDescription
6464
}
6565
}
6666
}) {
67-
Text("Restart XPC Service")
67+
Text("Reload Launch Agent")
6868
}.alert(isPresented: $isDidRestartLaunchAgentAlertPresented) {
6969
.init(
70-
title: Text("Launch Agent Restarted"),
70+
title: Text("Launch Agent Reloaded"),
7171
dismissButton: .default(Text("OK"))
7272
)
7373
}
@@ -91,7 +91,21 @@ struct LaunchAgentView: View {
9191
.textFieldStyle(.copilot)
9292
}
9393
}
94-
}.buttonStyle(.copilot)
94+
}
95+
.buttonStyle(.copilot)
96+
.onAppear {
97+
#if DEBUG
98+
// do not auto install on debug build
99+
#else
100+
Task {
101+
do {
102+
try await LaunchAgentManager().setupLaunchAgentForTheFirstTimeIfNeeded()
103+
} catch {
104+
errorMessage = error.localizedDescription
105+
}
106+
}
107+
#endif
108+
}
95109
}
96110
}
97111

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import LaunchAgentManager
2+
import SwiftUI
3+
import XPCShared
4+
5+
struct SettingsView: View {
6+
@AppStorage(SettingsKey.quitXPCServiceOnXcodeAndAppQuit, store: .shared)
7+
var quitXPCServiceOnXcodeAndAppQuit: Bool = false
8+
@AppStorage(SettingsKey.realtimeSuggestionToggle, store: .shared)
9+
var realtimeSuggestionToggle: Bool = false
10+
@AppStorage(SettingsKey.realtimeSuggestionDebounce, store: .shared)
11+
var realtimeSuggestionDebounce: Double = 0.7
12+
@State var editingRealtimeSuggestionDebounce: Double = UserDefaults.shared
13+
.value(forKey: SettingsKey.realtimeSuggestionDebounce) as? Double ?? 0.7
14+
15+
var body: some View {
16+
Section {
17+
Form {
18+
Toggle(isOn: $quitXPCServiceOnXcodeAndAppQuit) {
19+
Text("Quit service when Xcode and host app are terminated")
20+
}
21+
.toggleStyle(.switch)
22+
Toggle(isOn: $realtimeSuggestionToggle) {
23+
Text("Real-time suggestion")
24+
}
25+
.toggleStyle(.switch)
26+
27+
HStack {
28+
Slider(value: $editingRealtimeSuggestionDebounce, in: 0...2, step: 0.1) {
29+
Text("Real-time suggestion fetch debounce")
30+
} onEditingChanged: { _ in
31+
realtimeSuggestionDebounce = editingRealtimeSuggestionDebounce
32+
}
33+
34+
Text(
35+
"\(editingRealtimeSuggestionDebounce.formatted(.number.precision(.fractionLength(2))))s"
36+
)
37+
.font(.body)
38+
.monospacedDigit()
39+
.padding(.vertical, 2)
40+
.padding(.horizontal, 6)
41+
.background(
42+
RoundedRectangle(cornerRadius: 4, style: .continuous)
43+
.fill(Color.white.opacity(0.2))
44+
)
45+
}
46+
}
47+
}.buttonStyle(.copilot)
48+
}
49+
}
50+
51+
struct SettingsView_Preview: PreviewProvider {
52+
static var previews: some View {
53+
SettingsView()
54+
.background(.purple)
55+
}
56+
}

Core/Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ let package = Package(
2020
.package(url: "https://github.com/ChimeHQ/LanguageClient", from: "0.3.1"),
2121
],
2222
targets: [
23+
.target(name: "CGEventObserver"),
2324
.target(
2425
name: "CopilotService",
2526
dependencies: ["LanguageClient", "CopilotModel", "XPCShared"]
@@ -50,7 +51,7 @@ let package = Package(
5051
),
5152
.target(
5253
name: "Service",
53-
dependencies: ["CopilotModel", "CopilotService", "XPCShared"]
54+
dependencies: ["CopilotModel", "CopilotService", "XPCShared", "CGEventObserver"]
5455
),
5556
.target(
5657
name: "XPCShared",

0 commit comments

Comments
 (0)