fix(gchat): use full markdown parser for card text rendering#92
Conversation
The _markdown_to_gchat helper only converted **bold** to *bold* via a naive regex, leaving markdown bullet lists and italic syntax as raw literals in textParagraph widgets. Google Chat does not render markdown list syntax (- item, * item), so agent responses with bullet lists appeared with literal * characters instead of formatted bullets. Replace _markdown_to_gchat with _render_markdown_as_gchat which round-trips content through parse_markdown + GoogleChatFormatConverter, the same path used for plain text messages. This correctly converts: - markdown lists -> bullet characters - **bold** -> *bold* (GChat bold) - *italic* -> _italic_ (GChat italic) Apply the fix to both _convert_text_to_widget and _convert_fields_to_widgets. Update the test that asserted old pass-through behavior for *italic* to reflect the correct output. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughRefactors Google Chat card markdown rendering to use parsed markdown + GoogleChatFormatConverter via _render_markdown_as_gchat(...); applies this to text and field widgets, preserves emoji conversion and muted-style emoji-only fallback, and updates tests for italics, lists, and muted behavior. ChangesGoogle Chat Markdown Conversion Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Code Review
This pull request replaces the naive regex-based Markdown conversion with a more robust AST-based implementation using GoogleChatFormatConverter, improving the handling of italics and bulleted lists in Google Chat cards. Review feedback indicates that explicit bold styles in card widgets should use tags instead of asterisks to ensure correct rendering.
|
@patrick-chinchill FYI on this one from today — fixes the raw |
…r refactor Upstream TS convertTextToWidget explicitly reverts muted elements to plain emoji-only text, bypassing markdown conversion. The AST-converter refactor dropped the elif branch, causing muted card text to go through parse_markdown + GoogleChatFormatConverter.from_ast instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Problem
_markdown_to_gchatinadapters/google_chat/cards.pywas a naive regex that only converted**bold**to*bold*. All other markdown syntax -- bullet lists, italic -- passed through as raw text into thetextParagraphwidget.Google Chat's
textParagraphdoes not render markdown list syntax (- item,* item), so agent responses with bullet lists appeared with literal*characters instead of formatted content. For example:rendered literally rather than as formatted bullets.
Fix
Replace
_markdown_to_gchatwith_render_markdown_as_gchat, which usesparse_markdown+GoogleChatFormatConverter.from_ast-- the same path the adapter already uses for plain text messages. This correctly handles:•bullet characters**bold**→*bold*(GChat bold)*italic*→_italic_(GChat italic)Applied to both
_convert_text_to_widgetand_convert_fields_to_widgets.Tests
test_preserves_single_asteriskto document correct behavior:*italic*markdown →_italic_GChat italic (not*italic*GChat bold as the old regex implied)test_markdown_bullet_list_with_bold_labels_renders_without_raw_markersto regression-test the exact failure caseAll 26 existing card tests pass.
cc @patrick-chinchill -- flagged while debugging a Google Chat rendering issue where the agent's ITSM list response was showing raw
*charactersSummary by CodeRabbit
Bug Fixes
Tests