Skip to content

Commit f359dc7

Browse files
committed
Merge branch 'release/0.9.0'
2 parents 047815c + dae6f1f commit f359dc7

File tree

69 files changed

+2804
-499
lines changed

Some content is hidden

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

69 files changed

+2804
-499
lines changed

Config.debug.xcconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "Version.xcconfig"
2+
SLASH = /
23

34
BUNDLE_IDENTIFIER_BASE = dev.com.intii.CopilotForXcode
45
EXTENSION_BUNDLE_NAME = Copilot Dev
6+
SPARKLE_FEED_URL = http:$(SLASH)$(SLASH)127.0.0.1:9433/appcast.xml
7+
SPARKLE_PUBLIC_KEY = WDzm5GHnc6c8kjeJEgX5GuGiPpW6Lc/ovGjLnrrZvPY=

Config.xcconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "Version.xcconfig"
2+
SLASH = /
23

34
BUNDLE_IDENTIFIER_BASE = com.intii.CopilotForXcode
45
EXTENSION_BUNDLE_NAME = Copilot
6+
SPARKLE_FEED_URL = https:$(SLASH)$(SLASH)raw.githubusercontent.com/intitni/CopilotForXcode/main/appcast.xml
7+
SPARKLE_PUBLIC_KEY = WDzm5GHnc6c8kjeJEgX5GuGiPpW6Lc/ovGjLnrrZvPY=

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
C83B2B82293DC38400C5ACCD /* LaunchAgentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83B2B81293DC38400C5ACCD /* LaunchAgentView.swift */; };
3232
C841BB242994CAD400B0B336 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C841BB232994CAD400B0B336 /* SettingsView.swift */; };
3333
C8520301293C4D9000460097 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8520300293C4D9000460097 /* Helpers.swift */; };
34+
C85AF32D29CF0C170031E18B /* DebugView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85AF32C29CF0C170031E18B /* DebugView.swift */; };
3435
C861E6112994F6070056CB02 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C861E6102994F6070056CB02 /* AppDelegate.swift */; };
3536
C861E6152994F6080056CB02 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C861E6142994F6080056CB02 /* Assets.xcassets */; };
3637
C861E61E2994F6150056CB02 /* Service in Frameworks */ = {isa = PBXBuildFile; productRef = C861E61D2994F6150056CB02 /* Service */; };
@@ -46,6 +47,10 @@
4647
C882175A294187E100A22FD3 /* Client in Frameworks */ = {isa = PBXBuildFile; productRef = C8821759294187E100A22FD3 /* Client */; };
4748
C882175C294187EF00A22FD3 /* Client in Frameworks */ = {isa = PBXBuildFile; productRef = C882175B294187EF00A22FD3 /* Client */; };
4849
C8C8B60929AFA35F00034BEE /* CopilotForXcodeExtensionService.app in Embed XPCService */ = {isa = PBXBuildFile; fileRef = C861E60E2994F6070056CB02 /* CopilotForXcodeExtensionService.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
50+
C8DCF00029CE11D500FDDDD7 /* ChatWithSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */; };
51+
C8EE079D29CC21300043B6D9 /* AccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8EE079C29CC21300043B6D9 /* AccountView.swift */; };
52+
C8EE079F29CC25C20043B6D9 /* OpenAIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8EE079E29CC25C20043B6D9 /* OpenAIView.swift */; };
53+
C8EE07A129CC9ED30043B6D9 /* ExplainSelectionCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8EE07A029CC9ED30043B6D9 /* ExplainSelectionCommand.swift */; };
4954
/* End PBXBuildFile section */
5055

