Skip to content

Commit 9b3f95e

Browse files
committed
Don't include html_deps in client message unless they're actually present
1 parent b59c931 commit 9b3f95e

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

js/chat/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type ShinyChatMessage = {
2727
handler: string;
2828
// Message keys will create custom element attributes, but html_deps are handled
2929
// separately
30-
obj: Message & { html_deps: HtmlDep[] };
30+
obj: Message & { html_deps?: HtmlDep[] };
3131
};
3232

3333
type UpdateUserInput = {

js/markdown-stream/markdown-stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type ContentMessage = {
2424
id: string;
2525
content: string;
2626
operation: "append" | "replace";
27-
html_deps: HtmlDep[];
27+
html_deps?: HtmlDep[];
2828
};
2929

3030
type IsStreamingMessage = {

shiny/ui/_chat.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,15 @@ async def _send_append_message(
759759
role=message["role"],
760760
content_type=content_type,
761761
chunk_type=chunk_type,
762-
html_deps=message.get("html_deps", []),
763762
)
764763

765764
if icon is not None:
766765
msg["icon"] = str(icon)
767766

767+
deps = message.get("html_deps", [])
768+
if deps:
769+
msg["html_deps"] = deps
770+
768771
# print(msg)
769772

770773
await self._send_custom_message(msg_type, msg)

shiny/ui/_chat_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ class ClientMessage(TypedDict):
3434
content_type: Literal["markdown", "html"]
3535
chunk_type: Literal["message_start", "message_end"] | None
3636
icon: NotRequired[str]
37-
html_deps: list[dict[str, str]]
37+
html_deps: NotRequired[list[dict[str, str]]]

shiny/www/py-shiny/chat/chat.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/py-shiny/markdown-stream/markdown-stream.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)