fix(examples): stop passing the deprecated messages= to Chat - #2486
Merged
Conversation
anyio 4.15.0 deprecated the `anyio.abc.BlockingPortal` alias, which starlette's `testclient` module still uses in a module-level annotation. Under `filterwarnings = error` that turns into a *collection* error for any test importing `starlette.testclient`, so every matrix job has been failing since 2026-09-03 -- no py-shiny commit involved. starlette fixed this on master in Kludex/starlette#3498, but it is not in a release yet (1.6.0 predates it), so ignore the warning for now.
schloerke
force-pushed
the
schloerke/fix-chat-example-greeting
branch
from
September 7, 2026 01:47
d802bbc to
e302a5c
Compare
greeting= in the Chat API examplesmessages= to Chat
This was referenced Sep 7, 2026
schloerke
force-pushed
the
schloerke/fix-chat-example-greeting
branch
from
September 7, 2026 02:05
e302a5c to
d5740f1
Compare
shinychat 0.7.0 deprecated `chat_ui(messages=...)`/`Chat.ui(messages=...)`
in favour of `greeting=`, and made `Chat(messages=...)` an outright error
unless `history=False` is also passed.
`tests/playwright/examples` fails any app that emits a warning, so the two
`Chat` API examples have taken 30 `playwright-examples` jobs red since
2026-09-04. The five `templates/chat` apps are worse but invisible to CI:
they pass `messages=` to the `Chat` constructor, so they now raise on
startup.
- api-examples/Chat: `messages=` -> `greeting=`, and drop a stray second
`ui.chat_ui("chat")` that rendered a duplicate, empty chat sharing the
`"chat"` id (predates the deprecation, 4a9ea3f).
- templates/chat: `Chat(messages=...)` -> `Chat(greeting=...)` in the
azure-openai, langchain, anthropic, ollama and openai templates.
- bundled shiny-for-python skill: its chat reference taught `messages=` in
four places, including the minimal-app snippet.
- bookmark/chat/client_state: same constructor fix, so the apps start again.
`expect_messages("Welcome!")` is commented out rather than adapted -- a
greeting renders outside the message list -- and replaced with
`expect_greeting()` on first load only, since shinychat drops the greeting
once the conversation is non-empty. A TODO points at #2489 for covering
`history=` instead of the app's ad hoc get_state/set_state plumbing.
- components/chat/icon: startup messages -> `greeting=`, asserted for
existence only, since a greeting renders no `.message-icon` of its own.
The Default Bot now passes `icon_assistant=True`: as of 0.7.0 `None`
omits the icon rather than falling back to the built-in one, which is the
behaviour that chat exists to cover.
Both chat tests now depend on 0.7.0 semantics while `pyproject.toml` still
floors shinychat at 0.6.0, so they skip below it via a new
`skip_if_shinychat_older_than()` helper rather than failing.
schloerke
force-pushed
the
schloerke/fix-chat-example-greeting
branch
from
September 7, 2026 02:20
d5740f1 to
c48850d
Compare
Base automatically changed from
schloerke/ignore-anyio-blockingportal-warning
to
main
September 7, 2026 02:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second CI blocker on
main, independent of #2485 below it in this stack.shinychat 0.7.0 (2026-09-04) deprecated
messages=onchat_ui()/Chat.ui()in favour ofgreeting=, and made it an outright error on theChatconstructor unlesshistory=Falseis also passed:pyproject.tomlfloors atshinychat>=0.6.0, so CI resolves 0.7.0. Same shape as #2485: a third-party release moved underneath us.Changes
api-examples/Chat/{app-core,app-express}.py—messages=→greeting=. These emit aShinyDeprecationWarning, andtests/playwright/examples/example_apps.pyfails any app that emits a warning, so 30playwright-examplesjobs have been red since 2026-09-04.ui.chat_ui("chat")from the Core example. It rendered a duplicate, empty chat sharing the"chat"id — the bare call came first, so the example showed an empty chat above the real one. Unrelated to the deprecation and long-standing:4a9ea3f3(2025-03-27).templates/chat/**(5 apps) — azure-openai, langchain, anthropic, ollama, openai all passmessages=to the constructor, so they now raise on startup. Not exercised by CI, so this was invisible: worse than the examples, but silent.shiny/.agents/skills/shiny-for-python/references/chat.md— the bundled Agent Skill taughtmessages=in four places, including the minimal-app snippet. CLAUDE.md requires updating bundled skills in the same PR as the API they document.Verification
Built both examples' UI under
warnings.simplefilter("error")— the exact condition the check enforces — and both construct clean.black,isort,flake8clean.Still failing, and deliberately not fixed here
Two
playwright-shinyfailures share this root cause but need a decision from the chat owner rather than a guess from me. Both are pre-existing onmain(confirmed in run34021260595, 2026-09-06):bookmark/chat/client_state/{app,app-server}.pypassmessages=to the constructor, so they hit theValueError(6 tests). The app deliberately manages its own conversation state viaRepeaterClientand bookmarking, and the test assertsexpect_messages("Welcome!")— butgreeting=renders outsideloc_messages(there's a separateexpect_greeting), so migrating it changes what the test is actually asserting. The right fix depends on how py-shiny's chat bookmarking should interact with shinychat 0.7.0's newhistory=feature.components/chat/icon/test_chat_icon.py::test_validate_chat_basicfails onAssertionError: Locator expected to have class 'bi bi-robot'(2 tests). The test asserts the assistant icon on the startup message, whichmessages=used to create; migrating togreeting=means there is no such message until the user sends one, so the test needs restructuring rather than a parameter swap.