Skip to content

Conversation

@qdaxb
Copy link
Contributor

@qdaxb qdaxb commented Jun 11, 2025

Related GitHub Issue

Closes: #4546

Description

Test Procedure

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • [ x] ✨ New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

mermaid

Documentation Updates

Additional Notes

Get in Touch


Important

Adds interactive buttons to Mermaid diagrams for zoom, copy, and code view, with clipboard support for images.

  • New Feature:
    • Adds MermaidButton component in MermaidButton.tsx for interactive buttons on Mermaid diagrams.
    • Supports zoom, copy to clipboard, and view code functionalities.
  • Behavior:
    • openImage function in open-file.ts now supports a "copy" action to copy images to clipboard.
    • webviewMessageHandler.ts updated to handle "openImage" message with copy action.
  • UI Components:
    • MermaidBlock.tsx integrates MermaidButton for enhanced diagram interaction.
    • Adds modals for zoom and code view in MermaidButton.tsx.

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

@qdaxb qdaxb requested review from cte, jr and mrubens as code owners June 11, 2025 12:01
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jun 11, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 11, 2025
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 12, 2025
@daniel-lxs daniel-lxs force-pushed the add_mermaid_buttons branch from 6c00b45 to 11cc721 Compare June 12, 2025 00:27
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

I made some adjustments to make the UX a bit better, I think the tabs work better:
image

And also internationalized the strings.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 12, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 12, 2025
Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

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

UX-wise, main feedback is that clicking to drag doesn't work like I expect when I zoom in. Are you all seeing the same thing? The zoom buttons zoom you in pretty slow too, and it would be nice to be able to hold them down to keep zooming.

@qdaxb qdaxb force-pushed the add_mermaid_buttons branch from d59524f to f335fdc Compare June 12, 2025 05:49
@qdaxb
Copy link
Contributor Author

qdaxb commented Jun 12, 2025

UX-wise, main feedback is that clicking to drag doesn't work like I expect when I zoom in. Are you all seeing the same thing? The zoom buttons zoom you in pretty slow too, and it would be nice to be able to hold them down to keep zooming.

@mrubens fixed

@daniel-lxs
I added the active color of the tabbutton to distinguish the currently active tab.

I also found a problem, in this commit:
11cc721
The previous copying of images to the clipboard has become copying datauri, and pasting in other applications will display text instead of images. Why did you make this change?

@daniel-lxs
Copy link
Member

daniel-lxs commented Jun 12, 2025

@qdaxb
It's better to use the vscode clipboard functionality rather than a child process and running a clipboard command.

I can fix the issue with the copy button, sorry about that!

Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

@qdaxb
I fixed the copy button! now it should copy the actual diagram.

This looks awesome!

@mrubens
Copy link
Collaborator

mrubens commented Jun 12, 2025

I just pushed a change to increase the max zoom - at least for the one I tested on I needed more.

I'm still struggling to figure out how to copy the image instead of the markup @daniel-lxs - am I missing something?

@daniel-lxs
Copy link
Member

@mrubens
I honestly didn't thought of actually copying the image, I'll look into it.

@mrubens
Copy link
Collaborator

mrubens commented Jun 12, 2025

@mrubens I honestly didn't thought of actually copying the image, I'll look into it.

Ah yeah, I think that's how @qdaxb had it set up previously with the datauri

@daniel-lxs
Copy link
Member

@mrubens
I added a new button:
image

Since I don't think is possible to directly copy the image using the vscode API that doesn't involve copying the datauri or spawning a child process with a command, which in my opinion isn't very clean, I added the save button to directly save the image.

Let me know what you think!

@mrubens mrubens merged commit dfcf8fe into RooCodeInc:main Jun 12, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 12, 2025
@qdaxb qdaxb deleted the add_mermaid_buttons branch June 13, 2025 02:50
cte pushed a commit that referenced this pull request Jun 24, 2025
* add mermaid buttons

* feat: Add Modal, TabButton, and ZoomControls components

* feat: Add error handling messages for image operations and file opening

* mermaid: Add drag functionality and support contious zooming

* add active color for tabbutton

* refactor zoom controls

* refactor: Remove unused svgToPng prop and simplify handleCopy function

* Move zoom to constants and increase max zoom

* feat: add save image functionality and refactor image handling

* feat: add translations

---------

Co-authored-by: Daniel Riccio <[email protected]>
Co-authored-by: Matt Rubens <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add a separate function button for the mermaid image

4 participants