Skip to content

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Sep 10, 2025

This PR adds 2 things:

  1. Chat.chat_ui(messages=...) now supports any type also supported by message_content()
  2. ChatMessage() can now be constructed outside of a Shiny session

@cpsievert cpsievert changed the title feat(pkg-py): Improvements to statically rendered messages feat(pkg-py): Improvements for statically rendered messages Sep 10, 2025
@cpsievert cpsievert requested a review from Copilot September 10, 2025 15:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves support for statically rendered messages in the shinychat package by making two key changes: allowing ChatMessage() construction outside Shiny sessions and expanding message type support for Chat.chat_ui().

  • Enhances ChatMessage() construction to work outside of active Shiny sessions by using get_current_session() instead of require_active_session()
  • Updates Chat.chat_ui(messages=...) to accept any type supported by message_content() function
  • Refactors multiple test apps to use the new chat.ui(messages=...) pattern instead of passing messages to the Chat() constructor

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

File Description
pkg-py/src/shinychat/_chat_types.py Updates ChatMessage to handle session-less construction with fallback HTML processing
pkg-py/src/shinychat/_chat.py Simplifies chat_ui() function to use message_content() for message processing
pkg-py/tests/playwright/chat/*/app.py Refactors 5 test applications to use new chat.ui(messages=...) pattern
pkg-py/CHANGELOG.md Documents the new features in the unreleased section

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cpsievert cpsievert marked this pull request as ready for review September 10, 2025 16:42
@cpsievert cpsievert merged commit 722b982 into main Sep 10, 2025
5 checks passed
@cpsievert cpsievert deleted the fix/chat-ui-content branch September 10, 2025 16:42
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