Skip to content

docs: mark reactive accessors experimental - #507

Draft
cpsievert wants to merge 2 commits into
mainfrom
docs-accessors-experimental
Draft

cpsievert wants to merge 2 commits into
mainfrom
docs-accessors-experimental

Conversation

@cpsievert

@cpsievert cpsievert commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #508 (which is stacked on #511); merge that first. The diff here shows only this PR's changes.

Why

The next release adds a very large public surface in one step: 41 render_* decorators and 83 reactive accessor methods across them (clicked(), selected(), view_state(), ...), plus .read(name), listen_to=, and rate_policy/rate_delay. The accessor names were renamed three times in the weeks before this, and which accessors are opt-in is still being adjusted. Once this ships without a caveat, every name, return shape, and default becomes a compatibility promise. This PR marks the accessor API experimental (docs only -- no runtime warnings, no behavior change) so the next rename doesn't need a deprecation cycle.

It also reclassifies one Unreleased changelog item: returning a @reactive.calc-cached widget from a render that re-runs for a reason the calc doesn't share used to display a (possibly stale) widget on 0.8.2; on main it now raises a clear ownership error. That's a visible breaking change for a real pattern, not just a bug fix, so it gets its own Breaking changes entry with the fix.

Where the experimental notice appears

Same wording everywhere: "Experimental: accessor names, return shapes, and which accessors are opt-in may change in a future release without a deprecation cycle."

  • CHANGELOG.md, as its own paragraph under the existing "Rendered outputs gain reactive accessors" bullet (didn't touch that bullet's own lines, since other PRs are concurrently editing its plotly sentences)
  • website/guide/reacting-to-widgets/index.md -- the guide's intro, which every widget page's "Reacting to user interaction" section and the cheat sheet point back to
  • shinywidgets/.agents/skills/shinywidgets/references/reacting-to-widgets.md -- the matching skill reference, same spot

Candidates considered and skipped: SKILL.md's index table (kept index-only, matching the existing shared_lifetime() precedent, whose experimental marker also lives only in the reference body) and the 41 renderer docstrings in shinywidgets/_render_widget.py (each hand-repeats a "Responding to user interaction" paragraph; adding a sentence there means touching all 41). I also built the site and confirmed render_widget_base's and read()'s docstrings don't reach the generated per-renderer reference pages (quartodoc only lists each render_* subclass's own methods), so they wouldn't have helped either.

New breaking-change entry

Returning a widget from a @reactive.calc to a @render_widget-family output can now raise an error that didn't happen before, if the render re-runs while the calc doesn't (e.g. it also reads another input):

@reactive.calc
def base_map():
    return ipyleaflet.Map(center=(51.5, -0.09), zoom=4)

@render_widget
def calc_map():
    input.rerender()  # the render depends on something the calc doesn't
    return base_map()

The re-run closes the widgets its previous run built, including the one the calc cached, so it now raises Map was closed (its render was invalidated, or it was closed explicitly), so it can't be displayed again... instead of showing the map, as 0.8.2 did. Build the widget inside with session_lifetime(): in the calc. (#258, #262)

The existing bug-fix sub-bullet ("Returning a widget closed by an earlier render raises a similar error") now cross-references this instead of duplicating it. The same mechanism (and trap) is also spelled out in website/guide/updating-in-place/index.md's Lifetimes section and its matching skill reference, with the exact error text.

I verified the session_lifetime() fix directly with a scratch test modeled on tests/unit/test_widget_lifetimes.py: a renderer returning a plain cached widget raises pointing at session_lifetime once its first render is invalidated (reproducing the regression), and wrapping that same cached construction in with session_lifetime(): lets the renderer re-render successfully across four invalidate/re-render cycles, each returning the same model_id.

Branch name note

Asked-for name docs/accessors-experimental collided with an existing flat branch named docs on origin (git can't have both a ref file docs and a ref directory docs/). Used docs-accessors-experimental instead, matching the flat-hyphenated convention other concurrent branches on this repo are already using for the same reason.

Verification

  • uv run pytest tests/unit/test_agent_skill.py -- 284 passed, 4 skipped (optional deps not installed)
  • uv run python website/_tools/check_docs.py -- no output (clean)
  • make check-format -- clean
  • make docs -- built successfully; confirmed the experimental notice and the lifetimes trap note render correctly
  • No Python files changed, so make check-types wasn't required

@netlify

netlify Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for shinywidgets canceled.

Name Link
🔨 Latest commit 72ad017
🔍 Latest deploy log https://app.netlify.com/projects/shinywidgets/deploys/6b0dc1573a693f25d01c9588

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request November 23, 2026 23:18 Inactive
@cpsievert
cpsievert force-pushed the docs-accessors-experimental branch from 6512cd9 to 9b988e5 Compare November 23, 2026 23:22
@cpsievert
cpsievert changed the base branch from main to fix/plotly-brushing-opt-in November 23, 2026 23:22
@cpsievert
cpsievert requested a balanced review from Copilot November 23, 2026 23:23

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.

🟢 Approval recommended

No active review issues are reported for this documentation-only update clarifying experimental accessors and cached-widget lifetimes.

No open issues 🎉

What changed in this PR

This documentation-only PR marks shinywidgets’ reactive accessor API as experimental and clarifies the breaking change affecting widgets cached by @reactive.calc. It keeps website guidance and bundled agent references aligned; runtime behavior is unchanged.

Changes:

  • Adds a consistent experimental notice covering accessor names, return shapes, and opt-in defaults.
  • Documents why cached widgets can be closed between renders and how session_lifetime() prevents this.
  • Reclassifies the cached-widget ownership error as a breaking change in the changelog.
File Description
website/​guide/​updating-in-place/​index.md Explains the cached-widget lifetime trap and remedy.
website/​guide/​reacting-to-widgets/​index.md Adds the experimental accessor notice.
shinywidgets/​.agents/​skills/​shinywidgets/​references/​updating-in-place.md Mirrors the lifetime guidance for agents.
shinywidgets/​.agents/​skills/​shinywidgets/​references/​reacting-to-widgets.md Mirrors the experimental accessor notice.
CHANGELOG.md Marks accessors experimental and documents the cached-widget breaking change.

Review effort: Balanced

@github-actions
github-actions Bot temporarily deployed to pull request November 23, 2026 23:26 Inactive
@cpsievert
cpsievert force-pushed the docs-accessors-experimental branch from 9b988e5 to 3288b44 Compare November 23, 2026 23:30
@cpsievert
cpsievert added this pull request to stack #513 November 30, 2026 16:52
@github-actions
github-actions Bot temporarily deployed to pull request November 30, 2026 16:55 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request November 30, 2026 17:22 Inactive
@cpsievert
cpsievert force-pushed the docs-accessors-experimental branch from 4cf353c to dac452b Compare November 30, 2026 18:06
@github-actions
github-actions Bot temporarily deployed to pull request November 30, 2026 18:10 Inactive
Base automatically changed from fix/plotly-brushing-opt-in to main November 30, 2026 18:32
…e regression

The accessor API (41 render_* decorators, 83 accessor methods, listen_to,
rate_policy/rate_delay) ships in the next release with names and shapes
that were still being renamed weeks before cut. Mark it experimental in
the two places a user or agent actually encounters it -- the accessors
guide article and its matching skill reference -- rather than all 41
renderer docstrings.

Also reclassify the "returning a closed widget now raises" bug fix: for
a widget built by a @reactive.calc and returned by a render with its own
independent invalidation trigger, this is a visible breaking change from
0.8.2, not just a bug fix. Add a Breaking changes entry with the fix
(construct the widget inside `with session_lifetime():`), verified
against the actual render/invalidate cycle, and note the same trap in
the widget-lifetimes guide and its skill reference.
The breaking-change entry, skill reference, and guide paragraph all
implied a second render returns the calc's cached widget. It's actually
the same render re-running: its own re-run closes the widgets it built
last time (including the one the calc cached), so the calc hands back
an already-closed widget on the next call. Rewrite all three to
describe that accurately.
@cpsievert
cpsievert force-pushed the docs-accessors-experimental branch from dac452b to 72ad017 Compare November 30, 2026 18:32
@github-actions
github-actions Bot temporarily deployed to pull request November 30, 2026 18:35 Inactive

This branch was previously deployed

1 inactive deployment
pull request — 72ad017e Deployed Nov 30, 2026 by github-actions[bot]
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