Add mermaid-to-image extension#17621
Conversation
- Update images in metadata - Refactor error handling in mermaid-to-image.tsx - Update package.json and improve temporary file cleanup - Update dependencies and fix license year - Refactor diagram generation logic by simplifying possiblePaths declaration and removing unused stdout and stderr handling - Add metadata images - Update README and package files to clarify Mermaid CLI installation and update type definitions - Refactor image handling and cleanup in Mermaid diagram generation - Update dependencies and clean up package-lock.json - Refactor Mermaid diagram generation by removing redundant Node.js path checks and updating command execution logic - Update dependencies and modify extension icon - Update documentation and remove unused files - init
|
Congratulations on your new Raycast extension! 🚀 Due to our current reduced availability, the initial review may take up to 10-15 business days Once the PR is approved and merged, the extension will be available on our Store. |
There was a problem hiding this comment.
PR Summary
This PR adds a new Mermaid to Image extension that converts Mermaid diagram code from clipboard into PNG/SVG images with multiple theme options and file handling capabilities.
- Since this is a new extension with
viewcommands inpackage.json, ametadatafolder with screenshots should be added as per extension store guidelines - The
launchCommandinmermaid-to-image.tsxshould be wrapped in try-catch blocks for better error handling - Consider adding
subtitlewith "Mermaid" to the command inpackage.jsonto better identify the service - The
showToasterror handling inmermaid-to-image.tsxcould be simplified usingshowFailureToastfrom@raycast/utilsin several places - Chinese comments in
mermaid-to-image.tsxshould be translated to English as Raycast doesn't support localization
💡 (2/5) Greptile learns from your feedback when you react with 👍/👎!
9 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile
|
@greptileai check it out now |
There was a problem hiding this comment.
PR Summary
This PR adds a new Mermaid to Image extension with several updates since the last review.
- The List component in
mermaid-to-image.tsxshould useisLoadingprop to avoid empty state flicker as per store guidelines - The
getSelectedText()function should include error handling for cases where text selection fails - The title in CHANGELOG.md ("Mermaid-to-image") should match package.json's title ("Mermaid to Image") for consistency
- Consider adding
isLoadingstate to the Detail component to improve the loading experience
Note: This review focuses on new points not covered in previous reviews, particularly around loading states and error handling improvements.
9 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
|
@greptileai check it out now |
There was a problem hiding this comment.
PR Summary
(updates since last review)
This PR updates the Mermaid to Image extension with improved error handling and loading states.
- The
getSelectedText()function inmermaid-to-image.tsxnow includes proper error handling with try-catch blocks and showFailureToast - Loading states have been added to both List and Detail components to prevent empty state flicker
- The CHANGELOG.md title has been updated to match package.json's "Mermaid to Image" for consistency
- The Detail component now properly handles loading states for better user experience
Note: This summary focuses on recent changes not mentioned in previous reviews, particularly around error handling and loading state improvements.
3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
|
@greptileai check it out now~ |
There was a problem hiding this comment.
PR Summary
(updates since last review)
Based on the latest changes to the Mermaid to Image extension, here's my review focusing on new points not previously covered:
The PR adds improvements to the Mermaid diagram code conversion extension with enhanced error handling and cleanup.
- The
launchCommandfunction inmermaid-to-image.tsxshould handle cleanup of temporary files in both success and error cases to prevent file system clutter - Consider adding a check for
mmdccommand availability before attempting diagram generation to provide better user feedback - The
execPromisetimeout of 10000ms inlaunchCommandmight be insufficient for complex diagrams, consider making this configurable via preferences - The clipboard restoration logic in
getSelectedText()could be improved to handle edge cases wherepreviousClipboard.textis undefined
Note: This review focuses on new aspects not mentioned in previous reviews, particularly around resource management and edge case handling.
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
|
@greptileai check it out now~ |
There was a problem hiding this comment.
PR Summary
(updates since last review)
Based on the latest changes to the Mermaid to Image extension, here's my review focusing on new points not previously covered:
This PR adds a configurable timeout and improved file handling to the Mermaid diagram conversion extension.
- The
PreferencesandArgumentsinterfaces inmermaid-to-image.tsxare unnecessary since they are auto-generated inraycast-env.d.ts - The
findMmdcPath()function should useshowFailureToastinstead ofshowToastwithStyle.Failurefor consistency - The
ImagePreviewcomponent could benefit from a loading state while reading image files - The
savePathpreference inpackage.jsonshould include validation to ensure it's a valid directory path
Note: This review focuses on recent changes and aspects not mentioned in previous reviews, particularly around type definitions and preference validation.
2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
|
@greptileai check it out |
There was a problem hiding this comment.
PR Summary
(updates since last review)
Based on the latest changes to the Mermaid to Image extension, here's my review focusing on new points not previously covered:
The PR adds improved error handling and loading states to the Mermaid diagram conversion extension.
- The
ImagePreviewcomponent inmermaid-to-image.tsxnow properly implements loading states withisLoading={true}to prevent UI flicker - The
showFailureToastfrom@raycast/utilsis now consistently used throughout the codebase for error handling - The
Preferencesinterface has been removed as it's auto-generated inraycast-env.d.ts - The
subtitlehas been added to the command inpackage.jsonwith "Generate Diagram Images from Mermaid Markup" for better service identification
Note: This review focuses on recent changes and aspects not mentioned in previous reviews, particularly around UI improvements and code cleanup.
2 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
|
@greptileai check it out |
There was a problem hiding this comment.
PR Summary
(updates since last review)
Based on the latest changes to the Mermaid to Image extension, here's my review focusing on new points not previously covered:
The PR adds improved error handling and cleanup functionality to the Mermaid diagram conversion extension.
- The
cleanupTempFilefunction inmermaid-to-image.tsxshould be called in the component's cleanup effect to ensure temporary files are removed when unmounting - The
generationTimeoutpreference inpackage.jsonhas proper validation with^[1-9]\\d*$to ensure positive integers - The
savePathpreference validation pattern^$|^/?(/[^/]+)+/?$correctly ensures valid directory paths - The
findMmdcPathfunction now properly checks multiple possible installation locations for better compatibility
Note: This review focuses on recent changes and aspects not mentioned in previous reviews, particularly around cleanup and validation improvements.
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
- Introduced a new preference for specifying a custom mmdc path in package.json, allowing users to define their own executable location for better flexibility. - Enhanced the findMmdcPath function in mermaid-to-image.tsx to first check for the custom path before falling back to default locations. This includes handling of glob patterns for NVM installations and improved error messaging for better user guidance. - Updated error handling to provide clearer instructions if the mmdc command is not found, encouraging users to either install the mermaid-cli or set a custom path in preferences.
|
@pernielsentikaer Done🎉 |
pernielsentikaer
left a comment
There was a problem hiding this comment.
I'm getting a new error now, but at least it found the mmdc 😊
Could you try to use enviroment.supportPath
…ility This commit completely reorganizes the extension's codebase to improve maintainability, readability, and separation of concerns: - Split monolithic index.tsx into modular components and utilities - Create dedicated directories for components, utils, and types - Extract ImagePreview into a separate component - Organize utility functions by domain (clipboard, files, executables, diagram) - Improve type safety with dedicated types file - Maintain all existing functionality while improving code organization - Ensure consistent error handling patterns throughout the codebase - Reduce code duplication by extracting common functionality
There was a problem hiding this comment.
PR Summary
(updates since last review)
Based on the latest changes to the Mermaid to Image extension, here's my review focusing on new points not previously covered:
The PR improves error handling and resource management in the diagram generation functionality.
- The
generateDiagramWithExplicitNodeindiagram.tsshould consolidate error message parsing into a separate helper function for better maintainability - The
cleanupResourceshelper function indiagram.tsshould be moved outside to be reusable across different functions - The
findMmdcPathinexecutables.tsshould consolidate success toasts to avoid multiple notifications when checking different paths - The error handling in
diagram.tsshould use more specific error types for better error differentiation
Note: This review focuses on code organization and error handling improvements not mentioned in previous reviews.
2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
| await showFailureToast({ | ||
| title: "Diagram Generation Failed", | ||
| message: userMessage, | ||
| }); |
There was a problem hiding this comment.
If you're inside a catch you can do like this
| await showFailureToast({ | |
| title: "Diagram Generation Failed", | |
| message: userMessage, | |
| }); | |
| await showFailureToast(error, { | |
| title: "Diagram Generation Failed", | |
| message: userMessage, | |
| }); |
if not inside a catch it's better to use the regular toast (since this uses error)
There was a problem hiding this comment.
@pernielsentikaer
Thank you for your valuable suggestions 😊
ImagePreview and diagram generation by including error details in showFailureToast calls for improved debugging 🛠️✨
|
Published to the Raycast Store: |
|
🎉 🎉 🎉 We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag. |



Description
A Raycast extension that instantly converts Mermaid diagram code from your clipboard into beautiful images.
Screencast
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare placed outside of themetadatafolder