Skip to content

Commit 814dfd0

Browse files
committed
refactor(ui): rename CombinedToolItem to ToolItem #453
Renames the CombinedToolItem composable and references to ToolItem for clarity and consistency across the codebase.
1 parent a4c30b6 commit 814dfd0

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/agent/AgentMessageList.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fun RenderMessageItem(
110110
}
111111

112112
is ComposeRenderer.TimelineItem.CombinedToolItem -> {
113-
CombinedToolItem(
113+
ToolItem(
114114
toolName = timelineItem.toolName,
115115
details = timelineItem.details,
116116
fullParams = timelineItem.fullParams,

mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/agent/ToolCallItem.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import cc.unitmesh.devins.ui.compose.terminal.PlatformTerminalDisplay
5050
*/
5151
@OptIn(ExperimentalLayoutApi::class)
5252
@Composable
53-
fun CombinedToolItem(
53+
fun ToolItem(
5454
toolName: String,
5555
details: String?,
5656
fullParams: String? = null,
@@ -132,13 +132,12 @@ fun CombinedToolItem(
132132
modifier = Modifier.Companion.size(16.dp)
133133
)
134134

135-
// Display tool name with query/path info for DocQL
136135
val displayToolName = when {
137136
toolName.lowercase() == "docql" && docqlStats != null -> {
138137
val query = docqlStats.query.take(30).let {
139138
if (docqlStats.query.length > 30) "$it..." else it
140139
}
141-
if (query.isNotEmpty()) "\"$query\" - DocQL" else "DocQL"
140+
if (query.isNotEmpty()) "DocQL - $query" else "DocQL"
142141
}
143142

144143
else -> toolName
@@ -153,7 +152,7 @@ fun CombinedToolItem(
153152

154153
val displaySummary = when {
155154
toolName.lowercase() == "docql" && docqlStats?.smartSummary != null ->
156-
docqlStats.smartSummary?.take(16)
155+
"${docqlStats.totalRawResults} results"
157156

158157
else -> summary
159158
}

mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/sketch/DevInBlockRenderer.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ package cc.unitmesh.devins.ui.compose.sketch
22

33
import androidx.compose.foundation.layout.Column
44
import androidx.compose.foundation.layout.Spacer
5-
import androidx.compose.foundation.layout.fillMaxWidth
65
import androidx.compose.foundation.layout.height
76
import androidx.compose.runtime.Composable
87
import androidx.compose.ui.Modifier
98
import androidx.compose.ui.unit.dp
109
import cc.unitmesh.agent.parser.ToolCallParser
1110
import cc.unitmesh.agent.tool.ToolType
12-
import cc.unitmesh.devins.ui.compose.agent.CombinedToolItem
11+
import cc.unitmesh.devins.ui.compose.agent.ToolItem
1312
import cc.unitmesh.devins.workspace.WorkspaceManager
1413
import kotlinx.serialization.json.Json
1514

1615
/**
1716
* DevIn Block Renderer - renders devin blocks as tool calls
18-
*
17+
*
1918
* Parses devin blocks (language id = "devin") and renders them as CombinedToolItem
2019
* when the block is complete.
2120
*/
@@ -35,27 +34,27 @@ fun DevInBlockRenderer(
3534
if (toolCalls.isNotEmpty()) {
3635
// Get workspace root path for resolving relative paths
3736
val workspaceRoot = WorkspaceManager.currentWorkspace?.rootPath
38-
37+
3938
toolCalls.forEach { toolCall ->
4039
// Extract details for rendering
4140
val toolName = toolCall.toolName
4241
val params = toolCall.params
43-
42+
4443
// Format details string (for display)
4544
val details = formatToolCallDetails(toolName, params)
46-
45+
4746
// Format full params as JSON (for expansion)
4847
val fullParams = formatParamsAsJson(params)
49-
48+
5049
// Extract file path if available (for ReadFile/WriteFile)
5150
// Resolve relative path to absolute path using workspace root
5251
val relativePath = params["path"] as? String
5352
val filePath = resolveAbsolutePath(relativePath, workspaceRoot)
54-
53+
5554
// Map tool name to ToolType
5655
val toolType = ToolType.fromName(toolName)
57-
58-
CombinedToolItem(
56+
57+
ToolItem(
5958
toolName = toolName,
6059
details = details,
6160
fullParams = fullParams,
@@ -67,7 +66,7 @@ fun DevInBlockRenderer(
6766
fullOutput = null,
6867
executionTimeMs = null
6968
)
70-
69+
7170
Spacer(modifier = Modifier.height(8.dp))
7271
}
7372
} else {
@@ -95,12 +94,12 @@ fun DevInBlockRenderer(
9594
private fun resolveAbsolutePath(relativePath: String?, workspaceRoot: String?): String? {
9695
if (relativePath == null) return null
9796
if (workspaceRoot == null) return relativePath
98-
97+
9998
// If already an absolute path, return as-is
10099
if (relativePath.startsWith("/") || relativePath.matches(Regex("^[A-Za-z]:.*"))) {
101100
return relativePath
102101
}
103-
102+
104103
// Combine workspace root with relative path
105104
val separator = if (workspaceRoot.endsWith("/") || workspaceRoot.endsWith("\\")) "" else "/"
106105
return "$workspaceRoot$separator$relativePath"

mpp-ui/src/jvmMain/kotlin/cc/unitmesh/devins/ui/compose/agent/test/AgentMessageListPreviews.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import androidx.compose.ui.Modifier
99
import cc.unitmesh.devins.llm.Message
1010
import cc.unitmesh.devins.llm.MessageRole
1111
import cc.unitmesh.devins.ui.compose.agent.AgentMessageList
12-
import cc.unitmesh.devins.ui.compose.agent.CombinedToolItem
12+
import cc.unitmesh.devins.ui.compose.agent.ToolItem
1313
import cc.unitmesh.devins.ui.compose.agent.ComposeRenderer
1414
import cc.unitmesh.devins.ui.compose.agent.CurrentToolCallItem
1515
import cc.unitmesh.devins.ui.compose.agent.ToolErrorItem
@@ -116,7 +116,7 @@ fun Preview_CurrentToolCallItem() {
116116
fun Preview_CombinedToolItem_FileRead() {
117117
MaterialTheme {
118118
Surface {
119-
CombinedToolItem(
119+
ToolItem(
120120
toolName = "src/Main.kt - ReadFile",
121121
details = "path=src/Main.kt",
122122
fullParams = "path=src/Main.kt encoding=utf-8",

0 commit comments

Comments
 (0)