Skip to content

Commit 7ea4165

Browse files
committed
Static messages never replace existing messages
And fix StatusMessage type
1 parent 8ee90d5 commit 7ea4165

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

js/chat/chat.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type UpdateUserInput = {
3434
type StatusMessage = {
3535
content: string;
3636
content_type: Exclude<ContentType, "markdown">;
37-
replaceable: "true" | "false" | "";
37+
type: "dynamic" | "static";
3838
};
3939

4040
// https://github.com/microsoft/TypeScript/issues/28357#issuecomment-748550734
@@ -444,12 +444,14 @@ class ChatContainer extends LightElement {
444444
}
445445

446446
#onAppendStatus(event: CustomEvent<StatusMessage>): void {
447-
if (this.messages.lastChild instanceof ChatStatusMessage) {
448-
if (this.messages.lastChild.type == "dynamic") {
449-
// Update previous status message if last message was a status item
450-
this.messages.lastChild.content = event.detail.content;
451-
this.messages.lastChild.content_type = event.detail.content_type;
452-
return;
447+
if (event.detail.type === "dynamic") {
448+
if (this.messages.lastChild instanceof ChatStatusMessage) {
449+
if (this.messages.lastChild.type == "dynamic") {
450+
// Update previous status message if last message was a status item
451+
this.messages.lastChild.content = event.detail.content;
452+
this.messages.lastChild.content_type = event.detail.content_type;
453+
return;
454+
}
453455
}
454456
}
455457

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

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/chat/chat.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)