Skip to content

Commit 83ee69e

Browse files
committed
Fix that an action was not sent from main thread
1 parent fde659e commit 83ee69e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Core/Sources/Service/SuggestionCommandHandler/WindowBaseCommandHandler.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,10 @@ extension WindowBaseCommandHandler {
285285

286286
switch command.feature {
287287
case .chatWithSelection, .customChat:
288-
GraphicalUserInterfaceController.shared.viewStore
289-
.send(.sendCustomCommandToActiveChat(command))
288+
Task { @MainActor in
289+
GraphicalUserInterfaceController.shared.viewStore
290+
.send(.sendCustomCommandToActiveChat(command))
291+
}
290292
case let .promptToCode(extraSystemPrompt, prompt, continuousMode, generateDescription):
291293
try await presentPromptToCode(
292294
editor: editor,

Core/Sources/SuggestionWidget/FeatureReducers/ChatPanelFeature.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ public struct ChatPanelFeature: ReducerProtocol {
1111
public var tabInfo: [ChatTabInfo]
1212
public var selectedTabId: String?
1313

14-
init(tabs: [BaseChatTab] = [], tabTypes: [String] = [], tabInfo: [ChatTabInfo] = [], selectedTabId: String? = nil) {
14+
init(
15+
tabs: [BaseChatTab] = [],
16+
tabTypes: [String] = [],
17+
tabInfo: [ChatTabInfo] = [],
18+
selectedTabId: String? = nil
19+
) {
1520
self.tabs = tabs
1621
self.tabTypes = tabTypes
1722
self.tabInfo = tabInfo
1823
self.selectedTabId = selectedTabId
1924
}
20-
25+
2126
public var activeChatTab: BaseChatTab? {
2227
guard let id = selectedTabId else { return tabs.first }
2328
guard let tab = tabs.first(where: { $0.id == id }) else { return tabs.first }
@@ -118,7 +123,7 @@ public struct ChatPanelFeature: ReducerProtocol {
118123
}
119124
state.chatTapGroup.selectedTabId = id
120125
return .none
121-
126+
122127
case let .appendAndSelectTab(tab):
123128
guard !state.chatTapGroup.tabInfo.contains(where: { $0.id == tab.id })
124129
else { return .none }

0 commit comments

Comments
 (0)