Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

fix(mcp): pretty-print tool responses in UI - #11115

Open
hannesrudolph wants to merge 3 commits into
mainfrom
format-mcp-output
Open

fix(mcp): pretty-print tool responses in UI#11115
hannesrudolph wants to merge 3 commits into
mainfrom
format-mcp-output

Conversation

@hannesrudolph

@hannesrudolph hannesrudolph commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Prevents UI hangups caused by large outputs being rendered as 1 line.

Improve MCP tool output readability in the chat UI by pretty-printing JSON responses when expanded while preserving raw output for copy.

Before After
image image

Changes

  • Format MCP response JSON (including escaped/double-encoded JSON) in
  • Preserve raw response for copy via in
  • Add UI tests in

Important

Enhance JSON response readability in McpExecution.tsx by pretty-printing and preserving raw data for copying, with tests added for verification.

  • Behavior:
    • Pretty-print JSON responses in McpExecution.tsx when expanded, including handling of escaped and double-encoded JSON.
    • Preserve raw JSON response for copying.
  • Functions:
    • Add looksLikeJson, looksLikeEscapedJsonBlob, tryParseJsonValue, and tryUnescapeJsonBlob in McpExecution.tsx to handle JSON parsing and formatting.
  • Tests:
    • Add tests in McpExecution.spec.tsx to verify pretty-printing of minified, escaped, and double-encoded JSON, and handling of non-JSON responses.

This description was created by Ellipsis for ae18182. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. UI/UX UI/UX related or focused labels Jan 30, 2026
@ghost

ghost commented Jan 30, 2026

Copy link
Copy Markdown

Oroocle Clock   See task on Roo Cloud

Re-review complete. No new issues flagged.

  • Restrict the unescape fallback so backslashes in non-JSON responses do not get mutated before formatting.
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment thread webview-ui/src/components/chat/McpExecution.tsx Fixed
Comment on lines +89 to +92
if (parsed === undefined && (trimmed.includes('\\"') || trimmed.includes("\\\\"))) {
const unescaped = trimmed.replaceAll("\\\\", "\\").replaceAll('\\"', '"')
parsed = tryParseJsonValue(unescaped)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The unescape fallback (replaceAll(\\\\, \\).replaceAll('\\"', '"')) is fairly aggressive and can change the meaning of responses that contain backslashes but are not actually escaped JSON blobs; consider gating this branch on a stricter pattern (eg starting with {\" or [{\") so we do not pretty-print mutated content.

Fix it with Roo Code or mention @roomote and request a fix.

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

Labels

size:L This PR changes 100-499 lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

No open projects
Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants