Skip to content

Conversation

@harley
Copy link
Contributor

@harley harley commented Sep 29, 2025

Summary

  • wrap Mermaid blocks in a shared container that exposes diagram/code toggle controls
  • persist and respect the selected view when rendering, defaulting to the diagram after successful renders
  • extend unit and Playwright tests to verify the new toggle behaviour

Testing

  • pnpm test
  • pnpm test:e2e (fails: Playwright build step hits existing CSS/module resolution issues)

https://chatgpt.com/codex/tasks/task_b_68da27a8233c832bb3261ec43683ad71

@gemini-code-assist
Copy link

Summary of Changes

Hello @harley, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the user experience for Mermaid diagrams by implementing a toggle mechanism that allows users to easily switch between the visual diagram and its source code. This feature includes state persistence for the selected view and is supported by comprehensive unit and end-to-end tests to ensure reliability and correct behavior.

Highlights

  • Diagram/Code Toggles: Introduced interactive toggle controls for Mermaid blocks, allowing users to switch between viewing the rendered diagram and its underlying code.
  • View Persistence: The system now persists the user's selected view (diagram or code) across renders, defaulting to the diagram view after a successful render.
  • Enhanced Testing: Added new unit tests and Playwright end-to-end tests to thoroughly verify the functionality and persistence of the new toggle behavior.
  • Structural Changes: Refactored the DOM structure around Mermaid blocks to accommodate the new toggle functionality, including new container elements and pane management.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a useful feature for toggling between the rendered Mermaid diagram and its source code. The implementation is solid, with good use of data attributes for state management and updates to both unit and end-to-end tests to cover the new functionality. I've identified a couple of areas for improvement: one is a bug in error handling where an error message might not be visible to the user, and another is an opportunity to clean up some leftover code from a removed feature. I've also suggested a minor refactoring for conciseness. Overall, great work on this enhancement.

@harley harley changed the title Add diagram/code toggles for Mermaid blocks feat: add diagram/code toggles for Mermaid blocks Sep 29, 2025
- Create separate tsconfig.build.json that excludes test files from build
- Update build script to use build-specific TypeScript configuration
- Add CSS handling configuration to vitest.config.ts
- Fix ES module __dirname issues in Playwright configs
- Update e2e test script to use correct Playwright config path
- Add test-results/ directory to gitignore

This resolves the syntax error when running 'pnpm test:e2e' that was
caused by the build process trying to compile CSS files as JavaScript.
When Mermaid rendering fails, the error message is displayed in the diagram pane.
Previously, if the user had selected 'code' view, they wouldn't see the error message.
Now the view is always switched to 'diagram' on rendering errors to ensure users
are notified of failures, improving the user experience.
- Rename updateCollapsedState() to updatePaneVisibility()
- Remove unused collapse logic and isCollapsed checks
- Simplify pane visibility logic to only handle diagram/code toggle
- Improve code maintainability by removing dead code paths

The collapse functionality was removed, making the collapse-related
logic unnecessary. This cleanup makes the code more readable and
focused on its actual purpose.
@harley harley merged commit 90c460f into main Sep 29, 2025
1 check passed
@harley harley deleted the codex/implement-code-diagram-toggle-feature branch September 29, 2025 07:06
harley pushed a commit that referenced this pull request Sep 29, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.1.0](v1.0.0...v1.1.0)
(2025-09-29)


### Features

* Add copy-to-clipboard fix prompt to Mermaid error notice
([#2](#2))
([7fb5785](7fb5785))
* add diagram/code toggles for Mermaid blocks
([#7](#7))
([90c460f](90c460f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants