-
Couldn't load subscription status.
- Fork 502
Fix Monaco editor syntax highlighting in Preview block #2459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Monaco editor syntax highlighting in Preview block #2459
Conversation
The Preview block's CodeEditPreview component was not passing file information to Monaco editor, preventing automatic language detection from file extensions. Changes: - Add fileName prop to CodeEditor component - Pass actual file path to Monaco instead of random UUID - Monaco now auto-detects language from file extension (.js, .py, .ts, etc.) Fixes syntax highlighting for all text files opened in Preview blocks while maintaining backward compatibility with existing CodeEditor usage.
|
Caution Review failedThe pull request is closed. WalkthroughAdds an optional Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
frontend/app/view/codeeditor/codeeditor.tsx(1 hunks)frontend/app/view/preview/preview-edit.tsx(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/app/view/codeeditor/codeeditor.tsx (2)
frontend/app/store/global.ts (1)
useOverrideConfigAtom(858-858)frontend/util/util.ts (1)
boundNumber(411-411)
🔇 Additional comments (4)
frontend/app/view/codeeditor/codeeditor.tsx (2)
111-111: LGTM! Optional prop maintains backward compatibility.The addition of the optional
fileNameprop to the interface is well-designed and maintains backward compatibility with existing CodeEditor usage.
116-116: LGTM! Function signature correctly implements the interface.frontend/app/view/preview/preview-edit.tsx (2)
19-19: Good defensive programming with optional chaining.The derivation logic correctly prefers
pathovernameand uses optional chaining to safely handle nullablefileInfo. This approach ensures that if file metadata is unavailable, the CodeEditor will fall back to a UUID (as implemented in line 124 of codeeditor.tsx).
69-69: LGTM! This change achieves the PR objective.Passing the derived
fileNameto CodeEditor enables Monaco's automatic language detection based on file extensions, which fixes the syntax highlighting issue described in the PR objectives.
|
@slate20 thanks for tracking this down (#2427)! I see it now, I had a regression from this commit a month ago (Sep 15) -- 77bbf74 i swapped from the filename to a UUID, which now I see lost the language detection / highlighting! the issue that my commit fixed for an issue where the model was getting initialized with an empty filename (which bound the 'internal' monaco model). that was particularly bad when two files were bound with empty string and then they would cross talk and overwrite each other. i'll just need to verify we dont re-introduce that bug with this fix. will work on getting this merged on monday so it will make the next patch release (should be this week). |
also, add blockid to filename to make sure it is unique (same filename on two different servers).
The Preview block's CodeEditPreview component was not passing file information to Monaco editor, preventing automatic language detection from file extensions.
Changes:
Fixes syntax highlighting for all text files opened in Preview blocks while maintaining backward compatibility with existing CodeEditor usage.