Skip to content

Commit 0cc2e7a

Browse files
committed
Merge branch 'release/0.30.4'
2 parents e81e8c6 + 653459c commit 0cc2e7a

27 files changed

Lines changed: 1199 additions & 836 deletions

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ body:
1313
id: before-reporting
1414
attributes:
1515
label: Before Reporting
16-
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.
16+
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.
1717
options:
1818
- label: I have checked FAQ, and there is no solution to my issue
1919
required: true
@@ -32,9 +32,9 @@ body:
3232
id: reproduce
3333
attributes:
3434
label: How to reproduce the bug.
35-
description: If possible, please provide the steps to reproduce the bug.
35+
description: If possible, please provide the steps to reproduce the bug and relevant settings in screenshots.
3636
placeholder: "1. *****\n2.*****"
37-
value: "It just happens!"
37+
value: "It just happened!"
3838
- type: textarea
3939
id: logs
4040
attributes:
@@ -53,8 +53,4 @@ body:
5353
id: copilot-for-xcode-version
5454
attributes:
5555
label: Copilot for Xcode version
56-
- type: input
57-
id: node-version
58-
attributes:
59-
label: Node version
6056

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Bug Report (Beta)
2+
description: File a bug report
3+
title: "[Bug (Beta)]: "
4+
labels: ["bug", "beta"]
5+
assignees:
6+
- intitni
7+
body:
8+
- type: markdown
9+
attributes:
10+
value: |
11+
Thanks for taking the time to fill out this bug report!
12+
- type: checkboxes
13+
id: before-reporting
14+
attributes:
15+
label: Before Reporting
16+
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.
17+
options:
18+
- label: I have checked FAQ, and there is no solution to my issue
19+
required: true
20+
- label: I have searched the existing issues, and there is no existing issue for my issue
21+
required: true
22+
- type: textarea
23+
id: what-happened
24+
attributes:
25+
label: What happened?
26+
description: Also tell us, what did you expect to happen?
27+
placeholder: Tell us what you see!
28+
value: "A bug happened!"
29+
validations:
30+
required: true
31+
- type: textarea
32+
id: reproduce
33+
attributes:
34+
label: How to reproduce the bug.
35+
description: If possible, please provide the steps to reproduce the bug and relevant settings in screenshots.
36+
placeholder: "1. *****\n2.*****"
37+
value: "It just happened!"
38+
- type: textarea
39+
id: logs
40+
attributes:
41+
label: Relevant log output
42+
description: If it's a crash, please provide the crash report. You can find it in the Console.app.
43+
render: shell
44+
- type: input
45+
id: mac-version
46+
attributes:
47+
label: macOS version
48+
- type: input
49+
id: xcode-version
50+
attributes:
51+
label: Xcode version
52+
- type: input
53+
id: copilot-for-xcode-version
54+
attributes:
55+
label: Copilot for Xcode version
56+

