Skip to content

feat(mpp-idea): enhance CodingAgent with MCP preloading and tool status - #5

Merged
phodal merged 2 commits into
masterfrom
feat/mpp-idea-coding-agent-enhancements
Nov 30, 2025
Merged

phodal merged 2 commits into
masterfrom
feat/mpp-idea-coding-agent-enhancements

Conversation

@phodal

@phodal phodal commented Nov 30, 2025 •

Copy link
Copy Markdown
Member

Summary

This PR enhances the mpp-idea module's CodingAgent implementation to align with mpp-ui's CodingAgentViewModel and AgentChatInterface for feature parity.

Changes

JewelRenderer (mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt)

  • Task Tracking: Add TaskInfo and TaskStatus data classes to support the task-boundary tool's task state updates
  • Terminal Output: Add TerminalOutputItem for displaying Shell command outputs
  • Tool Call Improvements: ToolCallItem now includes more fields (description, fullParams, filePath, toolType) to match ComposeRenderer
  • Token Accumulation: Improved updateTokenInfo() to accumulate token usage
  • Force Stop: Add forceStop() method for user task cancellation
  • Formatting Helpers: Add formatToolCallDisplay() and formatToolResultSummary() methods

IdeaAgentViewModel (mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt)

  • MCP Preloading: Add startMcpPreloading() method and related states (mcpPreloadingStatus, mcpPreloadingMessage)
  • Tool Loading Status: Add getToolLoadingStatus() method and ToolLoadingStatus data class
  • Builtin Commands: Add handleBuiltinCommand() for /clear, /help, /status commands
  • Task Management: Add executeTask() and cancelTask() methods
  • Configuration Caching: Cache tool configuration for better performance

IdeaAgentApp (mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt)

  • ToolLoadingStatusBar: New component showing SubAgents and MCP Tools loading status
  • ToolStatusChip: Status indicator chip component
  • TerminalOutputBubble: Component for displaying terminal command output
  • Updated TimelineItemView to support TerminalOutputItem

Tests

  • JewelRendererTest: Unit tests for renderer functionality (does not require IntelliJ Platform)
  • IdeaAgentViewModelTest: Unit tests for ViewModel (requires IntelliJ Platform Test Framework)

Design Considerations

  1. 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.

  2. Feature Parity: All functionality is aligned with mpp-ui's CodingAgentViewModel for cross-platform consistency.

  3. Theme Adaptation: UI components use Jewel theme colors while leveraging AutoDevColors design system for visual consistency.


Pull Request opened by Augment Code with guidance from the PR author

Summary by CodeRabbit

  • New Features

    • Richer tool calls/results display (descriptions, full params, summaries, per-tool handling) and live terminal output rendering with timing/exit codes
    • Tool loading status UI with progress messaging and status chips
    • Task lifecycle tracking with statuses and continuous execution time
    • Built-in chat commands (/clear, /help, /status) and task execute/cancel flows
  • Refactor

    • Processing state renamed to executing for clearer intent
  • Tests

    • Expanded renderer and view-model test suites
  • Documentation

    • Added plugin build/test usage notes in docs

✏️ Tip: You can customize this high-level summary in your review settings.

- 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.
@coderabbitai

coderabbitai Bot commented Nov 30, 2025 •

Copy link
Copy Markdown

Walkthrough

Adds 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

Cohort / File(s) Summary
Rendering Engine
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt
Added TaskInfo/TaskStatus and StateFlows tasks and currentExecutionTime; introduced TerminalOutputItem; expanded ToolCallItem/ToolCallInfo with description, fullParams, filePath, toolType, summary, fullOutput, executionTime; added parse/format helpers, updateTaskFromToolCall(), forceStop(), and adjusted lifecycle/error clears.
ViewModel & Orchestration
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt
Added MCP preloading coroutine and public mcpPreloadingStatus/mcpPreloadingMessage; cached tool config; new executeTask, sendMessage, cancelTask, getToolLoadingStatus, isConfigured; renamed _isProcessing → _isExecuting (alias kept); builtin command handling and extended initialization flow (constructor gains maxIterations).
UI Composables
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
Added ToolLoadingStatusBar, ToolStatusChip, TerminalOutputBubble; wired preloading messages and isExecuting state; TimelineItemView extended to render TerminalOutputItem; ChatInputArea usage adjusted to call cancelTask().
Tests
mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt, mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.kt
New unit tests covering renderer lifecycle, tool call/result rendering, terminal output, task updates, force-stop, MCP preloading/status and viewmodel execution/command handling.
Docs
AGENTS.md
Added documentation about mpp-idea Gradle project, build/test/plugin commands and invocation notes.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay attention to:
    • JewelRenderer: stateflow updates, concurrency, and correct reset semantics (tasks, execution time, last-token).
    • IdeaAgentViewModel: coroutine lifecycle, cancellation paths, cached tool config usage, and integrated preloading progression.
    • UI bindings: isExecuting vs. isProcessing alias, and TerminalOutputItem rendering to ensure no threading/compose state issues.

Possibly related PRs

Poem

🐰 I hop through timelines, tools in paw,

Shell lines sparkle, tasks I saw,
MCP hums a preloading tune,
Calls and outputs dance in noon,
A carrot-coded cheer — hop, vroom! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.61% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: enhancing CodingAgent with MCP preloading and tool status features, which aligns with the PR's core objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/mpp-idea-coding-agent-enhancements

