Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions js/dist/chat/chat.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/dist/chat/chat.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions js/dist/markdown-stream/markdown-stream.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/dist/markdown-stream/markdown-stream.js.map

Large diffs are not rendered by default.

31 changes: 14 additions & 17 deletions js/src/chat/chat-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ window.shinychat = window.shinychat || {}
window.shinychat.hiddenToolRequests =
window.shinychat.hiddenToolRequests || new Set<string>()

window.addEventListener("shiny-tool-request-hide", (event: CustomEvent) => {
// Hide the tool request element with the given request ID
const { request_id: requestId } = event.detail
if (!requestId) return
window.shinychat.hiddenToolRequests.add(requestId)
const toolRequestElement = document.querySelector<HTMLElement>(
`.shiny-tool-request[request-id="${requestId}"]`,
)
if (!toolRequestElement) return
toolRequestElement.hidden = true
})

/**
* Base class for a collapsible tool request or result card component.
*
Expand Down Expand Up @@ -193,28 +205,14 @@ export class ShinyToolRequest extends ShinyToolCard {

constructor() {
super()
this.classList.add("shiny-tool-request")
this.titleTemplate = "Running {title}"
this.icon = '<div class="spinner-border" role="status"></div>'
}

connectedCallback() {
super.connectedCallback()
this.hidden = window.shinychat.hiddenToolRequests.has(this.requestId)
window.addEventListener("shiny-tool-request-hide", this.#onToolRequestHide)
}

disconnectedCallback() {
super.disconnectedCallback()
window.removeEventListener(
"shiny-tool-request-hide",
this.#onToolRequestHide,
)
}

#onToolRequestHide = (event: CustomEvent) => {
if (event.detail.request_id === this.requestId) {
this.hidden = true
}
}

render() {
Expand Down Expand Up @@ -295,6 +293,7 @@ export class ShinyToolResult extends ShinyToolCard {

constructor() {
super()
this.classList.add("shiny-tool-result")
this.titleTemplate = "{title}"
}

Expand All @@ -307,7 +306,6 @@ export class ShinyToolResult extends ShinyToolCard {
this.titleTemplate = "{title} failed"
}
// Emit event to hide the corresponding tool request
window.shinychat.hiddenToolRequests.add(this.requestId)
this.dispatchEvent(
new CustomEvent("shiny-tool-request-hide", {
detail: { request_id: this.requestId },
Expand Down Expand Up @@ -420,7 +418,6 @@ const markdownCodeBlock = (content: string, language: string = "markdown") => {
window.Shiny?.addCustomMessageHandler(
"shiny-tool-request-hide",
(request_id) => {
window.shinychat.hiddenToolRequests.add(request_id)
const event = new CustomEvent("shiny-tool-request-hide", {
detail: { request_id },
bubbles: true,
Expand Down
2 changes: 1 addition & 1 deletion pkg-py/src/shinychat/www/GIT_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5c2a13cd6352282d4902d450bb8d0d7cd4718bad
9d753cee62a1fd7549d22621abb795d2d84df892
16 changes: 8 additions & 8 deletions pkg-py/src/shinychat/www/chat/chat.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pkg-py/src/shinychat/www/chat/chat.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pkg-py/src/shinychat/www/markdown-stream/markdown-stream.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg-r/inst/lib/shiny/GIT_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5c2a13cd6352282d4902d450bb8d0d7cd4718bad
9d753cee62a1fd7549d22621abb795d2d84df892
16 changes: 8 additions & 8 deletions pkg-r/inst/lib/shiny/chat/chat.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pkg-r/inst/lib/shiny/chat/chat.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pkg-r/inst/lib/shiny/markdown-stream/markdown-stream.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pkg-r/inst/lib/shiny/markdown-stream/markdown-stream.js.map

Large diffs are not rendered by default.