Skip to content

fix(idea): use correct project basePath for shell execution and improve tool call bubble UI#42

Merged
phodal merged 3 commits intomasterfrom
feat/vscode-renderer-improvements
Dec 4, 2025
Merged

fix(idea): use correct project basePath for shell execution and improve tool call bubble UI#42
phodal merged 3 commits intomasterfrom
feat/vscode-renderer-improvements

Conversation

@phodal
Copy link
Member

@phodal phodal commented Dec 4, 2025

Changes

1. Fix Shell Tool Working Directory (ProcessExecutor)

Problem: Shell commands were executing in the wrong directory (first opened project instead of current project)

Root Cause: ProcessExecutor.createProcess() used ProjectManager.getInstance().openProjects.firstOrNull()?.basePath instead of the current project's basePath

Solution: Changed to use project.basePath directly since ProcessExecutor is a project-level service that already has the correct project reference

2. Improve Tool Call Bubble UI (IdeaToolCallBubble)

Problem: Output was truncated at fixed 100 characters regardless of available space

Changes:

  • Left side: Status icon + ToolName (fixed width)
  • Right side: Output content with dynamic truncation using TextOverflow.Ellipsis
  • Removed fixed 100-character truncation in formatToolOutput
  • Output fills remaining space and shows ... only when actually overflowing
  • Falls back to showing params if no output available

Summary by CodeRabbit

  • UI/UX Changes

    • Terminal output now collapses by default for a streamlined interface
    • Tool execution headers display output summary and elapsed time information
    • File operation display simplified for clarity
  • Internal Improvements

    • Code refactoring for enhanced project path handling

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

Remove file path from toolName and use only displayName for clarity.
Use project.basePath for process execution and set terminal output bubble to collapsed by default.
Display tool output in the timeline bubble header, truncating with ellipsis and falling back to params if output is unavailable. UI now handles overflow without fixed truncation.
Copilot AI review requested due to automatic review settings December 4, 2025 06:53
@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Walkthrough

This pull request refactors project execution logic to remove global ProjectManager dependency, simplifies tool call display formatting in the renderer, adjusts UI component default states, and restructures tool call bubble UI to dynamically display output in headers with fixed-width constraints and improved spacing handling.

Changes

Cohort / File(s) Summary
Project Execution
core/src/main/kotlin/cc/unitmesh/devti/sketch/run/ProcessExecutor.kt
Replaces ProjectManager.openProjects dependency with project.basePath for working directory initialization in process creation.
Renderer Display Formatting
mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/render/RendererUtils.kt
Simplifies toolName display for ReadFile and WriteFile operations to show only toolType.displayName instead of "${path} - ${displayName}" format.
UI Component State & Layout
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaTerminalOutputBubble.kt, mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaToolCallBubble.kt
Changes terminal output bubble default state from expanded to collapsed; refactors tool call bubble to display dynamic output and execution time in header, constrains tool name to fixed width with ellipsis overflow handling, and replaces summary/params display logic with conditional output/params/spacer rendering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • IdeaToolCallBubble.kt: Most complex file with multiple conditional rendering branches and output display logic changes; requires careful validation of UI layout behavior across different output states.
  • RendererUtils.kt: Display formatting change affects visibility; verify impact on tool call presentation across the application.
  • ProcessExecutor.kt: Straightforward refactoring but verify project.basePath availability in all invocation contexts.

Possibly related PRs

Poem

🐰 In bubbles bright, we hop and play,
Old paths now rest, new ways display—
Output shines in headers neat,
Collapsed by default, quite sweet!
With ellipsis trim, the UI's complete.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 accurately summarizes both main changes: fixing shell execution basePath and improving tool call bubble UI display.
✨ 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/vscode-renderer-improvements

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaToolCallBubble.kt (2)

104-109: Consider adding width constraints to prevent layout issues.

The comment mentions "fixed width" for the tool name, but there's no explicit width() or minWidth() modifier. Very long tool names could still push other elements off-screen, while very short names might leave too much space.

Consider applying a width constraint:

 // Tool name (fixed width, no shrink)
 Text(
     text = item.toolName,
     style = JewelTheme.defaultTextStyle.copy(fontWeight = FontWeight.Bold),
-    maxLines = 1
+    maxLines = 1,
+    modifier = Modifier.widthIn(min = 60.dp, max = 120.dp)
 )

403-408: Good simplification - dynamic truncation is now UI-driven.

Removing the fixed truncation logic aligns with the PR objectives. The UI now handles overflow dynamically through TextOverflow.Ellipsis.

Since this function now just returns the input unchanged, you could consider removing it entirely and using item.output directly at the call site (line 307). However, keeping it provides flexibility for future formatting needs.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee06e30 and 094e880.

