posit-dev / posit-dev/py-shiny

Test shinychat's `history=` feature instead of ad hoc bookmark state

Open
#2,489 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-triage:done Priority: Low
Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

Background

shinychat 0.7.0 added a first-class conversation-history feature: Chat(history=...), either True/False or a HistoryOptions instance with restore_mode ("browser" / "url" / "none" / "bookmark"), store ("auto" / "memory" / "file" / a custom ConversationStore), scope, title and max_store_mb.

We have no coverage of it. What we have instead is tests/playwright/shiny/bookmark/chat/client_state/, which predates the feature and hand-rolls the same job: a RepeaterClient implementing get_state/set_state, wired up through chat.enable_bookmarking(client, bookmark_store=...).

Two problems with that as our only coverage:

  1. It exercises plumbing an app shouldn't need to write any more. restore_mode="bookmark" participates in Shiny server bookmarking directly, and restore_mode="url" persists conversations with no Shiny bookmarking at all.
  2. It doesn't touch the parts most likely to break — the conversation store, scoping, restore modes, switching between conversations.
Why now

The app passed messages= to the Chat constructor, which shinychat 0.7.0 turned into a hard error (Chat(messages=...) requires history=False), so these tests went red on main for days. #2486 migrates the startup message to greeting= and points the assertion at expect_greeting, which gets CI green and incidentally covers the greeting bookmark round-trip — but it leaves the ad hoc state plumbing as the thing under test. There's a TODO in the test file pointing here.

What to cover
  • history=True vs False, and the history= + messages= interaction that now raises.
  • Each restore_mode: "browser" (localStorage, survives reload without touching the URL), "url" (?shinychat_conversation_id=), "none", "bookmark" (requires bookmark_store="server").
  • store="memory" — the docstring calls it out as the testing option.
  • scope for multi-user separation.
  • Switching conversations in-session, and @chat.history.on_save / on_restore callbacks.

Note: history= only takes effect when client= is also provided, so most of this needs a chatlas-shaped client. That may mean a fake client implementing the protocol rather than a real LLM.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in tests/playwright/shiny/bookmark/chat/client_state/ and follow the TODO, then inspect shinychat's Chat(history=...) and the available chatlas-shaped client protocol. Run the relevant Playwright tests while covering history settings, restore modes, stores, scoping, conversation switching, and callbacks; done means the first-class history feature replaces the ad hoc bookmark-state coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.