Skip to content

Commit be9a4ae

Browse files
committed
feat(mcp): add execution time display to chat results #371
Add execution time measurement and display in McpChatResultPanel. Includes UI panel for showing duration and necessary i18n strings.
1 parent cf8b970 commit be9a4ae

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ class McpChatResultPanel(private val project: Project, val config: McpChatConfig
232232
resultPanel.revalidate()
233233
resultPanel.repaint()
234234

235+
val startTime = System.currentTimeMillis()
236+
235237
SwingUtilities.invokeLater {
236238
val params = try {
237239
val jsonParams = json.encodeToString(toolCall.parameters)
@@ -247,8 +249,18 @@ class McpChatResultPanel(private val project: Project, val config: McpChatConfig
247249
} else {
248250
AutoDevBundle.message("mcp.chat.result.error.tool.not.found", toolCall.name)
249251
}
250-
252+
253+
val executionTime = System.currentTimeMillis() - startTime
251254
resultPanel.removeAll()
255+
256+
val timeInfoPanel = JPanel(FlowLayout(FlowLayout.LEFT)).apply {
257+
isOpaque = false
258+
add(JBLabel("${AutoDevBundle.message("mcp.chat.result.execution.time")}: ${executionTime}ms").apply {
259+
font = JBUI.Fonts.label(12f)
260+
foreground = JBColor(0x6B7280, 0x9DA0A8)
261+
})
262+
}
263+
252264
val textArea = JTextArea(result).apply {
253265
lineWrap = true
254266
wrapStyleWord = true
@@ -263,6 +275,7 @@ class McpChatResultPanel(private val project: Project, val config: McpChatConfig
263275
preferredSize = Dimension(0, 150) // Reasonable default height for results
264276
}
265277

278+
resultPanel.add(timeInfoPanel, BorderLayout.NORTH)
266279
resultPanel.add(resultScrollPane, BorderLayout.CENTER)
267280
resultPanel.isVisible = true
268281
resultPanel.revalidate()

core/src/main/resources/messages/AutoDevBundle_en.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,5 @@ mcp.chat.result.executing=Executing tool {0}...
243243
mcp.chat.result.error.tool.not.found=Error: Could not find matching tool ''{0}''
244244

245245
indexer.generate.domain=Generate domain.csv
246+
mcp.chat.result.execution.time=Duration
246247

core/src/main/resources/messages/AutoDevBundle_zh.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,5 @@ mcp.chat.result.no.tools=响应中未找到工具调用
234234
mcp.chat.result.execute=执行
235235
mcp.chat.result.executing=正在执行工具 {0}...
236236
mcp.chat.result.error.tool.not.found=错误:找不到匹配的工具 ''{0}''
237+
mcp.chat.result.execution.time=Duration
237238

0 commit comments

Comments
 (0)