📒 Files selected for processing (4)
  • core/src/main/kotlin/cc/unitmesh/devti/sketch/run/ProcessExecutor.kt (1 hunks)
  • mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/render/RendererUtils.kt (1 hunks)
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaTerminalOutputBubble.kt (1 hunks)
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaToolCallBubble.kt (5 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.kt

📄 CodeRabbit inference engine (AGENTS.md)

**/*.kt: Use expect/actual for platform-specific code (e.g., file I/O on JVM/JS/Wasm) in Kotlin Multiplatform projects
Check export first if some functions are not working well with CLI (TypeScript)
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
For WASM platform, avoid using emoji and UTF-8 in code

Files:

  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaTerminalOutputBubble.kt
  • core/src/main/kotlin/cc/unitmesh/devti/sketch/run/ProcessExecutor.kt
  • mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/render/RendererUtils.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaToolCallBubble.kt
**/idea/**/*.kt

📄 CodeRabbit inference engine (AGENTS.md)

**/idea/**/*.kt: For SwingPanel z-index issues with Compose popups, enable Jewel's custom popup renderer: JewelFlags.useCustomPopupRenderer = true in IdeaAgentToolWindowFactory
For popup/dropdown menus in IntelliJ plugins, use Jewel's PopupMenu instead of androidx.compose.ui.window.Popup
For dialogs in IntelliJ plugins, use IntelliJ's DialogWrapper with org.jetbrains.jewel.bridge.compose instead of androidx.compose.ui.window.Dialog

Files:

  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaTerminalOutputBubble.kt
  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaToolCallBubble.kt
🧠 Learnings (4)
📚 Learning: 2025-12-02T00:20:34.480Z
Learnt from: CR
Repo: phodal/auto-dev-sketch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T00:20:34.480Z
Learning: Applies to **/compose/**/*.{kt,kts} : In 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/components/timeline/IdeaToolCallBubble.kt
📚 Learning: 2025-12-02T00:20:34.480Z
Learnt from: CR
Repo: phodal/auto-dev-sketch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T00:20:34.480Z
Learning: Applies to **/idea/**/*.kt : For dialogs in IntelliJ plugins, use IntelliJ's `DialogWrapper` with `org.jetbrains.jewel.bridge.compose` instead of `androidx.compose.ui.window.Dialog`

Applied to files:

  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaToolCallBubble.kt
📚 Learning: 2025-12-02T00:20:34.480Z
Learnt from: CR
Repo: phodal/auto-dev-sketch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T00:20:34.480Z
Learning: Applies to **/idea/**/*.kt : For popup/dropdown menus in IntelliJ plugins, use Jewel's `PopupMenu` instead of `androidx.compose.ui.window.Popup`

Applied to files:

  • mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaToolCallBubble.kt
📚 Learning: 2025-12-02T00:20:34.480Z
Learnt from: CR
Repo: phodal/auto-dev-sketch PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T00:20:34.480Z
Learning: Applies to {**/compose/**/*.kt,mpp-ui/src/jsMain/typescript/**/*.{ts,tsx}} : 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/components/timeline/IdeaToolCallBubble.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). (4)
  • GitHub Check: Agent
  • GitHub Check: Build (241)
  • GitHub Check: Build (223)
  • GitHub Check: Test mpp-core (KMP)
🔇 Additional comments (4)
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaTerminalOutputBubble.kt (1)

48-48: LGTM! Improved default UX.

Collapsing terminal output by default reduces visual clutter and aligns with the PR's UI improvements. Users can still expand on demand.

core/src/main/kotlin/cc/unitmesh/devti/sketch/run/ProcessExecutor.kt (1)

128-128: Excellent fix! Resolves the working directory bug.

This correctly uses the project instance's basePath instead of the first opened project from ProjectManager. Since ProcessExecutor is a project-level service, it already has the correct project reference. This ensures shell commands execute in the right directory.

mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/render/RendererUtils.kt (1)

20-30: LGTM! Cleaner tool name display.

Simplifying the tool name to just the display name (removing the file path) improves readability. The file path is still available in the details field for expanded views.

mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaToolCallBubble.kt (1)

111-149: Excellent dynamic output handling!

The new logic intelligently displays:

  1. Output when available (collapsed state)
  2. Parameters as fallback when no output (collapsed state)
  3. Spacer when expanded

The use of weight(1f), TextOverflow.Ellipsis, and clipToBounds ensures the content dynamically fills available space with proper truncation. This aligns perfectly with the PR objectives to remove fixed 100-character truncation.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in shell command execution and improves the UI presentation of tool call results. The ProcessExecutor was incorrectly using the first opened project's base path instead of the current project's path, which caused shell commands to execute in the wrong directory in multi-project scenarios. The UI improvements make tool output more readable by using dynamic text overflow instead of fixed truncation.

Key Changes

  • Fixed ProcessExecutor to use the current project's basePath instead of first opened project
  • Improved IdeaToolCallBubble to show dynamic output with proper text overflow handling
  • Simplified tool names in RendererUtils to show only the tool type, moving path details to output
  • Changed IdeaTerminalOutputBubble default state from expanded to collapsed

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
core/src/main/kotlin/cc/unitmesh/devti/sketch/run/ProcessExecutor.kt Fixed shell command working directory by using project.basePath instead of ProjectManager.getInstance().openProjects.firstOrNull()?.basePath, ensuring commands execute in the correct project context
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaToolCallBubble.kt Improved UI to show dynamic output with TextOverflow.Ellipsis, prioritize output over params in summary, and removed fixed 100-character truncation from formatToolOutput
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaTerminalOutputBubble.kt Changed initial expanded state from true to false for better UX
mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/render/RendererUtils.kt Simplified tool names for ReadFile and WriteFile to show only the tool type (path details remain in output/details)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@phodal phodal merged commit 05e440d into master Dec 4, 2025
13 of 14 checks passed
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

Comments