Skip to content

Commit

Permalink
Merge branch 'release/0.30.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
intitni committed Feb 17, 2024
2 parents e81e8c6 + 653459c commit 0cc2e7a
Show file tree
Hide file tree
Showing 27 changed files with 1,199 additions and 836 deletions.
10 changes: 3 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ body:
id: before-reporting
attributes:
label: Before Reporting
description: Before reporting the bug, we suggestion that you first refer to the [FAQ](https://github.com/intitni/CopilotForXcode/wiki/Frequently-Asked-Questions) to check if it may address your issue. And search for existing issues to avoid duplication.
description: Before reporting the bug, we suggestion that you first refer to the [FAQ](https://github.com/intitni/CopilotForXcode/wiki/Frequently-Asked-Questions) to check if it may address your issue. And search for existing issues to avoid duplication. If you are reporting a bug from a beta build, please use the dedicated template for beta build.
options:
- label: I have checked FAQ, and there is no solution to my issue
required: true
Expand All @@ -32,9 +32,9 @@ body:
id: reproduce
attributes:
label: How to reproduce the bug.
description: If possible, please provide the steps to reproduce the bug.
description: If possible, please provide the steps to reproduce the bug and relevant settings in screenshots.
placeholder: "1. *****\n2.*****"
value: "It just happens!"
value: "It just happened!"
- type: textarea
id: logs
attributes:
Expand All @@ -53,8 +53,4 @@ body:
id: copilot-for-xcode-version
attributes:
label: Copilot for Xcode version
- type: input
id: node-version
attributes:
label: Node version

56 changes: 56 additions & 0 deletions .github/ISSUE_TEMPLATE/z_bug_report_beta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Bug Report (Beta)
description: File a bug report
title: "[Bug (Beta)]: "
labels: ["bug", "beta"]
assignees:
- intitni
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: checkboxes
id: before-reporting
attributes:
label: Before Reporting
description: Before reporting the bug, we suggestion that you first refer to the [FAQ](https://github.com/intitni/CopilotForXcode/wiki/Frequently-Asked-Questions) to check if it may address your issue. And search for existing issues to avoid duplication.
options:
- label: I have checked FAQ, and there is no solution to my issue
required: true
- label: I have searched the existing issues, and there is no existing issue for my issue
required: true
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: How to reproduce the bug.
description: If possible, please provide the steps to reproduce the bug and relevant settings in screenshots.
placeholder: "1. *****\n2.*****"
value: "It just happened!"
- type: textarea
id: logs
attributes:
label: Relevant log output
description: If it's a crash, please provide the crash report. You can find it in the Console.app.
render: shell
- type: input
id: mac-version
attributes:
label: macOS version
- type: input
id: xcode-version
attributes:
label: Xcode version
- type: input
id: copilot-for-xcode-version
attributes:
label: Copilot for Xcode version

1 change: 1 addition & 0 deletions Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ let package = Package(
.target(
name: "ChatPlugin",
dependencies: [
.product(name: "AppMonitoring", package: "Tool"),
.product(name: "OpenAIService", package: "Tool"),
.product(name: "Terminal", package: "Tool"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public final class OpenAIPromptToCodeService: PromptToCodeServiceType {
return userPreferredLanguage.isEmpty ? "" : " in \(userPreferredLanguage)"
}()

let editor: EditorInformation = XcodeInspector.shared.focusedEditorContent ?? .init(
let editor: EditorInformation = XcodeInspector.shared.getFocusedEditorContent() ?? .init(
editorContent: .init(
content: source.content,
lines: source.lines,
Expand Down
80 changes: 55 additions & 25 deletions Core/Sources/Service/RealtimeSuggestionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public actor RealtimeSuggestionController {

private func observeXcodeChange() {
cancellable.forEach { $0.cancel() }

XcodeInspector.shared.$focusedEditor
.sink { [weak self] editor in
guard let self else { return }
Task {
guard let editor else { return }
guard let editor else { return }
await self.handleFocusElementChange(editor)
}
}.store(in: &cancellable)
Expand All @@ -51,7 +51,7 @@ public actor RealtimeSuggestionController {
}

self.sourceEditor = sourceEditor

let notificationsFromEditor = sourceEditor.axNotifications

editorObservationTask?.cancel()
Expand All @@ -65,25 +65,54 @@ public actor RealtimeSuggestionController {
)
}

for await notification in notificationsFromEditor {
guard let self else { return }
try Task.checkCancellation()

switch notification.kind {
case .valueChanged:
await cancelInFlightTasks()
await self.triggerPrefetchDebounced()
await self.notifyEditingFileChange(editor: sourceEditor.element)
case .selectedTextChanged:
guard let fileURL = XcodeInspector.shared.activeDocumentURL
else { break }
await PseudoCommandHandler().invalidateRealtimeSuggestionsIfNeeded(
fileURL: fileURL,
sourceEditor: sourceEditor
)
default:
break
let valueChange = notificationsFromEditor.filter { $0.kind == .valueChanged }
let selectedTextChanged = notificationsFromEditor
.filter { $0.kind == .selectedTextChanged }

await withTaskGroup(of: Void.self) { [weak self] group in
group.addTask { [weak self] in
let handler = { [weak self] in
guard let self else { return }
await cancelInFlightTasks()
await self.triggerPrefetchDebounced()
await self.notifyEditingFileChange(editor: sourceEditor.element)
}

if #available(macOS 13.0, *) {
for await _ in valueChange.throttle(for: .milliseconds(200)) {
if Task.isCancelled { return }
await handler()
}
} else {
for await _ in valueChange {
if Task.isCancelled { return }
await handler()
}
}
}
group.addTask {
let handler = {
guard let fileURL = XcodeInspector.shared.activeDocumentURL else { return }
await PseudoCommandHandler().invalidateRealtimeSuggestionsIfNeeded(
fileURL: fileURL,
sourceEditor: sourceEditor
)
}

if #available(macOS 13.0, *) {
for await _ in selectedTextChanged.throttle(for: .milliseconds(200)) {
if Task.isCancelled { return }
await handler()
}
} else {
for await _ in selectedTextChanged {
if Task.isCancelled { return }
await handler()
}
}
}

await group.waitForAll()
}
}

Expand All @@ -94,7 +123,7 @@ public actor RealtimeSuggestionController {
.fetchOrCreateWorkspaceAndFilespace(fileURL: fileURL)

if filespace.codeMetadata.uti == nil {
Logger.service.info("Generate cache for file.")
Logger.service.info("Generate cache for file.")
// avoid the command get called twice
filespace.codeMetadata.uti = ""
do {
Expand All @@ -111,10 +140,11 @@ public actor RealtimeSuggestionController {

func triggerPrefetchDebounced(force: Bool = false) {
inflightPrefetchTask = Task(priority: .utility) { @WorkspaceActor in
try? await Task.sleep(nanoseconds: UInt64((
try? await Task.sleep(nanoseconds: UInt64(
max(UserDefaults.shared.value(for: \.realtimeSuggestionDebounce), 0.15)
) * 1_000_000_000))

* 1_000_000_000
))

if Task.isCancelled { return }

guard UserDefaults.shared.value(for: \.realtimeSuggestionToggle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public struct ChatPanelFeature: ReducerProtocol {
@Dependency(\.chatTabBuilderCollection) var chatTabBuilderCollection

@MainActor func toggleFullScreen() {
let window = suggestionWidgetControllerDependency.windows
let window = suggestionWidgetControllerDependency.windowsController?.windows
.chatPanelWindow
window?.toggleFullScreen(nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public struct CircularWidgetFeature: ReducerProtocol {
var isContentEmpty: Bool
var isChatPanelDetached: Bool
var isChatOpen: Bool
var animationProgress: Double = 0
}

public enum Action: Equatable {
Expand All @@ -27,7 +26,6 @@ public struct CircularWidgetFeature: ReducerProtocol {
case markIsProcessing
case endIsProcessing
case _forceEndIsProcessing
case _refreshRing
}

struct CancelAutoEndIsProcessKey: Hashable {}
Expand Down Expand Up @@ -75,14 +73,6 @@ public struct CircularWidgetFeature: ReducerProtocol {
state.isProcessingCounters.removeAll()
state.isProcessing = false
return .none

case ._refreshRing:
if state.isProcessing {
state.animationProgress = 1 - state.animationProgress
} else {
state.animationProgress = state.isContentEmpty ? 0 : 1
}
return .none
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct PanelFeature: ReducerProtocol {
@Dependency(\.suggestionWidgetControllerDependency) var suggestionWidgetControllerDependency
@Dependency(\.xcodeInspector) var xcodeInspector
@Dependency(\.activateThisApp) var activateThisApp
var windows: WidgetWindows { suggestionWidgetControllerDependency.windows }
var windows: WidgetWindows? { suggestionWidgetControllerDependency.windowsController?.windows }

public var body: some ReducerProtocol<State, Action> {
Scope(state: \.suggestionPanelState, action: /Action.suggestionPanel) {
Expand Down Expand Up @@ -122,7 +122,9 @@ public struct PanelFeature: ReducerProtocol {

if hasPromptToCode {
activateThisApp()
await windows.sharedPanelWindow.makeKey()
await MainActor.run {
windows?.sharedPanelWindow.makeKey()
}
}
}.animation(.easeInOut(duration: 0.2))

Expand Down
Loading

0 comments on commit 0cc2e7a

Please sign in to comment.