Skip to content

Commit 376cc57

Browse files
authored
fix(markdown-stream): Scroll to bottom when tool request/results finish rendering (#157)
* fix(markdown-stream): Scroll to bottom when tool request/results are rendered * chore: build and update assets
1 parent ec204ac commit 376cc57

File tree

16 files changed

+97
-77
lines changed

16 files changed

+97
-77
lines changed

js/dist/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.

js/dist/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.

js/dist/markdown-stream/markdown-stream.js

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

js/dist/markdown-stream/markdown-stream.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.

js/src/chat/chat-tools.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ class ShinyToolCard extends LitElement {
103103
this.requestUpdate()
104104
}
105105

106+
firstUpdated() {
107+
this.dispatchEvent(new CustomEvent("shiny-chat-maybe-scroll-to-bottom"))
108+
}
109+
106110
/**
107111
* Formats the title for display in the card header. Uses the `titleTemplate`,
108112
* replacing `{title}` with the actual title or name of the tool.

js/src/markdown-stream/markdown-stream.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ class MarkdownElement extends LightElement {
116116
return html`${contentToHTML(this.content, this.content_type)}`
117117
}
118118

119+
connectedCallback(): void {
120+
super.connectedCallback()
121+
this.addEventListener(
122+
"shiny-chat-maybe-scroll-to-bottom",
123+
this.#onMaybeScrollToBottom,
124+
)
125+
}
126+
119127
disconnectedCallback(): void {
120128
super.disconnectedCallback()
121129
this.#cleanup()
@@ -376,6 +384,10 @@ class MarkdownElement extends LightElement {
376384
return null
377385
}
378386

387+
#onMaybeScrollToBottom = (): void => {
388+
this.#maybeScrollToBottom()
389+
}
390+
379391
#maybeScrollToBottom(): void {
380392
const el = this.#scrollableElement
381393
if (!el || this.#isUserScrolled) return
@@ -390,6 +402,10 @@ class MarkdownElement extends LightElement {
390402
this.#scrollableElement?.removeEventListener("scroll", this.#onScroll)
391403
this.#scrollableElement = null
392404
this.#isUserScrolled = false
405+
this.removeEventListener(
406+
"shiny-chat-maybe-scroll-to-bottom",
407+
this.#onMaybeScrollToBottom,
408+
)
393409
}
394410
}
395411

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ec8feb87cb2a78c497d8ee66edd6f1e50faf1d48
1+
ec204acc3563226e4bcba3d48fc5b19418a9a360

pkg-py/src/shinychat/www/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.

pkg-py/src/shinychat/www/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.

pkg-py/src/shinychat/www/markdown-stream/markdown-stream.js

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

0 commit comments

Comments
 (0)