Core/Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ let package = Package(
242242
.target(
243243
name: "ChatPlugin",
244244
dependencies: [
245+
.product(name: "AppMonitoring", package: "Tool"),
245246
.product(name: "OpenAIService", package: "Tool"),
246247
.product(name: "Terminal", package: "Tool"),
247248
]

Core/Sources/PromptToCodeService/OpenAIPromptToCodeService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public final class OpenAIPromptToCodeService: PromptToCodeServiceType {
3131
return userPreferredLanguage.isEmpty ? "" : " in \(userPreferredLanguage)"
3232
}()
3333

34-
let editor: EditorInformation = XcodeInspector.shared.focusedEditorContent ?? .init(
34+
let editor: EditorInformation = XcodeInspector.shared.getFocusedEditorContent() ?? .init(
3535
editorContent: .init(
3636
content: source.content,
3737
lines: source.lines,

Core/Sources/Service/RealtimeSuggestionController.swift

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ public actor RealtimeSuggestionController {
3131

3232
private func observeXcodeChange() {
3333
cancellable.forEach { $0.cancel() }
34-
34+
3535
XcodeInspector.shared.$focusedEditor
3636
.sink { [weak self] editor in
3737
guard let self else { return }
3838
Task {
39-
guard let editor else { return }
39+
guard let editor else { return }
4040
await self.handleFocusElementChange(editor)
4141
}
4242
}.store(in: &cancellable)
@@ -51,7 +51,7 @@ public actor RealtimeSuggestionController {
5151
}
5252

5353
self.sourceEditor = sourceEditor
54-
54+
5555
let notificationsFromEditor = sourceEditor.axNotifications
5656

5757
editorObservationTask?.cancel()
@@ -65,25 +65,54 @@ public actor RealtimeSuggestionController {
6565
)
6666
}
6767

68-
for await notification in notificationsFromEditor {
69-
guard let self else { return }
70-
try Task.checkCancellation()
71-
72-
switch notification.kind {
73-
case .valueChanged:
74-
await cancelInFlightTasks()
75-
await self.triggerPrefetchDebounced()
76-
await self.notifyEditingFileChange(editor: sourceEditor.element)
77-
case .selectedTextChanged:
78-
guard let fileURL = XcodeInspector.shared.activeDocumentURL
79-
else { break }
80-
await PseudoCommandHandler().invalidateRealtimeSuggestionsIfNeeded(
81-
fileURL: fileURL,
82-
sourceEditor: sourceEditor
83-
)
84-
default:
85-
break
68+
let valueChange = notificationsFromEditor.filter { $0.kind == .valueChanged }
69+
let selectedTextChanged = notificationsFromEditor
70+
.filter { $0.kind == .selectedTextChanged }
71+
72+
await withTaskGroup(of: Void.self) { [weak self] group in
73+
group.addTask { [weak self] in
74+
let handler = { [weak self] in
75+
guard let self else { return }
76+
await cancelInFlightTasks()
77+
await self.triggerPrefetchDebounced()
78+
await self.notifyEditingFileChange(editor: sourceEditor.element)
79+
}
80+
81+
if #available(macOS 13.0, *) {
82+
for await _ in valueChange.throttle(for: .milliseconds(200)) {
83+
if Task.isCancelled { return }
84+
await handler()
85+
}
86+
} else {
87+
for await _ in valueChange {
88+
if Task.isCancelled { return }
89+
await handler()
90+
}
91+
}
8692
}
93+
group.addTask {
94+
let handler = {
95+
guard let fileURL = XcodeInspector.shared.activeDocumentURL else { return }
96+
await PseudoCommandHandler().invalidateRealtimeSuggestionsIfNeeded(
97+
fileURL: fileURL,
98+
sourceEditor: sourceEditor
99+
)
100+
}
101+
102+
if #available(macOS 13.0, *) {
103+
for await _ in selectedTextChanged.throttle(for: .milliseconds(200)) {
104+
if Task.isCancelled { return }
105+
await handler()
106+
}
107+
} else {
108+
for await _ in selectedTextChanged {
109+
if Task.isCancelled { return }
110+
await handler()
111+
}
112+
}
113+
}
114+
115+
await group.waitForAll()
87116
}
88117
}
89118

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

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

112141
func triggerPrefetchDebounced(force: Bool = false) {
113142
inflightPrefetchTask = Task(priority: .utility) { @WorkspaceActor in
114-
try? await Task.sleep(nanoseconds: UInt64((
143+
try? await Task.sleep(nanoseconds: UInt64(
115144
max(UserDefaults.shared.value(for: \.realtimeSuggestionDebounce), 0.15)
116-
) * 1_000_000_000))
117-
145+
* 1_000_000_000
146+
))
147+
118148
if Task.isCancelled { return }
119149

120150
guard UserDefaults.shared.value(for: \.realtimeSuggestionToggle)

Core/Sources/SuggestionWidget/FeatureReducers/ChatPanelFeature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public struct ChatPanelFeature: ReducerProtocol {
8585
@Dependency(\.chatTabBuilderCollection) var chatTabBuilderCollection
8686

8787
@MainActor func toggleFullScreen() {
88-
let window = suggestionWidgetControllerDependency.windows
88+
let window = suggestionWidgetControllerDependency.windowsController?.windows
8989
.chatPanelWindow
9090
window?.toggleFullScreen(nil)
9191
}

Core/Sources/SuggestionWidget/FeatureReducers/CircularWidgetFeature.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public struct CircularWidgetFeature: ReducerProtocol {
1616
var isContentEmpty: Bool
1717
var isChatPanelDetached: Bool
1818
var isChatOpen: Bool
19-
var animationProgress: Double = 0
2019
}
2120

2221
public enum Action: Equatable {
@@ -27,7 +26,6 @@ public struct CircularWidgetFeature: ReducerProtocol {
2726
case markIsProcessing
2827
case endIsProcessing
2928
case _forceEndIsProcessing
30-
case _refreshRing
3129
}
3230

3331
struct CancelAutoEndIsProcessKey: Hashable {}
@@ -75,14 +73,6 @@ public struct CircularWidgetFeature: ReducerProtocol {
7573
state.isProcessingCounters.removeAll()
7674
state.isProcessing = false
7775
return .none
78-
79-
case ._refreshRing:
80-
if state.isProcessing {
81-
state.animationProgress = 1 - state.animationProgress
82-
} else {
83-
state.animationProgress = state.isContentEmpty ? 0 : 1
84-
}
85-
return .none
8676
}
8777
}
8878
}

Core/Sources/SuggestionWidget/FeatureReducers/PanelFeature.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct PanelFeature: ReducerProtocol {
3838
@Dependency(\.suggestionWidgetControllerDependency) var suggestionWidgetControllerDependency
3939
@Dependency(\.xcodeInspector) var xcodeInspector
4040
@Dependency(\.activateThisApp) var activateThisApp
41-
var windows: WidgetWindows { suggestionWidgetControllerDependency.windows }
41+
var windows: WidgetWindows? { suggestionWidgetControllerDependency.windowsController?.windows }
4242

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

123123
if hasPromptToCode {
124124
activateThisApp()
125-
await windows.sharedPanelWindow.makeKey()
125+
await MainActor.run {
126+
windows?.sharedPanelWindow.makeKey()
127+
}
126128
}
127129
}.animation(.easeInOut(duration: 0.2))
128130

0 commit comments

Comments
 (0)