Skip to content

Commit 081ab92

Browse files
committed
fix(preview): reset result panel before loading new content #371
Add reset() function to McpChatResultPanel to clear previous content and reset UI state before displaying new response.
1 parent 1a134ab commit 081ab92

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

core/src/main/kotlin/cc/unitmesh/devti/mcp/editor/McpPreviewEditor.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ open class McpPreviewEditor(
237237
val result = StringBuilder()
238238
val stream: Flow<String> = llmProvider.stream(message, systemPrompt = config.createSystemPrompt())
239239

240+
// Reset the resultPanel before setting new content
241+
resultPanel.reset()
240242
resultPanel.setText("Loading response...")
241243
resultPanel.isVisible = true
242244
mainPanel.revalidate()

core/src/main/kotlin/cc/unitmesh/devti/mcp/ui/McpChatResultPanel.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ class McpChatResultPanel(private val project: Project, val config: McpChatConfig
7474
tabbedPane.preferredSize = Dimension(width, currentHeight)
7575
}
7676

77+
fun reset() {
78+
rawResultTextArea.text = ""
79+
80+
toolsPanel.removeAll()
81+
toolsPanel.revalidate()
82+
toolsPanel.repaint()
83+
84+
messageLogPanel.clear()
85+
86+
toolCalls = emptyList()
87+
88+
tabbedPane.selectedIndex = 0
89+
}
90+
7791
fun setText(text: String) {
7892
rawResultTextArea.text = text
7993
parseAndShowTools(text)

0 commit comments

Comments
 (0)