Skip to content

Commit 6e18ba8

Browse files
committed
refactor(devti): improve code structure for sending to chat panel
- Restructure the code to run in EDT (Event Dispatch Thread) for UI operations - Optimize the activation of the tool window - Enhance readability and maintainability of the sendToChatPanel function
1 parent 8a9c6a9 commit 6e18ba8

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

core/src/main/kotlin/cc/unitmesh/devti/gui/SendToWindow.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ fun sendToChatWindow(
2222
return
2323
}
2424

25-
val contentPanel = AutoDevToolWindowFactory.labelNormalChat(chatCodingService) ?: run {
26-
logger<ChatCodingService>().warn("Content panel not found")
27-
return
28-
}
25+
runInEdt {
26+
toolWindowManager.activate {
27+
val contentPanel = AutoDevToolWindowFactory.labelNormalChat(chatCodingService) ?: run {
28+
logger<ChatCodingService>().warn("Content panel not found")
29+
return@activate
30+
}
2931

30-
toolWindowManager.activate {
31-
runInEdt {
3232
runnable(contentPanel, chatCodingService)
3333
}
3434
}
@@ -39,7 +39,11 @@ fun sendToChatPanel(project: Project, runnable: (NormalChatCodingPanel, ChatCodi
3939
sendToChatWindow(project, actionType, runnable)
4040
}
4141

42-
fun sendToChatPanel(project: Project, actionType: ChatActionType, runnable: (NormalChatCodingPanel, ChatCodingService) -> Unit) {
42+
fun sendToChatPanel(
43+
project: Project,
44+
actionType: ChatActionType,
45+
runnable: (NormalChatCodingPanel, ChatCodingService) -> Unit
46+
) {
4347
sendToChatWindow(project, actionType, runnable)
4448
}
4549

0 commit comments

Comments
 (0)