Comment @coderabbitai help to get the list of available commands and usage tips.

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Comment augment review to trigger a new review at any time.

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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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() }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👎

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and toolType. 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 TerminalOutputItem for 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 /clear command calls renderer.clearTimeline() then renderer.renderFinalResult(). The assertion assertTrue(timeline.isNotEmpty()) passes because renderFinalResult adds a TaskCompleteItem, 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 replacing Thread.sleep with deterministic waiting.

Using Thread.sleep(100) for async operations can lead to flaky tests, especially under CI load. Consider using advanceUntilIdle() from kotlinx-coroutines-test or polling with a timeout for more reliable tests.


149-154: Weak assertion for testIsConfigured.

assertNotNull(isConfigured) on a Boolean return type is redundant since Kotlin's Boolean is 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 else branch duplicates most of executeTask's logic. Consider refactoring to call executeTask directly 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 0 always returns enabledMcpToolsCount since size is 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

📥 Commits

Reviewing files that changed from the base of the PR and between c7445af and eb719a6.

📒 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: Use expect/actual for 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: avoid Flow, use Promise instead
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.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
  • mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt
**/*.{kt,kts}

📄 CodeRabbit inference engine (AGENTS.md)

For Compose (Desktop/Android), use AutoDevColors from cc.unitmesh.devins.ui.compose.theme or MaterialTheme.colorScheme

Files:

  • mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/renderer/JewelRendererTest.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
  • mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt
  • mpp-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.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
  • mpp-idea/src/test/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModelTest.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt
  • mpp-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.kt
  • mpp-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(), currentToolCall becomes null (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/bash

Search 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/bash

Find 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/bash

Locate 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/bash

Search 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/bash

Let'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/bash

Check 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/bash

Get 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/bash

Show 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/bash

Find 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/bash

Check 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/bash

Look 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/bash

List 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/bash

Check directory structure at mpp-idea

ls -la mpp-idea/ 2>/dev/null || ls -la . | head -20


</function_calls>

<function_calls>

14

#!/bin/bash

Show current location and repository structure

pwd
echo "=== Root files ==="
ls -1 | head -20

echo "=== 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/bash

Find 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/bash

Broader 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/bash

Get 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/bash

List all kotlin files to understand structure

find . -name "*.kt" -type f 2>/dev/null | head -40


</function_calls>

<function_calls>

19

#!/bin/bash

Check git ls-files to see what files are in the repo

git ls-files "*.kt" | head -40


</function_calls>

<function_calls>

20

#!/bin/bash

Search 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/bash

Get 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/bash

Show 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/bash

Search 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/bash

Search 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/bash

Get 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/bash

Show 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/bash

Find 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/bash

Find 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/bash

Search 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/bash

Find 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 re

Get 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:
pass

for 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/bash

Now 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/null

echo ""
echo "=== Searching for TaskStatus files ==="
git ls-files "*.kt" | xargs grep -l 'TaskStatus' 2>/dev/null

echo ""
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/bash

Get 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/null

echo ""
echo "=== Files containing renderToolCall ==="
git ls-files "*.kt" | xargs grep -l 'renderToolCall' 2>/dev/null


</function_calls>

<function_calls>

34

#!/bin/bash

Show 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 extract taskName, status, and summary fields
  • JewelRenderer.TaskStatus enum exists with WORKING value (plus NOT_STARTED, COMPLETED, FAILED)
  • The tasks StateFlow is properly updated with a TaskInfo object containing the parsed values
  • Status string conversion ("WORKING" → TaskStatus.WORKING) is handled correctly during parsing

No 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.toolName to contain "file.txt". Here's why:

  1. parseParamsString("path=\"/test/file.txt\"") correctly extracts params["path"] = "/test/file.txt" using a regex pattern that handles quoted values.

  2. 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 File
  3. This 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" and key=value patterns 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 ToolCallItem with its result.


144-156: LGTM!

The TaskStatus enum 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 TimelineItemView correctly handles the new TerminalOutputItem variant.


101-105: LGTM!

Good update to use isExecuting state and cancelTask() 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
@phodal

phodal commented Nov 30, 2025

Copy link
Copy Markdown
Member Author

augment review

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Comment augment review to trigger a new review at any time.

} else {
McpToolConfigManager.getTotalDiscoveredTools()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👎

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 loadConfiguration is 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.isActive or use coroutineContext.isActive.


276-280: Unused variable args.

The args variable 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 size is 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

📥 Commits

Reviewing files that changed from the base of the PR and between eb719a6 and c6b8758.

📒 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: Use expect/actual for 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: avoid Flow, use Promise instead
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.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentApp.kt
**/*.{kt,kts}

📄 CodeRabbit inference engine (AGENTS.md)

For Compose (Desktop/Android), use AutoDevColors from cc.unitmesh.devins.ui.compose.theme or MaterialTheme.colorScheme

Files:

  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt
  • mpp-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.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/IdeaAgentViewModel.kt
  • mpp-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.kt
  • 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 **/*.{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 isProcessing as an alias getter for _isExecuting maintains 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 /status work 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 TerminalOutputItem rendering into the timeline view.


428-484: LGTM!

The terminal output bubble correctly uses AutoDevColors design tokens for all colors, addressing the previous hardcoded colors concern and complying with coding guidelines.


486-546: LGTM!

The status bar properly recomputes toolStatus when mcpPreloadingStatus changes, 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 /help for 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 ToolCallItem and new TerminalOutputItem for richer timeline rendering. The TaskStatus enum with fromString companion 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.

Comment on lines +321 to +337
_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
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant