Repository navigation
feat: rebuild one-liner apps on page() with auto-opening data drawer - #293
Merged
Merged
Conversation
cpsievert
commented
Sep 10, 2026
cpsievert
marked this pull request as ready for review
September 10, 2026 01:11
cpsievert
force-pushed
the
drawer-app
branch
from
September 10, 2026 01:11
e0faf04 to
557f334
Compare
cpsievert
force-pushed
the
drawer-app
branch
from
September 10, 2026 16:54
8d4fbf7 to
e8df3de
Compare
Rebuild QueryChat.app()'s UI on the shinychat page_chat() layout (via .page()) instead of page_sidebar. The SQL editor and data table cards move into a chat_drawer(open=False), and a reactive effect in the generated server auto-opens the drawer (chat.drawer.show()) whenever a query lands on the active table. ServerValues gains shinychat_chat (None in stub sessions) so host apps can drive chat-level UI like the drawer controller. Prototype only: R port, mobile auto-open behavior, and drawer sizing are still open questions.
Mirror of the Python prototype: $app_obj()/$app() now build on $page() (shinychat::page_chat()) instead of bslib::page_sidebar. The SQL editor and DT cards move into shinychat::chat_drawer(open = FALSE), and a server-side observer calls chat_drawer_show() when a query lands on the active table. Busy indicators and the gadget close button ride in the page_chat() footer slot (page_chat owns the whole document). Also fixes a real bug this surfaced: R Shiny only re-scans output visibility on bindAll/unbindAll or jQuery shown/hidden events, so outputs inside an initially-closed drawer stayed suspended server-side forever. querychat.js now watches the drawer's hidden attribute and triggers the shown/hidden events Shiny listens for (jQuery-guarded; py-shiny tracks visibility itself). Worth an upstream shinychat fix. - DESCRIPTION bumps shinychat to >= 0.5.0 (page_chat/drawer API) - Adds test-QueryChat coverage for the new app UI structure - Adds inst/examples-shiny/13-app-drawer smoke-test app
Shiny 1.14.0 (on CRAN since 2026-06-21) replaced jQuery/Bootstrap event-driven output visibility tracking with per-output ResizeObserver/IntersectionObserver (rstudio/shiny#3682, #4388), which handles shinychat's drawer toggling the hidden attribute natively. The jQuery-based MutationObserver shim in querychat.js is no longer needed on either side (py-shiny tracked visibility itself already).
The 13-app-drawer examples were smoke-test checklists rather than instructive examples. Also drops the standalone NEWS bullet for the shiny >= 1.14.0 requirement and adds chat-first app() entries to both NEWS.md and CHANGELOG.md.
Re-applies web edit e0faf04 that was clobbered by the history-rewrite force push.
Also drops the shiny >= 1.14.0 pin from DESCRIPTION -- it moves down the stack to chat-footer-extras (#292).
…hat skip version - The drawer branch's older _shiny.py content had clobbered page-method's pyright: ignore[reportPrivateImportUsage] on the namespace_context import, failing make py-check-types in CI. - Copilot: () tests skipped on shinychat >= 0.4.0.9000, but DESCRIPTION requires >= 0.5.0.
app() now starts with the data drawer closed (it auto-opens when a query lands), so fixtures that waited for a visible table on page load timed out. Add an open_data_drawer() helper that clicks the drawer trigger before waiting for the table.
Makes the data table the drawer's primary content and tucks the SQL editor behind a "Show Query" toggle in its footer, mirroring the existing ggSQL show/hide pattern used by the Visualize tool. Also replaces the drawer's fixed 720px width with a clamp-based policy (matching the chat container's own width formula) so it no longer dominates mid-size viewports.
The drawer previously just said "Drawer" and only ever showed the table the chat most recently touched, with no way to look at the others. Now it's titled "Data Sources", and when more than one table is registered, a fully static accordion below the pinned "active table" card gives on-demand access to every table's own data grid and read-only SQL query -- with a small badge marking which one the chat is currently focused on. Single-table apps are unaffected (no accordion, same pinned card as before).
cpsievert
force-pushed
the
drawer-app
branch
from
September 10, 2026 18:35
2125b81 to
781d8ff
Compare
…e2e tests The data drawer's SQL panel moved behind a "Show Query" footer toggle; Shiny suspends rendering of outputs inside hidden containers, so the sql_editor code editor never mounted in the DOM for tests that checked its value without expanding the section first.
cpsievert
commented
Sep 10, 2026
On slow CI runners the first click can land before shinychat's React client has attached its handler, silently swallowing it; every app()-based e2e test then timed out waiting for the drawer's table. Retry the click until the drawer is actually open (and don't click at all if it auto-opened already).
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Add R/Python integration coverage for drawer auto-opening and address the noted naming and changelog issues.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (5)
pkg-py/src/querychat/_shiny.py:479
- The new reactive callback is named
_inside the private_shiny.pymodule, which makes its purpose opaque and violates the project's private-module naming convention. Rename it to a descriptive name such asauto_open_drawer.
async def _():
pkg-py/src/querychat/_shiny.py:487
- This newly registered effect is also named
_inside a private module, so logs and debugging cannot distinguish it from the other reactive callbacks. Give it a descriptive name such ashandle_sql_editor_input.
def _():
pkg-py/src/querychat/_shiny.py:503
- This output callback uses a leading-underscore name inside the already-private
_shiny.pymodule, contrary to the project's naming convention. Rename it to a descriptive name such asactive_badge.
def _badge():
pkg-py/src/querychat/_shiny.py:512
- This output callback uses a leading-underscore name inside the already-private
_shiny.pymodule, contrary to the project's naming convention. Rename it to a descriptive name such astable_data.
def _dt():
pkg-py/src/querychat/_shiny.py:517
- This output callback uses a leading-underscore name inside the already-private
_shiny.pymodule, contrary to the project's naming convention. Rename it to a descriptive name such assql_view.
def _view():
- Files reviewed: 16/16 changed files
- Comments generated: 3
- Review effort level: Lite
Comment on lines
+479
to
+483
| async def _(): | ||
| # Auto-open the data drawer when a new query lands | ||
| name = active_table_name() | ||
| if vals.table(name).sql() and vals.chat is not None: | ||
| await vals.chat.drawer.show() |
Comment on lines
+827
to
+831
| shiny::observe(label = "auto_open_drawer", { | ||
| name <- active_table_name() | ||
| if (shiny::isTruthy(qc_vals$.tables[[name]]$sql())) { | ||
| shinychat::chat_drawer_show(shiny::NS(self$id)("chat")) | ||
| } |
|
|
||
| ### New features | ||
|
|
||
| * `QueryChat.app()` (Core and Express) is now chat-first: it builds on the `.page()` layout, so the chat owns the window, and the SQL editor + data table live in a `chat_drawer` that auto-opens when the LLM runs a query (including on bookmark/history restore). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #294 (visualize by default), itself stacked on #291.
Summary
Rebuilds the one-liner app entry points —
querychat_app()/$app_obj()(R) andQueryChat.app()(py) — on the$page()/page()layout from #291, making them chat-first: chat owns the window, and the SQL editor + data table live in achat_drawer(open = FALSE)that auto-opens server-side when a query lands on the active table (including on bookmark/history restore). Busy indicators and the gadget close button ride inpage_chat()'s footer slot.Note: the R shiny >= 1.14.0 requirement this relies on (per-output ResizeObserver/IntersectionObserver visibility tracking, so outputs render inside an initially-closed drawer) is introduced down-stack in #292.
Also renames the py
ServerValues.shinychat_chatfield tochat(vals.chat.drawer.show()).Verification