feat: Allow deferred data_source initialization#202
Merged
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Stores table_name and init parameters for deferred system prompt building. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Normalizes the data source and rebuilds system prompt when set. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Methods that need data_source now raise RuntimeError with helpful message. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Allows deferred data source pattern where UI is created before data source is available (e.g., in Shiny Core global scope). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
QueryChatExpress requires data_source at init since it calls mod_server. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
These frameworks require data_source before app()/ui() since there's no separate server() call like in Shiny. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cpsievert
commented
Jan 23, 2026
cpsievert
commented
Jan 23, 2026
cpsievert
commented
Jan 23, 2026
cpsievert
commented
Jan 23, 2026
- Add ibis.Table to server() data_source type hint - Remove unnecessary comments in server() method - Make QueryChatExpress data_source required (not optional) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add assert statements after _require_data_source() calls to help pyright narrow types from DataSource | None to DataSource. Also capture local variables for nested functions where type narrowing doesn't carry through. feat(pkg-r): implement deferred data source pattern Allow data_source to be NULL at initialization, deferring the actual data source binding until $server() is called. This enables Shiny Core apps where UI is in global scope but database connections need to be created per-user in server scope. Changes: - data_source parameter accepts NULL in initialize() - $data_source property is now settable - $server() accepts optional data_source parameter - Added _require_data_source checks to methods that need data - Updated CHANGELOG.md and NEWS.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cpsievert
commented
Jan 23, 2026
Document the deferred data source pattern for per-user database connections in Shiny Core applications. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update _data_source type annotation to DataSource | None to match QueryChatBase. Add assertions to methods that use _data_source. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Assert statements are used for type narrowing after _require_data_source() which already handles runtime validation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…pe narrowing Replace assert statements with `# noqa: S101` by having `_require_data_source()` return the validated DataSource. This provides cleaner type narrowing without needing to suppress lint warnings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `data_source: None` overload to QueryChatExpress - Use class variable to cache bookmarking settings between stub and real sessions - Defer mod_server() call to real session (skip during stub session) - Add _require_vals() helper for safe accessor access - Update documentation for Express deferred pattern Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update mod_server() to accept data_source: DataSource | None - Handle None data_source during stub session (return placeholder ServerValues) - Raise clear error if data_source is None during real session - Simplify QueryChatExpress to always call mod_server() with self._data_source - Remove _require_vals() helper, use self._vals directly Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cpsievert
commented
Jan 23, 2026
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.
Summary
data_sourceto beNoneatQueryChatinitialization, deferring binding untilserver()is calleddata_sourceproperty that rebuilds system prompt when changeddata_sourceparameter to Shinyserver()method for the deferred patternNonedata_sourceMotivation
This enables Shiny Core applications where:
Test plan
🤖 Generated with Claude Code