From c13e8bd6220bbfaa0fb0358902eb64b87c8ac630 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Wed, 24 Jun 2026 16:45:22 -0400 Subject: [PATCH 1/2] fix(pkg-r): hide close button in $app() when non-interactive Closes #259 --- pkg-r/R/QueryChat.R | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/pkg-r/R/QueryChat.R b/pkg-r/R/QueryChat.R index 576d9abc..b9b7a104 100644 --- a/pkg-r/R/QueryChat.R +++ b/pkg-r/R/QueryChat.R @@ -705,12 +705,14 @@ QueryChat <- R6::R6Class( ), DT::DTOutput("dt") ), - shiny::actionButton( - "close_btn", - label = "", - class = "btn-close", - style = "position: fixed; top: 6px; right: 6px;" - ) + if (rlang::is_interactive()) { + shiny::actionButton( + "close_btn", + label = "", + class = "btn-close", + style = "position: fixed; top: 6px; right: 6px;" + ) + } ) } @@ -777,17 +779,19 @@ QueryChat <- R6::R6Class( ) }) - shiny::observeEvent(input$close_btn, label = "on_close_btn", { - name <- active_table_name() - shiny::stopApp( - list( - df = qc_vals$.tables[[name]]$df(), - sql = qc_vals$.tables[[name]]$sql(), - title = qc_vals$.tables[[name]]$title(), - client = qc_vals$client + if (rlang::is_interactive()) { + shiny::observeEvent(input$close_btn, label = "on_close_btn", { + name <- active_table_name() + shiny::stopApp( + list( + df = qc_vals$.tables[[name]]$df(), + sql = qc_vals$.tables[[name]]$sql(), + title = qc_vals$.tables[[name]]$title(), + client = qc_vals$client + ) ) - ) - }) + }) + } } shiny::shinyApp(ui, server, enableBookmarking = bookmark_store) From 551d9cbb945d01ccc0b1c4e5b4dba809ed88e9c8 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Wed, 24 Jun 2026 16:56:08 -0400 Subject: [PATCH 2/2] docs(pkg-r): add NEWS bullet for #259 --- pkg-r/NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg-r/NEWS.md b/pkg-r/NEWS.md index 7775a851..087e1c38 100644 --- a/pkg-r/NEWS.md +++ b/pkg-r/NEWS.md @@ -39,6 +39,8 @@ * Fixed `data_description` and `extra_instructions` being HTML-escaped in the system prompt. Special characters like `<`, `>`, and `&` in developer-provided descriptions and instructions are now passed to the LLM verbatim. (#258) +* The close button in `$app()` is now hidden when running in a non-interactive context (e.g. a deployed Shiny app), preventing `stopApp()` from crashing the session for other users. (#259) + # querychat 0.3.0 ## New features