Skip to content

Commit 5419472

Browse files
authored
Fix Chat()'s loading message removal (on error) (#1679)
1 parent b52ec80 commit 5419472

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
* Fixed a bug with `Chat()` sometimes silently dropping errors. (#1672)
1313

14+
* Fixed a bug with `Chat()` sometimes not removing it's loading icon (on error or a `None` transform). (#1679)
15+
1416
* `shiny create` now uses the template `id` rather than the directory name as the default directory. (#1666)
1517

1618
## [1.1.0] - 2024-09-03

js/chat/chat.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,20 +398,19 @@ class ChatContainer extends LightElement {
398398
}
399399
}
400400

401+
// Loading message is just an empty message
401402
#addLoadingMessage(): void {
402403
const loading_message = {
403404
content: "",
404405
role: "assistant",
405-
id: `${this.id}-loading-message`,
406406
};
407407
const message = createElement(CHAT_MESSAGE_TAG, loading_message);
408408
this.messages.appendChild(message);
409409
}
410410

411411
#removeLoadingMessage(): void {
412-
const id = `${this.id}-loading-message`;
413-
const message = this.messages.querySelector(`#${id}`);
414-
if (message) message.remove();
412+
const content = this.lastMessage?.content;
413+
if (!content) this.lastMessage?.remove();
415414
}
416415

417416
#onAppendChunk(event: CustomEvent<Message>): void {

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: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)