5156
/* Begin PBXContainerItemProxy section */
@@ -174,6 +179,7 @@
174179
C841BB232994CAD400B0B336 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
175180
C8520300293C4D9000460097 /* Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = "<group>"; };
176181
C8520308293D805800460097 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
182+
C85AF32C29CF0C170031E18B /* DebugView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugView.swift; sourceTree = "<group>"; };
177183
C861E60E2994F6070056CB02 /* CopilotForXcodeExtensionService.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CopilotForXcodeExtensionService.app; sourceTree = BUILT_PRODUCTS_DIR; };
178184
C861E6102994F6070056CB02 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
179185
C861E6142994F6080056CB02 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -188,6 +194,10 @@
188194
C87F3E61293DD004008523E8 /* Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styles.swift; sourceTree = "<group>"; };
189195
C887BC832965D96000931567 /* DEVELOPMENT.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = DEVELOPMENT.md; sourceTree = "<group>"; };
190196
C8CD828229B88006008D044D /* TestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestPlan.xctestplan; sourceTree = "<group>"; };
197+
C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatWithSelection.swift; sourceTree = "<group>"; };
198+
C8EE079C29CC21300043B6D9 /* AccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountView.swift; sourceTree = "<group>"; };
199+
C8EE079E29CC25C20043B6D9 /* OpenAIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenAIView.swift; sourceTree = "<group>"; };
200+
C8EE07A029CC9ED30043B6D9 /* ExplainSelectionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExplainSelectionCommand.swift; sourceTree = "<group>"; };
191201
/* End PBXFileReference section */
192202

193203
/* Begin PBXFrameworksBuildPhase section */
@@ -250,6 +260,8 @@
250260
C8009BFE2941C551007AA7E8 /* ToggleRealtimeSuggestionsCommand.swift */,
251261
C8009C022941C576007AA7E8 /* RealtimeSuggestionCommand.swift */,
252262
C800DBB0294C624D00B04CAC /* PrefetchSuggestionsCommand.swift */,
263+
C8EE07A029CC9ED30043B6D9 /* ExplainSelectionCommand.swift */,
264+
C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */,
253265
C81458972939EFDC00135263 /* Info.plist */,
254266
C81458982939EFDC00135263 /* EditorExtension.entitlements */,
255267
);
@@ -298,8 +310,11 @@
298310
C83B2B81293DC38400C5ACCD /* LaunchAgentView.swift */,
299311
C83B2B7B293D9FB400C5ACCD /* CopilotView.swift */,
300312
C83B2B7D293DA0CA00C5ACCD /* AppInfoView.swift */,
313+
C8EE079C29CC21300043B6D9 /* AccountView.swift */,
314+
C8EE079E29CC25C20043B6D9 /* OpenAIView.swift */,
301315
C83B2B7F293DA1B600C5ACCD /* InstructionView.swift */,
302316
C841BB232994CAD400B0B336 /* SettingsView.swift */,
317+
C85AF32C29CF0C170031E18B /* DebugView.swift */,
303318
C87F3E61293DD004008523E8 /* Styles.swift */,
304319
C8189B1D2938973000C9DCDA /* Assets.xcassets */,
305320
C8189B222938973000C9DCDA /* Copilot_for_Xcode.entitlements */,
@@ -510,13 +525,15 @@
510525
isa = PBXSourcesBuildPhase;
511526
buildActionMask = 2147483647;
512527
files = (
528+
C8DCF00029CE11D500FDDDD7 /* ChatWithSelection.swift in Sources */,
513529
C81458942939EFDC00135263 /* SourceEditorExtension.swift in Sources */,
514530
C8520301293C4D9000460097 /* Helpers.swift in Sources */,
515531
C8009BFF2941C551007AA7E8 /* ToggleRealtimeSuggestionsCommand.swift in Sources */,
516532
C87B03A5293B261200C77EAE /* AcceptSuggestionCommand.swift in Sources */,
517533
C87B03A9293B262600C77EAE /* NextSuggestionCommand.swift in Sources */,
518534
C87B03AB293B262E00C77EAE /* PreviousSuggestionCommand.swift in Sources */,
519535
C87B03A7293B261900C77EAE /* RejectSuggestionCommand.swift in Sources */,
536+
C8EE07A129CC9ED30043B6D9 /* ExplainSelectionCommand.swift in Sources */,
520537
C8009C032941C576007AA7E8 /* RealtimeSuggestionCommand.swift in Sources */,
521538
C800DBB1294C624D00B04CAC /* PrefetchSuggestionsCommand.swift in Sources */,
522539
C81458962939EFDC00135263 /* GetSuggestionsCommand.swift in Sources */,
@@ -531,10 +548,13 @@
531548
C87F3E60293DC600008523E8 /* Section.swift in Sources */,
532549
C87F3E62293DD004008523E8 /* Styles.swift in Sources */,
533550
C83B2B82293DC38400C5ACCD /* LaunchAgentView.swift in Sources */,
551+
C8EE079D29CC21300043B6D9 /* AccountView.swift in Sources */,
534552
C83B2B7E293DA0CA00C5ACCD /* AppInfoView.swift in Sources */,
553+
C8EE079F29CC25C20043B6D9 /* OpenAIView.swift in Sources */,
535554
C841BB242994CAD400B0B336 /* SettingsView.swift in Sources */,
536555
C83B2B80293DA1B600C5ACCD /* InstructionView.swift in Sources */,
537556
C83B2B7C293D9FB400C5ACCD /* CopilotView.swift in Sources */,
557+
C85AF32D29CF0C170031E18B /* DebugView.swift in Sources */,
538558
C83B2B7A293D9C8C00C5ACCD /* LaunchAgentManager.swift in Sources */,
539559
C8189B1A2938972F00C9DCDA /* App.swift in Sources */,
540560
);

