Repository navigation
feat(mpp-idea): enhance CodingAgent with MCP preloading and tool status - #5
Conversation
- JewelRenderer: Add TaskInfo/TaskStatus for task-boundary tool support, TerminalOutputItem for shell commands, improved token tracking, forceStop() method, and tool call formatting helpers - IdeaAgentViewModel: Add MCP server preloading, tool loading status, builtin commands (/clear, /help, /status), executeTask/cancelTask methods, and ToolLoadingStatus data class - IdeaAgentApp: Add ToolLoadingStatusBar, ToolStatusChip, TerminalOutputBubble components for enhanced UI - Add unit tests for JewelRenderer and IdeaAgentViewModel Aligned with mpp-ui's CodingAgentViewModel for feature parity.
WalkthroughAdds task-tracking, terminal output capture, richer tool-call/result modeling, MCP preloading and tool-loading status, built-in command handling, and new UI components; view model orchestration and renderer state flows were extended and tests added to cover behaviors. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant VM as IdeaAgentViewModel
participant Config as ConfigManager
participant Mcp as McpToolConfigManager
participant Agent as CodingAgent
participant Renderer as JewelRenderer
User->>VM: executeTask(task)
alt Not configured
VM->>User: invoke onConfigRequired callback (UI)
User->>VM: provides config
end
VM->>Renderer: emit user MessageItem
VM->>Agent: start execution (with tool config)
par MCP Preloading (may run earlier/parallel)
VM->>Config: load MCP config
Config-->>VM: config
VM->>Mcp: initialize MCP servers/tools
Mcp-->>VM: server/tool ready
VM->>Renderer: emit preloading status updates
end
loop Agent execution steps
Agent->>Renderer: emit ToolCallItem
Renderer->>Renderer: format ToolCallItem (formatToolCallDisplay/parseParamsString)
Agent->>Renderer: emit ToolResult
alt Shell live session
Renderer->>Renderer: append TerminalOutputItem entries
else Non-shell result
Renderer->>Renderer: update last ToolCallItem with summary, output
end
end
Agent-->>VM: task complete
VM->>Renderer: emit TaskCompleteItem / update tasks StateFlow
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
| if (toolType == ToolType.Shell && output != null) { | ||
| val exitCode = liveExitCode ?: (if (success) 0 else 1) | ||
| val executionTimeMs = executionTime ?: 0L | ||
| val command = _currentToolCall.value?.details?.removePrefix("Executing: ") ?: "unknown" |
There was a problem hiding this comment.
_currentToolCall is set to null earlier in this method, so val command = _currentToolCall.value?.details... will always resolve to "unknown"; consider deriving the command from the last tool call item or capturing it before clearing to keep terminal output accurate.
🤖 Was this useful? React with 👍 or 👎
| modifier: Modifier = Modifier | ||
| ) { | ||
| val mcpPreloadingMessage by viewModel.mcpPreloadingMessage.collectAsState() | ||
| val toolStatus = remember(viewModel) { viewModel.getToolLoadingStatus() } |
There was a problem hiding this comment.
toolStatus is created with remember(viewModel) and won’t update as MCP preloading progresses; consider deriving it from state (e.g., flows) so the status bar reflects live changes.
🤖 Was this useful? React with 👍 or 👎
| fun executeTask(task: String, onConfigRequired: (() -> Unit)? = null) { | ||
| if (_isExecuting.value) return | ||
|
|
||
| if (!isConfigured()) { |
There was a problem hiding this comment.
Builtin commands like /clear and /help are gated behind the LLM configuration check, which prevents them from working when not configured; consider handling builtin commands before the config check so they remain usable.
🤖 Was this useful? React with 👍 or 👎
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (7)
mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt (2)
83-116: Add test coverage for expanded ToolCallItem fields mentioned in PR objectives.The PR objectives mention that ToolCallItem is expanded with new fields:
description,fullParams,filePath, andtoolType. However, the test suite does not verify these fields are present or correctly populated. Consider adding assertions to verify:
- That these fields exist on ToolCallItem
- That they are populated from the tool call parameters when appropriate
This will ensure the PR delivers the full set of enhancements described.
1-26: Consider adding test for TerminalOutputItem rendering.The PR objectives mention that JewelRenderer now supports
TerminalOutputItemfor shell command outputs, but there is no test coverage for this feature. The test suite should include at least one test that verifies terminal output items are rendered correctly to the timeline (e.g., when a tool result contains shell output).This gap suggests incomplete validation of one of the key features mentioned in the PR objectives.
mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.kt (3)
80-93: Test assertion may not match expected behavior.The
/clearcommand callsrenderer.clearTimeline()thenrenderer.renderFinalResult(). The assertionassertTrue(timeline.isNotEmpty())passes becauserenderFinalResultadds aTaskCompleteItem, but the test comment says "Timeline should contain command result" which is accurate. However, the test first adds a message, executes/clear, but doesn't verify the original message was actually cleared—only that something remains.Consider strengthening the assertion:
// Execute /clear command viewModel.executeTask("/clear", null) // Wait a bit for the command to execute Thread.sleep(100) - // Timeline should contain command result - val timeline = viewModel.renderer.timeline.first() - assertTrue(timeline.isNotEmpty()) + // Timeline should only contain the command result, not the original message + val timeline = viewModel.renderer.timeline.first() + assertEquals(1, timeline.size) + assertTrue(timeline.first() is JewelRenderer.TimelineItem.TaskCompleteItem)
86-88: Consider replacingThread.sleepwith deterministic waiting.Using
Thread.sleep(100)for async operations can lead to flaky tests, especially under CI load. Consider usingadvanceUntilIdle()from kotlinx-coroutines-test or polling with a timeout for more reliable tests.
149-154: Weak assertion fortestIsConfigured.
assertNotNull(isConfigured)on aBooleanreturn type is redundant since Kotlin'sBooleanis never null. The test only verifies the method doesn't throw, not its actual behavior.fun testIsConfigured() { - // Initially may or may not be configured (depends on config file) - val isConfigured = viewModel.isConfigured() - // Just verify it doesn't throw - assertNotNull(isConfigured) + // Initially not configured (no config file in test environment) + val isConfigured = viewModel.isConfigured() + // LLM service should be null in test environment without config + assertFalse(isConfigured) }mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt (2)
315-341: Reduce code duplication in command handling.The
elsebranch duplicates most ofexecuteTask's logic. Consider refactoring to callexecuteTaskdirectly or extracting the common execution logic:else -> { if (!isConfigured()) { renderer.renderError("WARNING: LLM model is not configured. Please configure your model to continue.") onConfigRequired?.invoke() return } - // Treat as a regular task - _isExecuting.value = true - currentJob = coroutineScope.launch { - try { - val agent = initializeCodingAgent() - val projectPath = project.basePath ?: System.getProperty("user.home") - val agentTask = AgentTask( - requirement = command, - projectPath = projectPath - ) - agent.executeTask(agentTask) - } catch (e: Exception) { - renderer.renderError(e.message ?: "Unknown error") - } finally { - _isExecuting.value = false - currentJob = null - } - } + // Treat as a regular task - delegate to common execution path + executeTaskInternal(command) }
388-393: Simplify redundant conditional.The conditional
if (enabledMcpToolsCount > 0) enabledMcpToolsCount else 0always returnsenabledMcpToolsCountsincesizeis never negative:val mcpToolsEnabled = if (McpToolConfigManager.isPreloading()) { 0 } else { - val enabledMcpToolsCount = toolConfig?.enabledMcpTools?.size ?: 0 - if (enabledMcpToolsCount > 0) enabledMcpToolsCount else 0 + toolConfig?.enabledMcpTools?.size ?: 0 }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt(11 hunks)mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt(6 hunks)mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt(12 hunks)mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt(1 hunks)mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.kt(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.kt
📄 CodeRabbit inference engine (AGENTS.md)
**/*.kt: Useexpect/actualfor platform-specific code in Kotlin Multiplatform (e.g., file I/O on JVM/JS/Wasm)
Check export first; if some functions are not working well with CLI (TypeScript), verify the export configuration
In Kotlin/JS @JsExport: avoidFlow, usePromiseinstead
In Kotlin/JS @JsExport: use concrete classes as return types and parameter types, avoid interface types as JS cannot handle type conversion correctly
For WASM platform, do not use emoji and UTF-8 in code
Files:
mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.ktmpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt
**/*.{kt,kts}
📄 CodeRabbit inference engine (AGENTS.md)
For Compose (Desktop/Android), use
AutoDevColorsfromcc.unitmesh.devins.ui.compose.themeorMaterialTheme.colorScheme
Files:
mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.ktmpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt
**/*.{ts,tsx,kt,kts}
📄 CodeRabbit inference engine (AGENTS.md)
DO NOT hardcode colors (e.g.,
Color(0xFF...)or#hex). Always use design tokens for consistency across platforms
Files:
mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.ktmpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt
🧠 Learnings (2)
📚 Learning: 2025-11-29T14:07:19.001Z
Learnt from: CR
Repo: phodal/auto-dev-sketch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-29T14:07:19.001Z
Learning: See `docs/design-system-compose.md` for Kotlin Compose color design system documentation
Applied to files:
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
📚 Learning: 2025-11-29T14:07:19.001Z
Learnt from: CR
Repo: phodal/auto-dev-sketch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-29T14:07:19.001Z
Learning: Applies to **/*.{kt,kts} : For Compose (Desktop/Android), use `AutoDevColors` from `cc.unitmesh.devins.ui.compose.theme` or `MaterialTheme.colorScheme`
Applied to files:
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt
🧬 Code graph analysis (2)
mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt (1)
mpp-core/src/commonMain/kotlin/cc/unitmesh/devins/test/DevInsTestCase.kt (5)
assertTrue(29-33)assertFalse(38-40)assertEquals(45-49)assertNotNull(54-59)assertNull(64-68)
mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.kt (1)
mpp-core/src/commonMain/kotlin/cc/unitmesh/devins/test/DevInsTestCase.kt (4)
assertEquals(45-49)assertNotNull(54-59)assertTrue(29-33)assertFalse(38-40)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build (241)
- GitHub Check: Build (223)
🔇 Additional comments (9)
mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt (3)
96-116: Verify currentToolCall state management in renderToolResult.The test assumes that after calling
renderToolResult(),currentToolCallbecomesnull(line 108). Verify that this is the intended behavior and that the renderToolResult method properly clears the current tool call state after applying the result.
203-211: I'll help you verify the test assumptions. Let me search for the relevant implementation details.
<function_calls>
1
#!/bin/bashSearch for task-boundary handling and TaskStatus enum
First, find the test file to understand its context
rg -B 3 -A 10 'task-boundary' --type kotlin
echo "---"
Search for TaskStatus enum
rg -A 10 'enum class TaskStatus|object TaskStatus' --type kotlin
echo "---"
Search for TaskInfo data class
rg -A 5 'data class TaskInfo|class TaskInfo' --type kotlin
</function_calls>
<function_calls>
2
#!/bin/bashFind the JewelRenderer class and renderToolCall method
rg -B 2 -A 15 'fun renderToolCall' --type kotlin
echo "---"
Search for tasks StateFlow definition in JewelRenderer
rg -B 2 -A 5 'val tasks\s*[:=]' --type kotlin
</function_calls>Let me search more broadly for the JewelRenderer implementation:
<function_calls>
3
#!/bin/bashLocate JewelRenderer class file
fd -name "*.kt" -type f | xargs rg -l "class JewelRenderer"
echo "---"
Get more context on renderToolCall
rg -B 5 -A 20 'renderToolCall.*=' --type kotlin | head -100
</function_calls><function_calls>
4
#!/bin/bashSearch more specifically for task-boundary string literal
rg 'task-boundary' --type kotlin -C 5
echo "=== TaskStatus enum search ==="
rg 'enum.*TaskStatus|TaskStatus.*enum' --type kotlin -A 10
</function_calls><function_calls>
5
#!/bin/bashLet's find the JewelRenderer file first
find . -name "JewelRenderer.kt" -o -name "JewelRenderer" | grep -v ".git"
echo "---"
Also check test file structure
cat -n mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt | head -50
</function_calls><function_calls>
6
#!/bin/bashCheck the test file to find imports and understand the structure
rg -A 200 'package cc.unitmesh.devins.idea.renderer' mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt | head -150
</function_calls><function_calls>
7
#!/bin/bashGet the entire test file to understand the full context
wc -l mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt
Show key sections
echo "=== Lines 1-100 ==="
head -100 mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt
</function_calls><function_calls>
8
#!/bin/bashShow the specific test and surrounding context
sed -n '195,215p' mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt
</function_calls><function_calls>
9
#!/bin/bashFind JewelRenderer class in the main source
find mpp-idea/src/main -name "*.kt" | xargs rg -l "class JewelRenderer"
echo "---"
Also search the entire repository
find . -name ".kt" -type f ! -path "./.git/" | xargs rg -l "class JewelRenderer" 2>/dev/null
</function_calls><function_calls>
10
#!/bin/bashCheck the full test file first few lines for package and imports
head -60 mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt
</function_calls><function_calls>
11
#!/bin/bashLook for JewelRenderer in imports and see where it's from
rg 'JewelRenderer' mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt | head -20
echo "---"
Search for any JewelRenderer definition anywhere
rg 'class JewelRenderer' . --type kotlin 2>/dev/null
</function_calls><function_calls>
12
#!/bin/bashList files in the mpp-idea/src/main directory to find the right location
find mpp-idea/src/main -name "*.kt" | grep -i renderer
echo "---"
Also check if there's a different base directory structure
ls -la mpp-idea/src/ 2>/dev/null || echo "mpp-idea structure not found"
Try broader search
find . -path "./.git" -prune -o -name "Renderer.kt" -type f -print 2>/dev/null | head -20
</function_calls><function_calls>
13
#!/bin/bashCheck directory structure at mpp-idea
ls -la mpp-idea/ 2>/dev/null || ls -la . | head -20
</function_calls><function_calls>
14
#!/bin/bashShow current location and repository structure
pwd
echo "=== Root files ==="
ls -1 | head -20echo "=== Check if file exists ==="
test -f "mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt" && echo "File exists" || echo "File does not exist"
</function_calls><function_calls>
15
#!/bin/bashFind all kotlin test files with JewelRenderer references
find . -name "*Test.kt" -type f 2>/dev/null | xargs grep -l "JewelRenderer" 2>/dev/null
echo "---"
Search for the actual file path
find . -name "JewelRendererTest.kt" 2>/dev/null
</function_calls><function_calls>
16
#!/bin/bashBroader search for task-boundary in all files
rg 'task-boundary' . --type kotlin 2>/dev/null
echo "---"
Search for TaskStatus and TaskInfo
rg 'TaskStatus|TaskInfo' . --type kotlin 2>/dev/null | head -30
</function_calls><function_calls>
17
#!/bin/bashGet all kotlin files related to rendering
find . -path "./.git" -prune -o -name "*.kt" -type f -print 2>/dev/null | xargs grep -l "renderToolCall|task-boundary" 2>/dev/null
</function_calls><function_calls>
18
#!/bin/bashList all kotlin files to understand structure
find . -name "*.kt" -type f 2>/dev/null | head -40
</function_calls><function_calls>
19
#!/bin/bashCheck git ls-files to see what files are in the repo
git ls-files "*.kt" | head -40
</function_calls><function_calls>
20
#!/bin/bashSearch specifically for the test file in git
git ls-files | grep -i "jewel.*test|renderer.*test"
echo "---"
Look for all renderer related files
git ls-files | grep -i renderer
</function_calls><function_calls>
21
#!/bin/bashGet file content using git
git show HEAD:mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt 2>/dev/null | head -100
</function_calls><function_calls>
22
#!/bin/bashShow the test method and related code
git show HEAD:mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt 2>/dev/null | sed -n '200,220p'
</function_calls><function_calls>
23
#!/bin/bashSearch for JewelRenderer implementation file
git ls-files | grep -i jewel
echo "---"
Search for renderToolCall implementation
git ls-files "*.kt" | xargs grep -l "renderToolCall" 2>/dev/null
</function_calls><function_calls>
24
#!/bin/bashSearch for task-boundary in git tracked files
git ls-files "*.kt" | xargs grep -l "task-boundary" 2>/dev/null
echo "---"
Search for TaskStatus enum
git ls-files "*.kt" | xargs grep -B 2 -A 5 "enum.*TaskStatus" 2>/dev/null
</function_calls><function_calls>
25
#!/bin/bashGet the full test file content
git show HEAD:mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt 2>/dev/null | wc -l
echo "=== Full imports and setup ==="
git show HEAD:mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt 2>/dev/null | head -80
</function_calls><function_calls>
26
#!/bin/bashShow entire test file
git show HEAD:mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt 2>/dev/null
</function_calls><function_calls>
27
#!/bin/bashFind the JewelRenderer source file
git ls-files "*.kt" | xargs grep -l "class JewelRenderer" 2>/dev/null
echo "---"
Show the content of the renderer class
git ls-files "*.kt" | xargs grep -B 5 -A 30 "class JewelRenderer" 2>/dev/null | head -200
</function_calls><function_calls>
28
#!/bin/bashFind renderToolCall implementation
git ls-files "*.kt" | xargs grep -B 3 -A 20 "fun renderToolCall" 2>/dev/null | head -150
</function_calls><function_calls>
29
#!/bin/bashSearch for tasks StateFlow and task-boundary handling
git ls-files "*.kt" | xargs grep -B 3 -A 10 '"task-boundary"' 2>/dev/null
</function_calls><function_calls>
30
#!/bin/bashFind TaskInfo and TaskStatus definitions
git ls-files "*.kt" | xargs grep -B 2 -A 10 "data class TaskInfo|class TaskInfo" 2>/dev/null
echo "=== TaskStatus enum ==="
git ls-files "*.kt" | xargs grep -B 2 -A 10 "enum class TaskStatus" 2>/dev/null
</function_calls>Let me try a more focused approach with Python to parse the git files:
<function_calls>
31
#!/bin/bash
python3 << 'EOF'
import subprocess
import reGet all kotlin files
result = subprocess.run(['git', 'ls-files', '*.kt'], capture_output=True, text=True)
files = result.stdout.strip().split('\n')Search for key patterns
key_patterns = {
'task-boundary': [],
'TaskStatus': [],
'TaskInfo': [],
'renderToolCall': [],
'class JewelRenderer': []
}for file in files:
if not file:
continue
try:
content = subprocess.run(['git', 'show', f'HEAD:{file}'],
capture_output=True, text=True, timeout=5)
if content.returncode == 0:
text = content.stdout
for pattern in key_patterns.keys():
if pattern in text:
key_patterns[pattern].append(file)
except:
passfor pattern, files_list in key_patterns.items():
if files_list:
print(f"\n{pattern}: Found in {len(files_list)} file(s)")
for f in files_list[:5]:
print(f" - {f}")
EOF
</function_calls><function_calls>
32
#!/bin/bashNow let's examine the actual files that contain these patterns
echo "=== Searching for task-boundary files ==="
git ls-files "*.kt" | xargs grep -l 'task-boundary' 2>/dev/nullecho ""
echo "=== Searching for TaskStatus files ==="
git ls-files "*.kt" | xargs grep -l 'TaskStatus' 2>/dev/nullecho ""
echo "=== Show file with task-boundary ==="
git ls-files "*.kt" | xargs grep -l 'task-boundary' 2>/dev/null | head -1 | xargs -I {} git show HEAD:{} 2>/dev/null | head -250
</function_calls><function_calls>
33
#!/bin/bashGet the test file and the main renderer file
echo "=== JewelRendererTest.kt ==="
git show HEAD:mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt 2>/dev/nullecho ""
echo "=== Files containing renderToolCall ==="
git ls-files "*.kt" | xargs grep -l 'renderToolCall' 2>/dev/null
</function_calls><function_calls>
34
#!/bin/bashShow the JewelRenderer implementation
git ls-files "*.kt" | xargs grep -l 'class JewelRenderer' 2>/dev/null | xargs -I {} git show HEAD:{} 2>/dev/null
</function_calls>Perfect! Now I have all the necessary information. Let me analyze the results:
All test assumptions verified and correct.
The test expectations are properly founded:
- The
renderToolCall("task-boundary", ...)method correctly parses the parameter string to extracttaskName,status, andsummaryfieldsJewelRenderer.TaskStatusenum exists withWORKINGvalue (plusNOT_STARTED,COMPLETED,FAILED)- The
tasksStateFlow is properly updated with aTaskInfoobject containing the parsed values- Status string conversion ("WORKING" →
TaskStatus.WORKING) is handled correctly during parsingNo issues found with the test logic or assumptions.
83-94: Based on my verification of the codebase, I can now provide the rewritten review comment.The review comment's concern about parameter parsing is unfounded—the test assertion is correct and the contract is clear.
The test correctly expects
currentToolCall.toolNameto contain "file.txt". Here's why:
parseParamsString("path=\"/test/file.txt\"")correctly extractsparams["path"] = "/test/file.txt"using a regex pattern that handles quoted values.
formatToolCallDisplay("read-file", "path=\"/test/file.txt\"")formats the display name as:
"${params["path"]} - ${toolType.displayName}"(line 476 of JewelRenderer.kt)- This produces:
/test/file.txt - Read FileThis formatted name is stored in
currentToolCall.toolName, which therefore contains "file.txt" as expected.The test is well-designed and the assertion is not fragile—it accurately verifies the intended behavior of parameter extraction and display formatting for file-based tool calls.
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt (3)
532-543: Parameter parsing may miss edge cases.The regex handles
key="value"andkey=valuepatterns but won't correctly parse:
- Escaped quotes:
path="file with \"quotes\""- Values with equals signs:
query="a=b"- Multiline values
This is likely acceptable for typical tool parameters, but consider adding a fallback or documenting the limitations if complex params are expected.
331-352: LGTM!The immutable list update pattern correctly identifies and updates the last pending
ToolCallItemwith its result.
144-156: LGTM!The
TaskStatusenum with case-insensitive parsing and a sensible default is well-implemented.mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt (1)
354-361: LGTM!The cancellation logic correctly cancels the job, clears state, and calls
forceStop()on the renderer.mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt (2)
163-166: LGTM!The
TimelineItemViewcorrectly handles the newTerminalOutputItemvariant.
101-105: LGTM!Good update to use
isExecutingstate andcancelTask()for the abort action.
- Fix _currentToolCall null bug by capturing value before clearing - Replace hardcoded colors with AutoDevColors design tokens - Make toolStatus reactive to mcpPreloadingStatus changes - Handle builtin commands (/clear, /help, /status) before config check - Add 60s timeout to MCP preloading loop to prevent infinite loop - Improve forceStop test assertion with explicit message verification - Add mpp-idea build instructions to AGENTS.md
|
augment review |
| } else { | ||
| McpToolConfigManager.getTotalDiscoveredTools() | ||
| } | ||
|
|
There was a problem hiding this comment.
In getToolLoadingStatus(), both subAgentsEnabled and subAgentsTotal derive from subAgentTools.size, so the SubAgents chip will always show X/X regardless of what's actually enabled; consider distinguishing enabled vs total if configuration supports toggling.
🤖 Was this useful? React with 👍 or 👎
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt (3)
142-151: Consider checking coroutine cancellation in the polling loop.The timeout prevents infinite loops, but the loop doesn't check for coroutine cancellation. If
loadConfigurationis called again while preloading, or if the ViewModel is disposed, the coroutine may not exit promptly.// Monitor preloading status with timeout to prevent infinite loop val timeoutMs = 60_000L // 60 seconds max val startTime = System.currentTimeMillis() - while (McpToolConfigManager.isPreloading() && - (System.currentTimeMillis() - startTime) < timeoutMs - ) { + while (isActive && McpToolConfigManager.isPreloading() && + (System.currentTimeMillis() - startTime) < timeoutMs) { _mcpPreloadingStatus.value = McpToolConfigManager.getPreloadingStatus() _mcpPreloadingMessage.value = "Loading MCP servers... (${_mcpPreloadingStatus.value.preloadedServers.size} completed)" delay(500) }Note: You'll need to import
kotlinx.coroutines.isActiveor usecoroutineContext.isActive.
276-280: Unused variableargs.The
argsvariable is extracted but never used in any of the command handlers. Consider removing it if command arguments aren't needed, or implement argument handling if planned.private fun handleBuiltinCommand(command: String, onConfigRequired: (() -> Unit)? = null) { val parts = command.substring(1).trim().split("\\s+".toRegex()) val commandName = parts[0].lowercase() - val args = parts.drop(1).joinToString(" ") renderer.addUserMessage(command)
386-391: Redundant conditional logic.The conditional at lines 389-390 is redundant since
sizeis always non-negative.val mcpToolsEnabled = if (McpToolConfigManager.isPreloading()) { 0 } else { - val enabledMcpToolsCount = toolConfig?.enabledMcpTools?.size ?: 0 - if (enabledMcpToolsCount > 0) enabledMcpToolsCount else 0 + toolConfig?.enabledMcpTools?.size ?: 0 }mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt (1)
534-545: Regex may miss values with spaces that aren't quoted.The regex
(\w+)="([^"]*)"|\s*(\w+)=([^\s]+)handles quoted values and unquoted values without spaces, but won't correctly parse unquoted values containing spaces (e.g.,path=foo bar). This is likely acceptable since parameters should typically be quoted when containing spaces.If you want to handle more edge cases, consider using a JSON-like parameter format or a more robust parser. The current implementation is sufficient for well-formed inputs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
AGENTS.md(1 hunks)mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt(10 hunks)mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt(6 hunks)mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt(12 hunks)mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- AGENTS.md
🚧 Files skipped from review as they are similar to previous changes (1)
- mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt
🧰 Additional context used
📓 Path-based instructions (3)
**/*.kt
📄 CodeRabbit inference engine (AGENTS.md)
**/*.kt: Useexpect/actualfor platform-specific code in Kotlin Multiplatform (e.g., file I/O on JVM/JS/Wasm)
Check export first; if some functions are not working well with CLI (TypeScript), verify the export configuration
In Kotlin/JS @JsExport: avoidFlow, usePromiseinstead
In Kotlin/JS @JsExport: use concrete classes as return types and parameter types, avoid interface types as JS cannot handle type conversion correctly
For WASM platform, do not use emoji and UTF-8 in code
Files:
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
**/*.{kt,kts}
📄 CodeRabbit inference engine (AGENTS.md)
For Compose (Desktop/Android), use
AutoDevColorsfromcc.unitmesh.devins.ui.compose.themeorMaterialTheme.colorScheme
Files:
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
**/*.{ts,tsx,kt,kts}
📄 CodeRabbit inference engine (AGENTS.md)
DO NOT hardcode colors (e.g.,
Color(0xFF...)or#hex). Always use design tokens for consistency across platforms
Files:
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
🧠 Learnings (3)
📚 Learning: 2025-11-29T14:07:19.001Z
Learnt from: CR
Repo: phodal/auto-dev-sketch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-29T14:07:19.001Z
Learning: Applies to **/*.{kt,kts} : For Compose (Desktop/Android), use `AutoDevColors` from `cc.unitmesh.devins.ui.compose.theme` or `MaterialTheme.colorScheme`
Applied to files:
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.ktmpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
📚 Learning: 2025-11-29T14:07:19.001Z
Learnt from: CR
Repo: phodal/auto-dev-sketch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-29T14:07:19.001Z
Learning: Applies to **/*.{ts,tsx,kt,kts} : DO NOT hardcode colors (e.g., `Color(0xFF...)` or `#hex`). Always use design tokens for consistency across platforms
Applied to files:
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
📚 Learning: 2025-11-29T14:07:19.001Z
Learnt from: CR
Repo: phodal/auto-dev-sketch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-29T14:07:19.001Z
Learning: See `docs/design-system-compose.md` for Kotlin Compose color design system documentation
Applied to files:
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build (241)
- GitHub Check: Build (223)
🔇 Additional comments (17)
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt (4)
49-54: Good backward compatibility approach.Using
isProcessingas an alias getter for_isExecutingmaintains API compatibility while renaming the internal state.
96-120: LGTM!Configuration loading flow properly chains LLM service creation with MCP preloading initialization.
229-270: LGTM!The execution flow correctly handles builtin commands before the configuration check, ensuring
/clear,/help, and/statuswork without LLM configuration. Exception handling properly distinguishes user cancellation from other errors.
446-458: LGTM!Clean data class definition with sensible defaults for representing tool loading status.
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt (6)
39-114: LGTM!The main composable properly integrates with the ViewModel's new state flows (
isExecuting,mcpPreloadingMessage) and adds the tool loading status bar. The layout structure is clean and well-organized.
145-167: LGTM!Clean integration of
TerminalOutputItemrendering into the timeline view.
428-484: LGTM!The terminal output bubble correctly uses
AutoDevColorsdesign tokens for all colors, addressing the previous hardcoded colors concern and complying with coding guidelines.
486-546: LGTM!The status bar properly recomputes
toolStatuswhenmcpPreloadingStatuschanges, addressing the previous reactivity concern. Color usage follows the design system.
548-584: LGTM!Clean chip component with good UX consideration for displaying unknown totals with "∞".
586-645: LGTM!Good UX improvement with the updated placeholder text guiding users to
/helpfor available commands.mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt (7)
24-72: LGTM!Clean StateFlow-based state management with proper encapsulation of internal state (
_lastMessageTokenInfo) versus public observable state.
74-156: LGTM!Well-designed data structures with the expanded
ToolCallItemand newTerminalOutputItemfor richer timeline rendering. TheTaskStatusenum withfromStringcompanion function provides clean status parsing.
191-208: LGTM!Proper association of token info with assistant messages, with clean reset after use.
210-247: LGTM!Clean tool call rendering with proper delegation to helper functions and special handling for task-boundary tools.
278-355: LGTM!The tool result rendering properly captures the current tool call info before clearing it, addressing the previous bug. The shell command handling with distinct paths for live sessions vs. regular execution is well-implemented.
403-413: LGTM!Clean token accumulation with proper StateFlow update pattern.
448-466: LGTM!Clean force stop implementation that preserves partial output with an
[Interrupted]marker for user clarity.
| _isExecuting.value = true | ||
| currentJob = coroutineScope.launch { | ||
| try { | ||
| val agent = initializeCodingAgent() | ||
| val projectPath = project.basePath ?: System.getProperty("user.home") | ||
| val agentTask = AgentTask( | ||
| requirement = command, | ||
| projectPath = projectPath | ||
| ) | ||
| agent.executeTask(agentTask) | ||
| } catch (e: Exception) { | ||
| renderer.renderError(e.message ?: "Unknown error") | ||
| } finally { | ||
| _isExecuting.value = false | ||
| currentJob = null | ||
| } | ||
| } |
There was a problem hiding this comment.
Inconsistent exception handling for unknown commands.
The else branch for unknown commands catches only Exception, missing the CancellationException handling present in executeTask(). This means cancelling an unknown command won't call forceStop() or show "Task cancelled by user".
currentJob = coroutineScope.launch {
try {
val agent = initializeCodingAgent()
val projectPath = project.basePath ?: System.getProperty("user.home")
val agentTask = AgentTask(
requirement = command,
projectPath = projectPath
)
agent.executeTask(agentTask)
+ } catch (e: CancellationException) {
+ renderer.forceStop()
+ renderer.renderError("Task cancelled by user")
} catch (e: Exception) {
renderer.renderError(e.message ?: "Unknown error")
} finally {
_isExecuting.value = false
currentJob = null
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| _isExecuting.value = true | |
| currentJob = coroutineScope.launch { | |
| try { | |
| val agent = initializeCodingAgent() | |
| val projectPath = project.basePath ?: System.getProperty("user.home") | |
| val agentTask = AgentTask( | |
| requirement = command, | |
| projectPath = projectPath | |
| ) | |
| agent.executeTask(agentTask) | |
| } catch (e: Exception) { | |
| renderer.renderError(e.message ?: "Unknown error") | |
| } finally { | |
| _isExecuting.value = false | |
| currentJob = null | |
| } | |
| } | |
| _isExecuting.value = true | |
| currentJob = coroutineScope.launch { | |
| try { | |
| val agent = initializeCodingAgent() | |
| val projectPath = project.basePath ?: System.getProperty("user.home") | |
| val agentTask = AgentTask( | |
| requirement = command, | |
| projectPath = projectPath | |
| ) | |
| agent.executeTask(agentTask) | |
| } catch (e: CancellationException) { | |
| renderer.forceStop() | |
| renderer.renderError("Task cancelled by user") | |
| } catch (e: Exception) { | |
| renderer.renderError(e.message ?: "Unknown error") | |
| } finally { | |
| _isExecuting.value = false | |
| currentJob = null | |
| } | |
| } |
🤖 Prompt for AI Agents
In
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt
around lines 321 to 337, the unknown-command branch only catches Exception and
thus swallows CancellationException; update the try/catch to add a specific
catch for CancellationException that calls the agent.forceStop() (or appropriate
cleanup), invokes the renderer to show "Task cancelled by user", and then
rethrows the CancellationException to allow proper coroutine cancellation; keep
the existing generic Exception catch for other errors and preserve the finally
block that clears _isExecuting and currentJob.
Summary
This PR enhances the mpp-idea module's CodingAgent implementation to align with mpp-ui's
CodingAgentViewModelandAgentChatInterfacefor feature parity.Changes
JewelRenderer (
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt)TaskInfoandTaskStatusdata classes to support thetask-boundarytool's task state updatesTerminalOutputItemfor displaying Shell command outputsToolCallItemnow includes more fields (description, fullParams, filePath, toolType) to match ComposeRendererupdateTokenInfo()to accumulate token usageforceStop()method for user task cancellationformatToolCallDisplay()andformatToolResultSummary()methodsIdeaAgentViewModel (
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt)startMcpPreloading()method and related states (mcpPreloadingStatus,mcpPreloadingMessage)getToolLoadingStatus()method andToolLoadingStatusdata classhandleBuiltinCommand()for/clear,/help,/statuscommandsexecuteTask()andcancelTask()methodsIdeaAgentApp (
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt)TimelineItemViewto supportTerminalOutputItemTests
Design Considerations
Reusability: JewelRenderer uses StateFlow instead of Compose's mutableStateOf, avoiding ClassLoader conflicts with IntelliJ's bundled Compose runtime while maintaining compatibility with any UI framework.
Feature Parity: All functionality is aligned with mpp-ui's
CodingAgentViewModelfor cross-platform consistency.Theme Adaptation: UI components use Jewel theme colors while leveraging
AutoDevColorsdesign system for visual consistency.Pull Request opened by Augment Code with guidance from the PR author
Summary by CodeRabbit
New Features
Refactor
Tests
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.