File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed
Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments