Skip to content

Commit

Permalink
Merge branch 'release/0.22.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
intitni committed Sep 2, 2023
2 parents f8e27a8 + fab4d33 commit 5898b16
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 20 deletions.
1 change: 1 addition & 0 deletions Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ let package = Package(
"LaunchAgentManager",
"PlusFeatureFlag",
.product(name: "Toast", package: "Tool"),
.product(name: "SharedUIComponents", package: "Tool"),
.product(name: "SuggestionModel", package: "Tool"),
.product(name: "MarkdownUI", package: "swift-markdown-ui"),
.product(name: "OpenAIService", package: "Tool"),
Expand Down
50 changes: 44 additions & 6 deletions Core/Sources/HostApp/AccountSettings/CopilotView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import AppKit
import Client
import GitHubCopilotService
import Preferences
import SharedUIComponents
import SuggestionModel
import SwiftUI

Expand Down Expand Up @@ -32,7 +33,7 @@ struct CopilotView: View {
@Published var installationStep: GitHubCopilotInstallationManager.InstallationStep?

init() {}

init(
installationStatus: GitHubCopilotInstallationManager.InstallationStatus,
installationStep: GitHubCopilotInstallationManager.InstallationStep?
Expand Down Expand Up @@ -142,10 +143,23 @@ struct CopilotView: View {
HStack {
VStack(alignment: .leading, spacing: 8) {
Form {
TextField(text: $settings.nodePath, prompt: Text("node")) {
TextField(
text: $settings.nodePath,
prompt: Text(
"node"
)
) {
Text("Path to Node (v17+)")
}

Text(
"Provide the path to the executable if it can't be found by the app, shim executable is not supported"
)
.lineLimit(10)
.foregroundColor(.secondary)
.font(.callout)
.dynamicHeightTextInFormWorkaround()

Picker(selection: $settings.runNodeWith) {
ForEach(NodeRunner.allCases, id: \.rawValue) { runner in
switch runner {
Expand All @@ -160,11 +174,28 @@ struct CopilotView: View {
} label: {
Text("Run Node with")
}

Group {
switch settings.runNodeWith {
case .env:
Text(
"PATH: `/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`"
)
case .bash:
Text("PATH inherited from bash configurations.")
case .shell:
Text("PATH inherited from $SHELL configurations.")
}
}
.lineLimit(10)
.foregroundColor(.secondary)
.font(.callout)
.dynamicHeightTextInFormWorkaround()
}

Text(
"You may have to restart the helper app to apply the changes. To do so, simply close the helper app by clicking on the menu bar icon that looks like a steer wheel, it will automatically restart as needed."
)
Text("""
You may have to restart the helper app to apply the changes. To do so, simply close the helper app by clicking on the menu bar icon that looks like a tentacle, it will automatically restart as needed.
""")
.lineLimit(6)
.fixedSize(horizontal: false, vertical: true)
.foregroundColor(.secondary)
Expand Down Expand Up @@ -236,9 +267,16 @@ struct CopilotView: View {

Form {
Toggle(
"Ignore Trailing New Lines and Whitespaces",
"Remove Extra New Lines Generated by GitHub Copilot",
isOn: $settings.gitHubCopilotIgnoreTrailingNewLines
)
Text(
"Sometimes GitHub Copilot may generate extra unwanted new lines at the end of a suggestion. If you don't like that, you can turn this toggle on."
)
.lineLimit(10)
.foregroundColor(.secondary)
.font(.callout)
.dynamicHeightTextInFormWorkaround()
Toggle("Verbose Log", isOn: $settings.gitHubCopilotVerboseLog)
}

Expand Down
23 changes: 12 additions & 11 deletions Core/Sources/Service/RealtimeSuggestionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import QuartzCore
import Workspace
import XcodeInspector

public class RealtimeSuggestionController {
public actor RealtimeSuggestionController {
let eventObserver: CGEventObserverType = CGEventObserver(eventsOfInterest: [.keyDown])
private var task: Task<Void, Error>?
private var inflightPrefetchTask: Task<Void, Error>?
Expand All @@ -23,12 +23,13 @@ public class RealtimeSuggestionController {
private var sourceEditor: SourceEditor?

init() {}


nonisolated
func start() {
Task { [weak self] in
if let app = ActiveApplicationMonitor.shared.activeXcode {
self?.handleXcodeChanged(app)
self?.startHIDObservation()
await self?.handleXcodeChanged(app)
await self?.startHIDObservation()
}
var previousApp = ActiveApplicationMonitor.shared.activeXcode
for await app in ActiveApplicationMonitor.shared.createStream() {
Expand All @@ -37,13 +38,13 @@ public class RealtimeSuggestionController {
defer { previousApp = app }

if let app = ActiveApplicationMonitor.shared.activeXcode, app != previousApp {
self.handleXcodeChanged(app)
await self.handleXcodeChanged(app)
}

if ActiveApplicationMonitor.shared.activeXcode != nil {
startHIDObservation()
await startHIDObservation()
} else {
stopHIDObservation()
await stopHIDObservation()
}
}
}
Expand Down Expand Up @@ -85,7 +86,7 @@ public class RealtimeSuggestionController {
for await _ in notifications {
guard let self else { return }
try Task.checkCancellation()
self.handleFocusElementChange()
await self.handleFocusElementChange()
}
}
}
Expand All @@ -112,7 +113,7 @@ public class RealtimeSuggestionController {

editorObservationTask = Task { [weak self] in
let fileURL = try await Environment.fetchCurrentFileURL()
if let sourceEditor = self?.sourceEditor {
if let sourceEditor = await self?.sourceEditor {
await PseudoCommandHandler().invalidateRealtimeSuggestionsIfNeeded(
fileURL: fileURL,
sourceEditor: sourceEditor
Expand All @@ -132,10 +133,10 @@ public class RealtimeSuggestionController {
switch notification.name {
case kAXValueChangedNotification:
await cancelInFlightTasks()
self.triggerPrefetchDebounced()
await self.triggerPrefetchDebounced()
await self.notifyEditingFileChange(editor: focusElement)
case kAXSelectedTextChangedNotification:
guard let sourceEditor else { continue }
guard let sourceEditor = await sourceEditor else { continue }
let fileURL = XcodeInspector.shared.activeDocumentURL
await PseudoCommandHandler().invalidateRealtimeSuggestionsIfNeeded(
fileURL: fileURL,
Expand Down
4 changes: 3 additions & 1 deletion Core/Sources/SuggestionWidget/ChatWindowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ struct ChatTabContainer: View {
} else {
ForEach(viewStore.state.tabInfo) { tabInfo in
if let tab = chatTabPool.getTab(of: tabInfo.id) {
let isActive = tab.id == viewStore.state.selectedTabId
tab.body
.opacity(tab.id == viewStore.state.selectedTabId ? 1 : 0)
.opacity(isActive ? 1 : 0)
.disabled(!isActive)
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
EmptyView()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import SwiftUI

struct DynamicHeightTextInFormWorkaroundModifier: ViewModifier {
func body(content: Content) -> some View {
HStack(spacing: 0) {
content
Spacer()
}
.fixedSize(horizontal: false, vertical: true)
}
}

public extension View {
func dynamicHeightTextInFormWorkaround() -> some View {
modifier(DynamicHeightTextInFormWorkaroundModifier())
}
}
4 changes: 2 additions & 2 deletions Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
APP_VERSION = 0.22.2
APP_BUILD = 232
APP_VERSION = 0.22.3
APP_BUILD = 233
12 changes: 12 additions & 0 deletions appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
<channel>
<title>Copilot for Xcode</title>

<item>
<title>0.22.3</title>
<pubDate>Sat, 02 Sep 2023 15:51:16 +0800</pubDate>
<sparkle:version>233</sparkle:version>
<sparkle:shortVersionString>0.22.3</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>12.0</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>
https://github.com/intitni/CopilotForXcode/releases/tag/0.22.3
</sparkle:releaseNotesLink>
<enclosure url="https://github.com/intitni/CopilotForXcode/releases/download/0.22.3/Copilot.for.Xcode.app.zip" length="31397137" type="application/octet-stream" sparkle:edSignature="1wu9QYOxI9TkSY2/+JcRZFv/9WjvRwMZ0j1Hdt3x4hh0QSxP5xELKJZzMkf7yOTz0qyNM/5mbmAmCtO6nP4gAg=="/>
</item>

<item>
<title>0.22.2</title>
<pubDate>Sat, 19 Aug 2023 10:48:38 +0800</pubDate>
Expand Down

0 comments on commit 5898b16

Please sign in to comment.