Skip to content

Commit 209d5b3

Browse files
committed
Fix that open chat in context menu not working in some windows
1 parent eac534b commit 209d5b3

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,12 @@ public final class GraphicalUserInterfaceController {
1010
private nonisolated init() {
1111
Task { @MainActor in
1212
suggestionWidget.dataSource = WidgetDataSource.shared
13-
suggestionWidget.onOpenChatClicked = {
13+
suggestionWidget.onOpenChatClicked = { [weak self] in
1414
Task {
15-
let commandHandler = WindowBaseCommandHandler()
16-
_ = try await commandHandler.chatWithSelection(editor: .init(
17-
content: "",
18-
lines: [],
19-
uti: "",
20-
cursorPosition: .outOfScope,
21-
selections: [],
22-
tabSize: 0,
23-
indentSize: 0,
24-
usesTabsForIndentation: false
25-
))
15+
let uri = try await Environment.fetchFocusedElementURI()
16+
let dataSource = WidgetDataSource.shared
17+
await dataSource.createChatIfNeeded(for: uri)
18+
self?.suggestionWidget.presentChatRoom(fileURL: uri)
2619
}
2720
}
2821
suggestionWidget.onCustomCommandClicked = { command in

0 commit comments

Comments
 (0)