Skip to content

fix(gchat): use full markdown parser for card text rendering#92

Merged
patrick-chinchill merged 2 commits into
Chinchill-AI:mainfrom
tony-chinchill-ai:fix/gchat-card-text-markdown-rendering
May 15, 2026
Merged

fix(gchat): use full markdown parser for card text rendering#92
patrick-chinchill merged 2 commits into
Chinchill-AI:mainfrom
tony-chinchill-ai:fix/gchat-card-text-markdown-rendering

Conversation

@tony-chinchill-ai
Copy link
Copy Markdown
Contributor

@tony-chinchill-ai tony-chinchill-ai commented May 15, 2026

Problem

_markdown_to_gchat in adapters/google_chat/cards.py was a naive regex that only converted **bold** to *bold*. All other markdown syntax -- bullet lists, italic -- passed through as raw text into the textParagraph widget.

Google Chat's textParagraph does not render markdown list syntax (- item, * item), so agent responses with bullet lists appeared with literal * characters instead of formatted content. For example:

*   *Jira:* create and search issues
*   *Zendesk:* manage tickets

rendered literally rather than as formatted bullets.

Fix

Replace _markdown_to_gchat with _render_markdown_as_gchat, which uses parse_markdown + GoogleChatFormatConverter.from_ast -- the same path the adapter already uses for plain text messages. This correctly handles:

  • Markdown lists → bullet characters
  • **bold***bold* (GChat bold)
  • *italic*_italic_ (GChat italic)

Applied to both _convert_text_to_widget and _convert_fields_to_widgets.

Tests

  • Updated test_preserves_single_asterisk to document correct behavior: *italic* markdown → _italic_ GChat italic (not *italic* GChat bold as the old regex implied)
  • Added test_markdown_bullet_list_with_bold_labels_renders_without_raw_markers to regression-test the exact failure case

All 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 * characters

Summary by CodeRabbit

  • Bug Fixes

    • Improved Google Chat card markdown handling: italics and bullet lists now render correctly and raw markdown symbols are not shown.
    • Preserved bold formatting; muted-style text bypasses markdown conversion to remain literal.
  • Tests

    • Expanded tests for markdown-to-Google Chat conversion covering italics, lists, bold, and muted behavior.

Review Change Stack

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>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: deef3fc7-3217-4d71-82b7-7eef0eda3097

📥 Commits

Reviewing files that changed from the base of the PR and between 1d99888 and 36a7e13.

📒 Files selected for processing (2)
  • src/chat_sdk/adapters/google_chat/cards.py
  • tests/test_gchat_cards.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/test_gchat_cards.py
  • src/chat_sdk/adapters/google_chat/cards.py

📝 Walkthrough

Walkthrough

Refactors 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.

Changes

Google Chat Markdown Conversion Refactoring

Layer / File(s) Summary
Markdown conversion infrastructure
src/chat_sdk/adapters/google_chat/cards.py
Adds GoogleChatFormatConverter and parse_markdown imports, defines convert_emoji, instantiates a _gchat_converter, and implements _render_markdown_as_gchat(text) to render parsed markdown into GChat format.
Text widget markdown rendering
src/chat_sdk/adapters/google_chat/cards.py
Text elements now render using _render_markdown_as_gchat(...); "bold" style still wraps the rendered result in *...*, and "muted" continues to bypass markdown rendering using emoji-converted plain content.
Field widget markdown rendering
src/chat_sdk/adapters/google_chat/cards.py
Field children topLabel and text are updated to use _render_markdown_as_gchat(...) instead of the removed regex-based converter.
Markdown conversion test coverage
tests/test_gchat_cards.py
Tests updated to assert *italic*_italic_, bullet lists with bold labels render as GChat bullets () without raw **, and style="muted" skips markdown conversion leaving **...** unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 From tokens parsed, not patched with haste,
Emoji stitched and formatting placed.
Italics curl under, bullets stand neat,
Muted stays simple — emoji complete.
A little hop for cleaner chat display.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing a naive regex-based markdown converter with a full markdown parser for Google Chat card text rendering.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@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 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.

Comment thread src/chat_sdk/adapters/google_chat/cards.py
@tony-chinchill-ai
Copy link
Copy Markdown
Contributor Author

@patrick-chinchill FYI on this one from today — fixes the raw * rendering issue we saw in Google Chat when the agent responds with bullet lists.

…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>
@patrick-chinchill patrick-chinchill merged commit c71442a into Chinchill-AI:main May 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants