Skip to content

v3.14.0

Choose a tag to compare

@HollowTheSilver HollowTheSilver released this 06 Oct 21:29
· 10 commits to main since this release

This release rebuilds how a view owns its message. A push or pop is one transaction, a close and a send take turns instead of racing, and renders land in the order they were asked for, so the clicks, navigation, and teardown a busy panel sees at once no longer leave a dead or doubled panel behind. Persistence now closes with the bot and writes what it batched, a restart in the same process restores its panels, and undo leaves other users' data alone. Read Breaking before upgrading: most of its entries turn a silent failure into an error at the call that caused it, and a few change behavior that worked.

Breaking

  • A modal callback that re-renders its view and then replies through interaction.response raises InteractionResponded, as a click callback doing the same always has: the re-render now answers the submission (see Changed). Reply with the view's respond() or with interaction.followup.
  • A re-posted persistent panel leaves its old message frozen instead of deleted. The old message now closes by the panel's exit_policy, like every other view's; set exit_policy = "delete" to keep deleting it.
  • replace() closes the view it was called on as that view's exit() would: the message is frozen or deleted by its exit_policy, attached views close, a persistent registration is removed, and an exit() override runs. Drop any cleanup of the old message that follows a replace().
  • A view that pushed or popped away hands its message to the new view. Its message reads None, push(), pop(), and replace() on it raise, and exit() on it does nothing. Navigate from the view the call returned, or reach the screen a panel shows now through the new current_view; a subclass with its own current_view attribute needs another name for it.
  • Navigation raises RuntimeError where it used to leave the panel inconsistent: from inside a push or pop the view takes part in (the new view's on_load(), a rebuild= or nav_rebuild hook), from inside the view's own send(), on a view that has closed or is closing, and with an instance already sent, pushed, or closed. A rebuild= or nav_rebuild hook that calls reload() or load() raises too, since the new view has already loaded.
  • Reducers run one at a time. A reducer that awaits holds up other dispatches until it returns, and dispatch() from inside a reducer raises instead of being lost. An on_state_changed() that awaits a separate task reloading its own view stalls, with a warning after 30 seconds; await self.reload() directly instead.
  • Closing a view a persistent panel pushed to retires the panel's registration, whether the message is frozen or deleted, so the closed panel no longer comes back after a restart. Give the pushed screen a Back button when the panel should stay up behind it.
  • More mistakes fail where they are made: persistence_key= must be a non-empty string, more class attributes are checked when the class is defined, persistent panels check the ids of nested controls and of buttons their on_load() builds, set_class_attribute() refuses attributes the library reads from the class, and PaginatedRegion.show_page() raises before the region has a host.

Added

  • current_view follows a panel through every push(), pop(), and ephemeral Continue to the view now showing it, so code holding the panel, a cog closing it from a command, reaches the screen on it.
  • exit_children() closes the views attached to a view and leaves it open, for a game closing its players' private panels when a round ends.
  • load() runs a view's on_load() under the same lock as reload(), without editing its message.
  • The ephemeral Continue button's hooks are public: build_refresh_button() builds the button, and build_reopen_view(interaction) builds the view it sends.
  • on_session_ended(interaction) and session_ended_message answer a user who reaches a session that has ended, such as a modal submitted after its view closed.
  • auto_exit_button on the paginated, tab, wizard, and form patterns, as MenuView has.
  • notify=False on set_page(), switch_tab(), and PaginatedRegion.show_page() moves without firing the change hook, for a jump the view makes on its own.
  • DISCORD_CALL_ERRORS groups the exceptions a failed Discord call raises: discord.HTTPException, discord.RateLimited, and aiohttp.ClientError.
  • Smaller additions: InstanceLimitError.scope, Collapsible(summary=) taking the text itself, and fetch_as_file(max_bytes=).

Changed

  • A modal opened from a view's button answers its submission with the view's re-render, in one request, as a click does, so a click made right after it can no longer land first.
  • A custom persistence backend must open again when initialize() is called after close(). Persistence now closes with the bot and reopens the same backend objects on a restart in the same process; the built-in backends support this. Closing a SQL backend waits up to five seconds for a running transaction, then closes anyway.
  • Outside a persistent view, choice_row, and button_row or tab_nav given a custom_id=, no longer number their buttons by position, so two choice_rows in one view no longer need distinct ids.
  • A frozen panel keeps its link buttons clickable.
  • The log file follows the date, moving to the new day's file at midnight so max_files applies to a bot that runs for weeks.
  • A click the library answers without running its callback logs a DEBUG line naming the view, the control, and why.

Deprecated

  • _build_refresh_button() is now build_refresh_button(). An override of the old name keeps working and warns with a DeprecationWarning when its class is defined. The old name is removed in 4.0.0.

Fixed

  • A push or pop always ends as a landed swap or a working source. A failed or stalled navigation leaves the view it started from working, only the navigation edits the message while it runs, and a push and a send of the same view no longer overlap.
  • A click sent from a screen that has since changed no longer runs a different button. Generated ids now also reflect what a button does, a click on a disabled or replaced button is dropped or answered, and a double-click acts once, including on a wizard's Next or Back.
  • A view is torn down once, and a close coordinates with a send. Overlapping exits and timeouts no longer tear a view down twice, a view closed while it is being sent no longer leaves a dead panel, and a send cancelled after Discord accepted its message finishes before it raises.
  • A view sent again closes the message it left by its exit_policy. The old message's buttons kept acting on the panel shown on the new message.
  • Reloads no longer race renders. A tab or wizard render, a page load, or a state change no longer interleaves with a reload, and two views that reload each other no longer hang.
  • Renders land in the order they were asked for. A state change during a send reaches the message, and a render abandoned on a slow Discord response is sent once the click is answered.
  • A discord.File arrives whole every time the library sends it. A file passed to a later call uploaded empty.
  • Persistence closes with the bot, writing what it batched instead of losing it at shutdown and letting a bot on SQLiteBackend exit; on Linux and macOS, the first SIGTERM does the same. A restart in the same process restores the panels the old bot left.
  • A persistent slot is written only when what it stores changes, so a ttl_days expiry counts from the last change, and an expired or pruned slot leaves memory as well as the database.
  • A middleware or reducer that awaits no longer loses another command's change, and a batch announces its actions in the order they were reduced.
  • Undo puts back only what the undone action changed, so one user's undo no longer erases other users' scoped data, and an undo of a persistent slot is saved.
  • A view pushed from a panel counts toward the panel's instance_limit whatever its own instance_scope, so running the command again no longer opens a second panel.
  • SQL backend transactions are kept apart: another task no longer joins an open SQLiteBackend transaction, a cancelled write rolls back, and a PostgresBackend transaction always returns its pooled connection.
  • The ephemeral Continue button is no longer overwritten by a render in progress, and a close or navigation that lands while a Continue runs waits for it instead of leaving the replacement without its attached views or two live panels.
  • setup_logging() deletes only the log files it wrote, and a misspelled log level raises.

Documentation

docs-current__view
docs-NavigationStack
docs-exit__children
docs-load
docs-build__reopen__view
docs-Shutdown
docs-RestartInProcess
docs-UndoRedo
docs-DISCORD__CALL__ERRORS

Install

pip install pycascadeui==3.14.0

See the full CHANGELOG for every entry.

Full Changelog: v3.13.0...v3.14.0