Copilot for Xcode.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import AppKit
2+
import Client
3+
import CopilotModel
4+
import SwiftUI
5+
6+
struct AccountView: View {
7+
enum Location {
8+
case account
9+
case gitHubCopilot
10+
case openAI
11+
}
12+
13+
@State var location: Location = .account
14+
15+
func navigate(to: Location) {
16+
withAnimation(.easeInOut(duration: 0.2)) {
17+
location = to
18+
}
19+
}
20+
21+
var body: some View {
22+
Section {
23+
switch location {
24+
case .account:
25+
VStack(alignment: .leading, spacing: 8) {
26+
Text("Accounts")
27+
.font(.title)
28+
.padding(.bottom, 12)
29+
30+
HStack {
31+
Button {
32+
navigate(to: .gitHubCopilot)
33+
} label: {
34+
Text("GitHub Copilot")
35+
}.buttonStyle(CopilotButtonStyle())
36+
37+
Button {
38+
navigate(to: .openAI)
39+
} label: {
40+
Text("OpenAI")
41+
}.buttonStyle(CopilotButtonStyle())
42+
43+
Spacer()
44+
}
45+
}
46+
case .gitHubCopilot:
47+
ChildPage(content: {
48+
CopilotView()
49+
}, onBackButtonClick: {
50+
navigate(to: .account)
51+
})
52+
case .openAI:
53+
ChildPage(content: {
54+
OpenAIView()
55+
}, onBackButtonClick: {
56+
navigate(to: .account)
57+
})
58+
}
59+
}
60+
}
61+
62+
struct ChildPage<V: View>: View {
63+
var content: () -> V
64+
var onBackButtonClick: () -> Void
65+
var body: some View {
66+
VStack(alignment: .leading) {
67+
Button(action: onBackButtonClick) {
68+
HStack {
69+
Image(systemName: "chevron.left")
70+
Text("Accounts")
71+
}
72+
.font(.title3)
73+
}
74+
.buttonStyle(.plain)
75+
content()
76+
}
77+
}
78+
}
79+
}
80+
81+
struct AccountView_Previews: PreviewProvider {
82+
static var previews: some View {
83+
VStack(alignment: .leading, spacing: 8) {
84+
AccountView()
85+
86+
AccountView(location: .gitHubCopilot)
87+
88+
AccountView(location: .openAI)
89+
}
90+
.frame(height: 800)
91+
.padding(.all, 8)
92+
.background(Color.black)
93+
}
94+
}

Copilot for Xcode/App.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22
import XPCShared
3+
import UpdateChecker
34

45
@main
56
struct CopilotForXcodeApp: App {
@@ -11,9 +12,23 @@ struct CopilotForXcodeApp: App {
1112
.onAppear {
1213
UserDefaults.setupDefaultSettings()
1314
}
15+
.environment(\.updateChecker, UpdateChecker(hostBundle: Bundle.main))
1416
}
1517
.windowStyle(.hiddenTitleBar)
1618
}
1719
}
1820

