Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
01a6f16
Merge tag '0.30.3' into develop
intitni Feb 7, 2024
c3d4dff
Update issue templates
intitni Feb 7, 2024
73cf3ab
Add WindowsController
intitni Feb 13, 2024
78ce489
Make WidgetLocation Equatable
intitni Feb 13, 2024
3c9dfc4
Move windows to WindowsController
intitni Feb 13, 2024
163f8d5
Update the dependency to hold a WindowsController instead
intitni Feb 13, 2024
eabb647
Remove useless actions
intitni Feb 13, 2024
f3275a1
Update windows getter
intitni Feb 13, 2024
e280dbd
Merge branch 'feature/improve-performance-of-widgets' into develop
intitni Feb 14, 2024
098e7e3
Make focusedEditorContent a function marked as expensive
intitni Feb 14, 2024
342ab60
Rename WindowsController to WidgetWindowsController
intitni Feb 14, 2024
6d65d57
Fix that a task is not stored
intitni Feb 14, 2024
a78ed53
Add throttler to RealtimeSuggestionController
intitni Feb 14, 2024
20bdfbd
Throttle location generation
intitni Feb 14, 2024
9a7ce06
Bump version to 0.30.4
intitni Feb 14, 2024
578802a
Merge tag '0.30.4.beta.1' into develop
intitni Feb 14, 2024
250bdf9
Remove scroll event throttle
intitni Feb 15, 2024
10f2a93
Add DebounceFunction and ThrottleFunction
intitni Feb 15, 2024
12ff573
Remove some use of MainActor
intitni Feb 15, 2024
3a1f4c3
Update circular widget implementation
intitni Feb 15, 2024
d480527
Update
intitni Feb 15, 2024
02ab5ca
Update signpost API
intitni Feb 15, 2024
72a8565
Fix dependecy
intitni Feb 15, 2024
7c5c105
Bump build number
intitni Feb 15, 2024
d1d118e
Tweak widget behavior
intitni Feb 15, 2024
060e08c
Make WidgetWindowsController an actor
intitni Feb 15, 2024
df7ad31
Bring back some main actors
intitni Feb 15, 2024
cbe4ec7
Merge tag '0.30.4.beta.2' into develop
intitni Feb 15, 2024
1973c99
Adjust widget transition when switching apps
intitni Feb 16, 2024
919c7ad
Bump version
intitni Feb 17, 2024
653459c
Update appcast.xml
intitni Feb 17, 2024
0cc2e7a
Merge branch 'release/0.30.4'
intitni Feb 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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