Skip to content

fix(pkg-py): accumulate streaming HTMLDependency objects and simplify bookmark restore#193

Draft
cpsievert wants to merge 7 commits intomainfrom
fix/simplify-message-storage-and-streaming-deps
Draft

fix(pkg-py): accumulate streaming HTMLDependency objects and simplify bookmark restore#193
cpsievert wants to merge 7 commits intomainfrom
fix/simplify-message-storage-and-streaming-deps

Conversation

@cpsievert
Copy link
Copy Markdown
Collaborator

Closes #192

Summary

  • Revert fix(pkg-py): re-send HTMLDependency objects on bookmark restore #191's narrow fix — the render_deps action and separate --deps bookmark key were a stopgap that didn't cover streamed messages.
  • Replace TransformedMessage with StoredMessage — drops the dual content_client/content_server split and the deprecated transform_user/transform_assistant parameters from messages(). Single content field plus html_deps.
  • Include html_deps in ChatMessageDictmessages() now returns serialized deps alongside each message, so bookmark save gets everything in one place.
  • Accumulate deps during streaming — new _current_stream_deps collector gathers deps across chunks and attaches them to the stored message at stream end.
  • Simplify bookmark save/restore — no more separate --deps key or render_deps hack. The restore path passes pre-serialized deps directly to the client via html_deps_serialized on _send_append_message.

Why Python-only

The R package doesn't have this issue — it re-renders from the ellmer client's restored turns on bookmark restore (contents_shinychat()as.tags()processDeps()), so HTMLDependencies are regenerated from scratch. Python saves/restores rendered message strings, so deps must be explicitly tracked.

Test plan

  • bookmark_html_deps — non-streaming HTMLDep bookmark restore (existing test, re-added after revert)
  • bookmark_html_deps_stream — streaming HTMLDep bookmark restore (new test)
  • transform / transform_assistant / transform_assistant_stream — transform decorators still work
  • Full suite: uv run pytest pkg-py/tests/ -x (61 tests pass)

🤖 Generated with Claude Code

cpsievert and others added 6 commits April 7, 2026 10:29
…sages()

Drop the dual content_client/content_server split and the deprecated
transform_user/transform_assistant parameters from messages().
StoredMessage has a single content field plus html_deps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The streaming path sent deps to the client during individual chunks
but didn't accumulate them on the stored message. This meant bookmark
save found no deps to serialize. Now deps are collected across chunks
and attached to the stored message at stream end.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drop the separate --deps save and render_deps hack. Messages now
carry their own deps, and the restore path passes pre-serialized deps
directly to the client.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cpsievert cpsievert marked this pull request as draft April 7, 2026 16:24
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

HTMLDependency objects lost during streaming message accumulation

1 participant