Repository navigation
v3.14.0
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.responseraisesInteractionResponded, as a click callback doing the same always has: the re-render now answers the submission (see Changed). Reply with the view'srespond()or withinteraction.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; setexit_policy = "delete"to keep deleting it. replace()closes the view it was called on as that view'sexit()would: the message is frozen or deleted by itsexit_policy, attached views close, a persistent registration is removed, and anexit()override runs. Drop any cleanup of the old message that follows areplace().- A view that pushed or popped away hands its message to the new view. Its
messagereadsNone,push(),pop(), andreplace()on it raise, andexit()on it does nothing. Navigate from the view the call returned, or reach the screen a panel shows now through the newcurrent_view; a subclass with its owncurrent_viewattribute needs another name for it. - Navigation raises
RuntimeErrorwhere it used to leave the panel inconsistent: from inside a push or pop the view takes part in (the new view'son_load(), arebuild=ornav_rebuildhook), from inside the view's ownsend(), on a view that has closed or is closing, and with an instance already sent, pushed, or closed. Arebuild=ornav_rebuildhook that callsreload()orload()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. Anon_state_changed()that awaits a separate task reloading its own view stalls, with a warning after 30 seconds; awaitself.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 theiron_load()builds,set_class_attribute()refuses attributes the library reads from the class, andPaginatedRegion.show_page()raises before the region has a host.
Added
current_viewfollows a panel through everypush(),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'son_load()under the same lock asreload(), without editing its message.- The ephemeral Continue button's hooks are public:
build_refresh_button()builds the button, andbuild_reopen_view(interaction)builds the view it sends. on_session_ended(interaction)andsession_ended_messageanswer a user who reaches a session that has ended, such as a modal submitted after its view closed.auto_exit_buttonon the paginated, tab, wizard, and form patterns, asMenuViewhas.notify=Falseonset_page(),switch_tab(), andPaginatedRegion.show_page()moves without firing the change hook, for a jump the view makes on its own.DISCORD_CALL_ERRORSgroups the exceptions a failed Discord call raises:discord.HTTPException,discord.RateLimited, andaiohttp.ClientError.- Smaller additions:
InstanceLimitError.scope,Collapsible(summary=)taking the text itself, andfetch_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 afterclose(). 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, andbutton_rowortab_navgiven acustom_id=, no longer number their buttons by position, so twochoice_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_filesapplies to a bot that runs for weeks. - A click the library answers without running its callback logs a
DEBUGline naming the view, the control, and why.
Deprecated
_build_refresh_button()is nowbuild_refresh_button(). An override of the old name keeps working and warns with aDeprecationWarningwhen 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.Filearrives 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
SQLiteBackendexit; 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_daysexpiry 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_limitwhatever its owninstance_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
SQLiteBackendtransaction, a cancelled write rolls back, and aPostgresBackendtransaction 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
Install
pip install pycascadeui==3.14.0
See the full CHANGELOG for every entry.
Full Changelog: v3.13.0...v3.14.0