Skip to content

Show chat messages as text in the LLM chat app - #1206

Open
kale-stew wants to merge 1 commit into
mainfrom
kylie/fix/llm-chat-message-text
Open

kale-stew wants to merge 1 commit into
mainfrom
kylie/fix/llm-chat-message-text

Conversation

@kale-stew

Copy link
Copy Markdown
Member

addMessageToChat in llm-chat-app-template/public/chat.js inserted message text with innerHTML, so a message containing HTML was rendered as HTML. This builds the paragraph with textContent instead, as the streamed assistant reply already does.

This is the remaining part of #913, which was opened before main changed the chat client. Credit to @him6794, who is listed as co-author.

How I verified it

  • New e2e test: sending <img src="x" id="injected"> shows that text in the chat and creates no #injected element. It fails without the fix.
  • playwright test playwright-tests/llm-chat-app-template.spec.ts (2 tests), templates lint ., and prettier --check pass.

Not verified

  • A deployed instance with Workers AI. The e2e test runs against the local dev server without an AI binding.

addMessageToChat inserted message text with innerHTML, so a message
containing HTML was rendered as HTML. Build the paragraph with
textContent instead, as the streamed assistant reply already does, and
add an e2e test for it.

Co-authored-by: Justin <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Dashboard preview link

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.

1 participant