Skip to content

Commit 1cd11f3

Browse files
committed
Move open chat to PseudoCommandHandler
1 parent b39a32b commit 1cd11f3

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

Core/Sources/Service/SuggestionCommandHandler/PseudoCommandHandler.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,14 @@ struct PseudoCommandHandler {
301301
await filespace.reset()
302302
PresentInWindowSuggestionPresenter().discardSuggestion(fileURL: documentURL)
303303
}
304+
305+
func openChat() {
306+
Task { @MainActor in
307+
let store = Service.shared.guiController.store
308+
await store.send(.createChatGPTChatTabIfNeeded)
309+
await store.send(.openChatPanel(forceDetach: false))
310+
}
311+
}
304312
}
305313

306314
extension PseudoCommandHandler {

Core/Sources/Service/SuggestionCommandHandler/SuggestionCommandHandler.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ protocol SuggestionCommandHandler {
1919
@ServiceActor
2020
func generateRealtimeSuggestions(editor: EditorContent) async throws -> UpdatedContent?
2121
@ServiceActor
22-
func chatWithSelection(editor: EditorContent) async throws -> UpdatedContent?
23-
@ServiceActor
2422
func promptToCode(editor: EditorContent) async throws -> UpdatedContent?
2523
@ServiceActor
2624
func customCommand(id: String, editor: EditorContent) async throws -> UpdatedContent?

Core/Sources/Service/SuggestionCommandHandler/WindowBaseCommandHandler.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,6 @@ struct WindowBaseCommandHandler: SuggestionCommandHandler {
262262
return try await presentSuggestions(editor: editor)
263263
}
264264

265-
func chatWithSelection(editor: EditorContent) async throws -> UpdatedContent? {
266-
Task { @MainActor in
267-
let store = Service.shared.guiController.store
268-
store.send(.createChatGPTChatTabIfNeeded)
269-
store.send(.openChatPanel(forceDetach: false))
270-
}
271-
return nil
272-
}
273-
274265
func promptToCode(editor: EditorContent) async throws -> UpdatedContent? {
275266
Task {
276267
do {

Core/Sources/Service/XPCService.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ public class XPCService: NSObject, XPCServiceProtocol {
144144
editorContent: Data,
145145
withReply reply: @escaping (Data?, Error?) -> Void
146146
) {
147-
replyWithUpdatedContent(editorContent: editorContent, withReply: reply) { handler, editor in
148-
try await handler.chatWithSelection(editor: editor)
149-
}
147+
let handler = PseudoCommandHandler()
148+
handler.openChat()
149+
reply(nil, nil)
150150
}
151151

152152
public func promptToCode(

0 commit comments

Comments
 (0)