Skip to content

Commit 4191361

Browse files
committed
Merge branch 'hotfix/0.34.1'
2 parents d89df81 + b4b9a35 commit 4191361

4 files changed

Lines changed: 53 additions & 73 deletions

File tree

Core/Sources/SuggestionWidget/ChatPanelWindow.swift

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,20 @@ final class ChatPanelWindow: WidgetWindow {
99
override var canBecomeMain: Bool { true }
1010

1111
private let storeObserver = NSObject()
12+
private let store: StoreOf<ChatPanel>
1213

1314
var minimizeWindow: () -> Void = {}
14-
15-
override var defaultCollectionBehavior: NSWindow.CollectionBehavior {
16-
[
17-
.fullScreenAuxiliary,
18-
.transient,
19-
.fullScreenPrimary,
20-
.fullScreenAllowsTiling,
21-
]
15+
16+
var isDetached: Bool {
17+
store.withState({$0.isDetached})
2218
}
2319

24-
override var switchingSpaceCollectionBehavior: NSWindow.CollectionBehavior {
25-
[
26-
.fullScreenAuxiliary,
27-
.transient,
28-
.fullScreenPrimary,
29-
.fullScreenAllowsTiling,
30-
]
31-
}
32-
33-
override var fullscreenCollectionBehavior: NSWindow.CollectionBehavior {
20+
override var defaultCollectionBehavior: NSWindow.CollectionBehavior {
3421
[
3522
.fullScreenAuxiliary,
3623
.transient,
3724
.fullScreenPrimary,
3825
.fullScreenAllowsTiling,
39-
.canJoinAllSpaces,
4026
]
4127
}
4228

@@ -45,6 +31,7 @@ final class ChatPanelWindow: WidgetWindow {
4531
chatTabPool: ChatTabPool,
4632
minimizeWindow: @escaping () -> Void
4733
) {
34+
self.store = store
4835
self.minimizeWindow = minimizeWindow
4936
super.init(
5037
contentRect: .init(x: 0, y: 0, width: 300, height: 400),
@@ -97,7 +84,7 @@ final class ChatPanelWindow: WidgetWindow {
9784
}
9885
}
9986
}
100-
87+
10188
func centerInActiveSpaceIfNeeded() {
10289
guard !isOnActiveSpace else { return }
10390
center()

Core/Sources/SuggestionWidget/WidgetWindowsController.swift

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ actor WidgetWindowsController: NSObject {
8282
}
8383
8484
updateWindowStateTask = Task { [weak self] in
85-
if let self { await handleXcodeFullscreenChange() }
85+
if let self { await handleSpaceChange() }
8686
8787
await withThrowingTaskGroup(of: Void.self) { [weak self] group in
8888
// active space did change
@@ -92,7 +92,7 @@ actor WidgetWindowsController: NSObject {
9292
for await _ in sequence {
9393
guard let self else { return }
9494
try Task.checkCancellation()
95-
await handleXcodeFullscreenChange()
95+
await handleSpaceChange()
9696
}
9797
}
9898
}
@@ -160,7 +160,7 @@ private extension WidgetWindowsController {
160160
161161
switch notification.kind {
162162
case .focusedWindowChanged:
163-
await handleXcodeFullscreenChange()
163+
await handleSpaceChange()
164164
await hideWidgetForTransitions()
165165
await updateWidgetsAndNotifyChangeOfEditor(immediately: true)
166166
case .focusedUIElementChanged:
@@ -402,7 +402,7 @@ extension WidgetWindowsController {
402402
windows.toastWindow.alphaValue = noFocus ? 0 : 1
403403

404404
if isChatPanelDetached {
405-
windows.chatPanelWindow.isWindowHidden = !hasChat
405+
windows.chatPanelWindow.isWindowHidden = false
406406
} else {
407407
windows.chatPanelWindow.isWindowHidden = noFocus
408408
}
@@ -436,7 +436,7 @@ extension WidgetWindowsController {
436436
}
437437
windows.toastWindow.alphaValue = noFocus ? 0 : 1
438438
if isChatPanelDetached {
439-
windows.chatPanelWindow.isWindowHidden = !hasChat
439+
windows.chatPanelWindow.isWindowHidden = false
440440
} else {
441441
windows.chatPanelWindow.isWindowHidden = noFocus && !windows
442442
.chatPanelWindow.isKeyWindow
@@ -584,7 +584,7 @@ extension WidgetWindowsController {
584584
}
585585

586586
@MainActor
587-
func handleXcodeFullscreenChange() async {
587+
func handleSpaceChange() async {
588588
let activeXcode = await XcodeInspector.shared.safe.activeXcode
589589

590590
let xcode = activeXcode?.appElement
@@ -593,19 +593,26 @@ extension WidgetWindowsController {
593593
} else {
594594
false
595595
}
596+
597+
let isXcodeActive = xcode?.isFrontmost ?? false
596598

597-
[
598-
windows.chatPanelWindow,
599+
await [
599600
windows.sharedPanelWindow,
600601
windows.suggestionPanelWindow,
601602
windows.widgetWindow,
602603
windows.toastWindow,
603604
].forEach {
604-
$0.send(.didChangeActiveSpace(fullscreen: isFullscreen))
605+
if isXcodeActive {
606+
$0.moveToActiveSpace()
607+
}
608+
}
609+
610+
if isXcodeActive, !windows.chatPanelWindow.isDetached {
611+
await windows.chatPanelWindow.moveToActiveSpace()
605612
}
606613

607-
if windows.fullscreenDetector.isOnActiveSpace, xcode?.focusedWindow != nil {
608-
windows.orderFront()
614+
if await windows.fullscreenDetector.isOnActiveSpace, xcode?.focusedWindow != nil {
615+
await windows.orderFront()
609616
}
610617
}
611618
}
@@ -796,7 +803,7 @@ public final class WidgetWindows {
796803
it.isReleasedWhenClosed = false
797804
it.isOpaque = false
798805
it.backgroundColor = .clear
799-
it.level = widgetLevel(0)
806+
it.level = widgetLevel(2)
800807
it.hasShadow = false
801808
it.contentView = NSHostingView(
802809
rootView: ToastPanelView(store: store.scope(
@@ -845,26 +852,10 @@ class WidgetWindow: CanBecomeKeyWindow {
845852
case switchingSpace
846853
}
847854

848-
enum Action {
849-
case didChangeActiveSpace(fullscreen: Bool)
850-
}
851-
852855
var defaultCollectionBehavior: NSWindow.CollectionBehavior {
853856
[.fullScreenAuxiliary, .transient]
854857
}
855858

856-
var fullscreenCollectionBehavior: NSWindow.CollectionBehavior {
857-
// .canJoinAllSpaces is required for macOS 15 (beta?) to display widgets in fullscreen mode.
858-
// But adding this behavior will create another issue that the widgets will display
859-
// whenever user switch spaces, so we are setting it only when the window is in fullscreen
860-
// mode.
861-
[.fullScreenAuxiliary, .transient, .canJoinAllSpaces]
862-
}
863-
864-
var switchingSpaceCollectionBehavior: NSWindow.CollectionBehavior {
865-
[.fullScreenAuxiliary, .transient]
866-
}
867-
868859
var isFullscreen: Bool {
869860
styleMask.contains(.fullScreen)
870861
}
@@ -876,19 +867,19 @@ class WidgetWindow: CanBecomeKeyWindow {
876867
case .none:
877868
collectionBehavior = defaultCollectionBehavior
878869
case .switchingSpace:
879-
collectionBehavior = switchingSpaceCollectionBehavior
880-
case let .normal(fullscreen):
881-
collectionBehavior = fullscreen
882-
? fullscreenCollectionBehavior
883-
: defaultCollectionBehavior
870+
collectionBehavior = defaultCollectionBehavior.union(.moveToActiveSpace)
871+
case .normal:
872+
collectionBehavior = defaultCollectionBehavior
884873
}
885874
}
886875
}
887-
888-
func send(_ action: Action) {
889-
switch action {
890-
case let .didChangeActiveSpace(fullscreen):
891-
state = .normal(fullscreen: fullscreen)
876+
877+
func moveToActiveSpace() {
878+
let previousState = state
879+
state = .switchingSpace
880+
Task { @MainActor in
881+
try await Task.sleep(nanoseconds: 50_000_000)
882+
self.state = previousState
892883
}
893884
}
894885
}

Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,23 @@ public final class GitHubCopilotChatService: BuiltinExtensionChatServiceType {
2626
let editorContent = await XcodeInspector.shared.getFocusedEditorContent()
2727
let workDoneToken = UUID().uuidString
2828
let turns = convertHistory(history: history, message: message)
29+
let doc = GitHubCopilotDoc(
30+
source: editorContent?.editorContent?.content ?? "",
31+
tabSize: 1,
32+
indentSize: 4,
33+
insertSpaces: true,
34+
path: editorContent?.documentURL.path ?? "",
35+
uri: editorContent?.documentURL.path ?? "",
36+
relativePath: editorContent?.relativePath ?? "",
37+
languageId: editorContent?.language ?? .plaintext,
38+
position: editorContent?.editorContent?.cursorPosition ?? .zero
39+
)
40+
2941
let request = GitHubCopilotRequest.ConversationCreate(requestBody: .init(
3042
workDoneToken: workDoneToken,
3143
turns: turns,
3244
capabilities: .init(allSkills: true, skills: []),
33-
doc: .init(
34-
source: editorContent?.editorContent?.content ?? "",
35-
tabSize: 1,
36-
indentSize: 4,
37-
insertSpaces: true,
38-
path: editorContent?.documentURL.path ?? "",
39-
uri: editorContent?.documentURL.path ?? "",
40-
relativePath: editorContent?.relativePath ?? "",
41-
languageId: editorContent?.language ?? .plaintext,
42-
position: editorContent?.editorContent?.cursorPosition ?? .zero
43-
),
45+
doc: doc,
4446
source: .panel,
4547
workspaceFolder: workspace.projectURL.path
4648
))
@@ -132,11 +134,11 @@ extension GitHubCopilotChatService {
132134
let systemPrompt = history
133135
.filter { $0.role == .system }.compactMap(\.content)
134136
.joined(separator: "\n\n")
135-
137+
136138
if !systemPrompt.isEmpty {
137139
turns.append(.init(request: "[System Prompt]\n\(systemPrompt)", response: "OK!"))
138140
}
139-
141+
140142
for i in firstIndexOfUserMessage..<history.endIndex {
141143
let message = history[i]
142144
let text = message.content ?? ""

Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
APP_VERSION = 0.34.0
2-
APP_BUILD = 412
1+
APP_VERSION = 0.34.1
2+
APP_BUILD = 413
33

0 commit comments

Comments
 (0)