1921
var isPreview: Bool { ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" }
22+
23+
struct UpdateCheckerKey: EnvironmentKey {
24+
static var defaultValue: UpdateChecker = UpdateChecker(hostBundle: nil)
25+
}
26+
27+
extension EnvironmentValues {
28+
var updateChecker: UpdateChecker {
29+
get { self[UpdateCheckerKey.self] }
30+
set { self[UpdateCheckerKey.self] = newValue }
31+
}
32+
}
33+
34+

Copilot for Xcode/AppInfoView.swift

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import SwiftUI
22

33
struct AppInfoView: View {
44
@State var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
5+
@Environment(\.updateChecker) var updateChecker
56

67
var body: some View {
78
Section {
@@ -14,15 +15,35 @@ struct AppInfoView: View {
1415
.foregroundColor(.white.opacity(0.5))
1516

1617
Spacer()
18+
19+
Button(action: {
20+
updateChecker.checkForUpdates()
21+
}) {
22+
HStack(spacing: 2) {
23+
Image(systemName: "arrow.up.right.circle.fill")
24+
Text("Check for Updates")
25+
}
26+
}
27+
.buttonStyle(.copilot)
1728
}
1829

19-
Link(destination: URL(string: "https://github.com/intitni/CopilotForXcode")!) {
20-
HStack(spacing: 2) {
21-
Image(systemName: "link")
22-
Text("GitHub")
30+
HStack(spacing: 16) {
31+
Link(destination: URL(string: "https://github.com/intitni/CopilotForXcode")!) {
32+
HStack(spacing: 2) {
33+
Image(systemName: "link")
34+
Text("GitHub")
35+
}
36+
}
37+
.focusable(false)
38+
39+
Link(destination: URL(string: "https://www.buymeacoffee.com/intitni")!) {
40+
HStack(spacing: 2) {
41+
Image(systemName: "cup.and.saucer.fill")
42+
Text("Buy Me A Coffee")
43+
}
2344
}
45+
.focusable(false)
2446
}
25-
.focusable(false)
2647
}
2748
}
2849
}

Copilot for Xcode/ContentView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ struct ContentView: View {
1414
VStack(alignment: .leading, spacing: 8) {
1515
AppInfoView()
1616
LaunchAgentView()
17-
CopilotView()
17+
AccountView()
1818
SettingsView()
1919
InstructionView()
20+
DebugSettingsView()
2021
Spacer()
2122
}
2223
.padding(.all, 12)
@@ -41,6 +42,6 @@ struct ContentView: View {
4142
struct ContentView_Previews: PreviewProvider {
4243
static var previews: some View {
4344
ContentView()
44-
.frame(height: 800)
45+
.frame(height: 1200)
4546
}
4647
}

Copilot for Xcode/DebugView.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import LaunchAgentManager
2+
import Preferences
3+
import SwiftUI
4+
5+
final class DebugSettings: ObservableObject {
6+
@AppStorage(\.disableLazyVStack)
7+
var disableLazyVStack: Bool
8+
init() {}
9+
}
10+
11+
struct DebugSettingsView: View {
12+
@StateObject var settings = DebugSettings()
13+
14+
var body: some View {
15+
Section {
16+
Form {
17+
Toggle(isOn: $settings.disableLazyVStack) {
18+
Text("Disable LazyVStack")
19+
}
20+
.toggleStyle(.switch)
21+
}
22+
}.buttonStyle(.copilot)
23+
}
24+
}
25+
26+
struct DebugSettingsView_Preview: PreviewProvider {
27+
static var previews: some View {
28+
DebugSettingsView()
29+
.background(.purple)
30+
}
31+
}

Copilot for Xcode/LaunchAgentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import LaunchAgentManager
22
import SwiftUI
3-
import XPCShared
3+
import Preferences
44

55
struct LaunchAgentView: View {
66
@State var errorMessage: String?
77
@State var isDidRemoveLaunchAgentAlertPresented = false
88
@State var isDidSetupLaunchAgentAlertPresented = false
99
@State var isDidRestartLaunchAgentAlertPresented = false
10-
@AppStorage(SettingsKey.nodePath, store: .shared) var nodePath: String = ""
10+
@AppStorage(\.nodePath) var nodePath: String
1111

1212
var body: some View {
1313
Section {

0 commit comments

Comments
 (0)