Skip to content

refactor: inject querychat extras via shinychat's footer slot - #292

Merged
cpsievert merged 4 commits into
mainfrom
chat-footer-extras
Sep 10, 2026
Merged

cpsievert merged 4 commits into
mainfrom
chat-footer-extras

Conversation

@cpsievert

@cpsievert cpsievert commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Why

mod_ui() (R and Python) previously delivered querychat's dependencies and the handoff panel as tagList() siblings of chat_ui(). This routes them through shinychat's footer slot instead — the only child-injection point page_chat() accepts — so extras injection works uniformly across chat entry points. This is groundwork for a forthcoming page()/$page() method (stacked PR to follow).

What changes

  • mod_ui() builds the extras (dependencies + handoff panel) into a .querychat-extras wrapper in the chat footer, merging any user-supplied footer and class.
  • enable_cancel/allow_attachments defaults are deferred to shinychat's client-based auto-enable.
  • styles.css source moves to js/src/; new rule collapses footer padding when it holds only the inert extras.
  • Bug fix: shinychat re-adopts the footer into its React tree at page load, which races <bslib-code-editor>'s async init and leaves a second, stale editor instance in the handoff panel. All but the last (live) instance are hidden via CSS; handoff E2E selectors are scoped to :visible.

Test plan

  • Python unit tests (875) and R testthat files pass
  • Full handoff Playwright suite (21 tests) passes, including the editor reopen/restore flows

Also on this branch

  • Bumps the R shiny requirement to >= 1.14.0: its per-output ResizeObserver/IntersectionObserver visibility tracking is needed for querychat UI living in shinychat chrome (footer extras here; the auto-opening data drawer in the stacked drawer-app PR).

This comment was marked as resolved.

cpsievert added a commit that referenced this pull request Sep 10, 2026
cpsievert added a commit that referenced this pull request Sep 10, 2026
Also drops the shiny >= 1.14.0 pin from DESCRIPTION -- it moves down
the stack to chat-footer-extras (#292).
mod_ui() (R and Python) now delivers querychat's dependencies and the handoff panel through chat_ui()'s footer slot instead of tagList siblings, unifying extras injection with page_chat(), where the footer is the only child-injection point. This is groundwork for a forthcoming page() method.

- Defer enable_cancel/allow_attachments defaults to shinychat's client-based auto-enable
- Move styles.css source to js/src and collapse footer padding when it holds only the inert extras
- Hide the stale duplicate code editor that shinychat's footer re-adoption creates by racing bslib-code-editor's async init; scope handoff E2E selectors to :visible
Per-output ResizeObserver/IntersectionObserver visibility tracking
(replacing jQuery/Bootstrap event-driven tracking) is needed for
querychat UI living in shinychat chrome -- footer extras here, and the
auto-opening data drawer in the stacked drawer-app PR.
cpsievert added a commit that referenced this pull request Sep 10, 2026
Also drops the shiny >= 1.14.0 pin from DESCRIPTION -- it moves down
the stack to chat-footer-extras (#292).
shinychat's footer centers its own content (the message composer),
which cascaded into the handoff panel and other footer-injected
querychat UI once extras moved into the footer slot, center-aligning
the handoff source editor and anything else rendered there.
cpsievert added a commit that referenced this pull request Sep 10, 2026
Also drops the shiny >= 1.14.0 pin from DESCRIPTION -- it moves down
the stack to chat-footer-extras (#292).
@cpsievert
cpsievert added this pull request to stack #296 September 10, 2026 20:57
@cpsievert
cpsievert merged commit 583c6e2 into main Sep 10, 2026
18 of 25 checks passed
@cpsievert
cpsievert deleted the chat-footer-extras branch September 10, 2026 22:30
cpsievert added a commit that referenced this pull request Sep 10, 2026
…293)

* feat(py): prototype app() on page() layout with auto-opening data drawer

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.

* docs(py): add drawer-layout smoke-test example app

* docs(py): fix run instructions to use project venv python

* feat(r): port app_obj() to page() layout with auto-opening data drawer

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

* require shiny >= 1.14.0 and drop drawer visibility shim

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).

* style(py): fix docstring formatting lint in drawer app test

* docs: drop drawer smoke examples; NEWS/CHANGELOG for chat-first app()

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.

* chore(py): restore querychat.js to base (shim removal left only newline diff)

* refactor(r): drop redundant comment in app_obj() ui

Re-applies web edit e0faf04 that was clobbered by the history-rewrite
force push.

* refactor(py): rename ServerValues.shinychat_chat to chat

Also drops the shiny >= 1.14.0 pin from DESCRIPTION -- it moves down
the stack to chat-footer-extras (#292).

* fix: restore pyright ignore on namespace_context import; align shinychat 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.

* test(py): open data drawer in e2e fixtures for qc.app()-based apps

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.

* refactor: demote SQL view to a footer control, tame drawer width

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.

* feat: give the drawer a real title and on-demand access to all tables

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).

* test(py): reveal SQL query section before asserting on sql_editor in 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.

* Update pkg-r/DESCRIPTION

* test(py): retry drawer-trigger click in e2e open_data_drawer

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).

* docs(py): correct changelog -- app() is Core-only (Copilot)
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