Skip to content

Commit 24daaa5

Browse files
committed
Fix open detach chat not updating opacity of window
1 parent 374b1d6 commit 24daaa5

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

Core/Sources/Service/GUI/GraphicalUserInterfaceController.swift.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ public final class GraphicalUserInterfaceController {
3636

3737
public func openGlobalChat() {
3838
UserDefaults.shared.set(true, for: \.useGlobalChat)
39-
suggestionWidget.detachChat()
4039
let dataSource = WidgetDataSource.shared
4140
let fakeFileURL = URL(fileURLWithPath: "/")
4241
Task {
4342
await dataSource.createChatIfNeeded(for: fakeFileURL)
44-
let presenter = PresentInWindowSuggestionPresenter()
45-
presenter.presentChatRoom(fileURL: fakeFileURL)
43+
suggestionWidget.presentDetachedGlobalChat()
4644
}
4745
}
4846
}

Core/Sources/SuggestionWidget/SuggestionWidgetController.swift

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,6 @@ public final class SuggestionWidgetController: NSObject {
263263
}
264264
}
265265
}
266-
267-
public func detachChat() {
268-
chatWindowViewModel.chatPanelInASeparateWindow = true
269-
}
270266
}
271267

272268
// MARK: - Handle Events
@@ -318,6 +314,27 @@ public extension SuggestionWidgetController {
318314
}
319315
}
320316
}
317+
318+
func presentDetachedGlobalChat() {
319+
chatWindowViewModel.chatPanelInASeparateWindow = true
320+
Task {
321+
if let chat = await dataSource?.chatForFile(at: URL(fileURLWithPath: "/")) {
322+
chatWindowViewModel.chat = chat
323+
chatWindowViewModel.isPanelDisplayed = true
324+
325+
if chatWindowViewModel.chatPanelInASeparateWindow {
326+
self.updateWindowLocation()
327+
}
328+
329+
Task { @MainActor in
330+
chatWindow.alphaValue = 1
331+
// looks like we need a delay.
332+
try await Task.sleep(nanoseconds: 150_000_000)
333+
NSApplication.shared.activate(ignoringOtherApps: true)
334+
}
335+
}
336+
}
337+
}
321338

322339
func closeChatRoom(fileURL: URL) {
323340
widgetViewModel.isProcessing = false

0 commit comments

Comments
 (0)