这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@srivatsj
Copy link
Contributor

@srivatsj srivatsj commented Oct 1, 2025

… display

Implements feature request from #6499 to toggle between rendered and raw markdown mode.

  • Add alt+m keybinding to toggle markdown rendering globally
  • Add renderMarkdown setting to UI config (default: true)
  • Update MarkdownDisplay to support raw mode with syntax highlighting
  • Update GeminiMessage, GeminiMessageContent, and ToolMessage to respect toggle
  • Add UIStateContext to test utilities for component testing
  • Visual indicator in footer (currently commented out)

Fixes #6499

TLDR

  • Add alt+m keybinding to toggle markdown rendering globally
  • Add renderMarkdown setting to UI config (default: true)
  • Update MarkdownDisplay to support raw mode with syntax highlighting
  • Update GeminiMessage, GeminiMessageContent, and ToolMessage to respect toggle
  • Add UIStateContext to test utilities for component testing
  • Visual indicator in footer (currently commented out)

Dive Deeper

Reviewer Test Plan

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

@google-cla
Copy link

google-cla bot commented Oct 1, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Collaborator

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

This is really helpful. Added some comments. Approved after those are addressed and there is a snapshot test fo the raw markdown display cases in GeminiMessage and ToolMessage.

@srivatsj srivatsj marked this pull request as ready for review October 3, 2025 15:32
@srivatsj srivatsj requested a review from a team as a code owner October 3, 2025 15:32
… display

Implements feature request from google-gemini#6499 to toggle between rendered and raw markdown mode.

- Add Ctrl+B keybinding to toggle markdown rendering globally
- Add renderMarkdown setting to UI config (default: true)
- Update MarkdownDisplay to support raw mode with syntax highlighting
- Update GeminiMessage, GeminiMessageContent, and ToolMessage to respect toggle
- Add UIStateContext to test utilities for component testing
- Visual indicator in footer (currently commented out)

Fixes google-gemini#6499
- Modified MarkdownDisplay to pass showLineNumbers: false when renderMarkdown is false
- Line numbers were confusing in raw mode due to chunked Gemini output
- Added snapshot tests for GeminiMessage and ToolMessage raw markdown rendering
- Tests verify line numbers are hidden in raw mode but shown in rendered mode
- ✅ keyBindings.ts - Updated to Alt+Shift+M (command+shift+m)
- ✅ keyMatchers.test.ts - Updated tests for Alt+Shift+M
- ✅ MarkdownDisplay.tsx - Fixed line numbers in raw mode
- ✅ Snapshot files - Updated and cleaned (4 obsolete snapshots removed)
…er access

Added dual Alt/Option key support for cross-terminal compatibility:
- Unicode mapping for terminals that send Unicode chars (iTerm2, VSCode)
- ESC sequence handling for terminals that send escape sequences
- Improved letter key handling to support both uppercase and lowercase with modifiers
- Updated tests to reflect new Cmd+M keybinding
… (lines 414-422)

2. ✅ Updated AppContainer.tsx to always initialize renderMarkdown to true instead of reading from settings
srivatsj and others added 3 commits October 14, 2025 11:14
Display "raw markdown mode (cmd+m to toggle)" indicator above input prompt when markdown rendering is disabled, consistent with shell mode and YOLO mode indicators.

  - Add RawMarkdownIndicator component
  - Show indicator in Composer when renderMarkdown is false
  - Add tests for RawMarkdownIndicator visibility
  - Remove commented markdown toggle code from Footer
@jacob314
Copy link
Collaborator

Please update the pr description to mention alt-m rather than ctrl-B. to avoid confusion if someone is looking through the changelog.

ShellModeIndicator: () => <Text>ShellModeIndicator</Text>,
}));

vi.mock('./RawMarkdownIndicator.js', () => ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Gemini CLI likes to mock too much. This isn't something that should be mocked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

<Box>
<Text>
raw markdown mode
<Text color={theme.text.secondary}> (alt+m to toggle) </Text>
Copy link
Collaborator

Choose a reason for hiding this comment

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

make this platform aware. Mac users have no idea what "alt" is. Call it "option+m" for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

This is looking great! Approved after these comments are addressed.

Show "option+m" on macOS and "alt+m" on other platforms for the markdown toggle shortcut, and remove mock from RawMarkdownIndicator tests to verify actual component behavior.
@srivatsj srivatsj changed the title feat: Add markdown toggle (Ctrl+B) to switch between rendered and raw… feat: Add markdown toggle (alt+m) to switch between rendered and raw… Oct 15, 2025
Copy link
Collaborator

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@jacob314 jacob314 added this pull request to the merge queue Oct 16, 2025
Merged via the queue into google-gemini:main with commit 6ded45e Oct 16, 2025
25 checks passed
thacio added a commit to thacio/auditaria that referenced this pull request Oct 17, 2025
Millsondylan pushed a commit to Millsondylan/gemini-cli-1 that referenced this pull request Oct 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toggle between raw and rendered mode for markdown

2 participants