Skip to content

feat: rebuild one-liner apps on page() with auto-opening data drawer - #293

Merged
cpsievert merged 18 commits into
viz-defaultfrom
drawer-app
Sep 10, 2026
Merged

cpsievert merged 18 commits into
viz-defaultfrom
drawer-app

Conversation

@cpsievert

@cpsievert cpsievert commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #294 (visualize by default), itself stacked on #291.

Summary

Rebuilds the one-liner app entry points — querychat_app()/$app_obj() (R) and QueryChat.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 a chat_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 in page_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_chat field to chat (vals.chat.drawer.show()).

Verification

  • py: 889 unit tests pass; ruff check clean
  • R: testthat suite passes (4 pre-existing, unrelated TblSqlSource/duckdb CTE failures)
  • Both apps browser-verified with Playwright: drawer closed at start, auto-opens with data, no console errors

Comment thread pkg-r/R/QueryChat.R Resolved
@cpsievert
cpsievert requested a lite review from Copilot September 10, 2026 01:10
@cpsievert
cpsievert marked this pull request as ready for review September 10, 2026 01:11
@cpsievert
cpsievert changed the base branch from page-method to viz-default September 10, 2026 01:11

This comment was marked as resolved.

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).
…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
cpsievert added this pull request to stack #296 September 10, 2026 20:57
Comment thread pkg-r/DESCRIPTION Resolved
@cpsievert
cpsievert requested a lite review from Copilot September 10, 2026 21:00
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).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.py module, which makes its purpose opaque and violates the project's private-module naming convention. Rename it to a descriptive name such as auto_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 as handle_sql_editor_input.
            def _():

pkg-py/src/querychat/_shiny.py:503

  • This output callback uses a leading-underscore name inside the already-private _shiny.py module, contrary to the project's naming convention. Rename it to a descriptive name such as active_badge.
                    def _badge():

pkg-py/src/querychat/_shiny.py:512

  • This output callback uses a leading-underscore name inside the already-private _shiny.py module, contrary to the project's naming convention. Rename it to a descriptive name such as table_data.
                    def _dt():

pkg-py/src/querychat/_shiny.py:517

  • This output callback uses a leading-underscore name inside the already-private _shiny.py module, contrary to the project's naming convention. Rename it to a descriptive name such as sql_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 thread pkg-r/R/QueryChat.R
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"))
}
Comment thread pkg-py/CHANGELOG.md Outdated

### 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).
@cpsievert
cpsievert merged commit 3d432c8 into main Sep 10, 2026
18 checks passed
@cpsievert
cpsievert deleted the drawer-app branch September 10, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants