Skip to content

Add markdown support for assist messages #26013

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

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

krsilas
Copy link

@krsilas krsilas commented Jun 30, 2025

Proposed change

This adds markdown support for messages in assist. LLM often return markdown which is currently shown unformatted in the chat interface.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Preview of some of the changes

Includes all of the markdown features supported by "marked" as in other parts of home assistant. Here are a few examples:

Before After
Link without formatting Link with formatting
Table without formatting Table with formatting
Image without formatting Formatted Image

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @krsilas

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant home-assistant bot marked this pull request as draft June 30, 2025 23:08
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@krsilas krsilas marked this pull request as ready for review June 30, 2025 23:12
@home-assistant home-assistant bot dismissed their stale review June 30, 2025 23:12

Stale

@krsilas
Copy link
Author

krsilas commented Jul 2, 2025

There is one outstanding layout issue during streaming that drives me nuts:

Bildschirmaufnahme.2025-07-02.um.20.58.50.mov

For some reason the element height of the ha-markdown element does not always match the text content height.
I thought this is related to the shadow root but I build two simple ha-markdown elements that just render the text. One in lit-html and one with vanilla js and only the lit-html version had this issue.

Copy link
Contributor

@MindFreeze MindFreeze left a comment

Choose a reason for hiding this comment

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

Looks good but the scrolling bug has to be fixed

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.

2 participants