Skip to content

fix(examples): stop passing the deprecated messages= to Chat - #2486

Merged
schloerke merged 2 commits into
mainfrom
schloerke/fix-chat-example-greeting
Sep 7, 2026
Merged

fix(examples): stop passing the deprecated messages= to Chat#2486
schloerke merged 2 commits into
mainfrom
schloerke/fix-chat-example-greeting

Conversation

@schloerke

@schloerke schloerke commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Second CI blocker on main, independent of #2485 below it in this stack.

shinychat 0.7.0 (2026-09-04) deprecated messages= on chat_ui() / Chat.ui() in favour of greeting=, and made it an outright error on the Chat constructor unless history=False is also passed:

ValueError: `Chat(messages=...)` requires `history=False`: startup messages
can't be recorded by the conversation-history feature. Use the `greeting`
parameter for a startup message, ...

pyproject.toml floors at shinychat>=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}.pymessages=greeting=. These emit a ShinyDeprecationWarning, and tests/playwright/examples/example_apps.py fails any app that emits a warning, so 30 playwright-examples jobs have been red since 2026-09-04.
  • Dropped a stray second 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 pass messages= 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 taught messages= 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, flake8 clean.

Still failing, and deliberately not fixed here

Two playwright-shiny failures share this root cause but need a decision from the chat owner rather than a guess from me. Both are pre-existing on main (confirmed in run 34021260595, 2026-09-06):

  1. bookmark/chat/client_state/{app,app-server}.py pass messages= to the constructor, so they hit the ValueError (6 tests). The app deliberately manages its own conversation state via RepeaterClient and bookmarking, and the test asserts expect_messages("Welcome!") — but greeting= renders outside loc_messages (there's a separate expect_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 new history= feature.
  2. components/chat/icon/test_chat_icon.py::test_validate_chat_basic fails on AssertionError: Locator expected to have class 'bi bi-robot' (2 tests). The test asserts the assistant icon on the startup message, which messages= used to create; migrating to greeting= means there is no such message until the user sends one, so the test needs restructuring rather than a parameter swap.

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
schloerke force-pushed the schloerke/fix-chat-example-greeting branch from d802bbc to e302a5c Compare September 7, 2026 01:47
@schloerke schloerke changed the title fix(examples): use greeting= in the Chat API examples fix(examples): stop passing the deprecated messages= to Chat Sep 7, 2026
@schloerke
schloerke force-pushed the schloerke/fix-chat-example-greeting branch from e302a5c to d5740f1 Compare September 7, 2026 02:05
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
schloerke force-pushed the schloerke/fix-chat-example-greeting branch from d5740f1 to c48850d Compare September 7, 2026 02:20
Base automatically changed from schloerke/ignore-anyio-blockingportal-warning to main September 7, 2026 02:29
@schloerke
schloerke merged commit 9ab6f65 into main Sep 7, 2026
176 checks passed
@schloerke
schloerke deleted the schloerke/fix-chat-example-greeting branch September 7, 2026 02:29
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