Commit Graph
110 Commits
Author SHA1 Message Date
harumaki4649 cc00d56a22 Fixed item state management in the UI View
* Fix ActionRow add_item type validation
* Fix View item state tracking
* Fix View add and remove item state
* Add UI view item state tests
2026-07-08 16:14:41 -04:00
Rapptz b01de35fa2 Remove old workaround to /callback not having a return type
The old code needed a workaround using interaction_id to differentiate
between multiple instances being reused since they would all go into
the `None` key. Since /callback now returns a proper message_id this
could be used as a key instead of None. From testing, it seems this is
true for both edit_message and send_message responses.
2026-03-02 12:29:02 -05:00
Rapptz 616137875b Fix memory leak with the view store when removing items
The previous code would maintain items in the dispatch mapping if
nested children were removed between calls because it would only
remove items that are live in the view at the point of removal. This
meant that calling something like ActionRow.clear_items() would keep
all the removed items within the mapping and would not be evicted.

This attempts to fix it by maintaining a cache state snapshot and
making a diff between the two versions to know which keys are now safe
to delete since they are no longer in the live view at all.
2026-03-02 11:33:51 -05:00
Rapptz ef1cb6a089 Prevent empty dictionaries from being added to the ViewStore
Fix #10405
2026-02-23 02:31:55 -05:00
Michael 38d5d8e47a Use walk_children within remove_view 2026-02-22 16:47:15 -05:00
Steve C dae46f7d0f Add generics to Interaction params 2026-02-22 15:59:46 -05:00
Rapptz 3ab09be13c Invert View.is_finished condition when there is no associated Future 2026-01-28 16:58:55 -05:00
Michael bcea13e993 Allow ui.View initialization without a running event loop 2026-01-13 18:08:53 -05:00
Rapptz 0052878983 Guard against Item.view being None when dispatching 2025-12-21 12:18:05 -05:00
Soheab 9580898c97 Detach view from item when removed 2025-11-12 20:02:19 -05:00
DA344 e2cf721e9c Fix container items having out of date internal state 2025-11-07 18:53:04 -05:00
Soheab_ 944ffe93c7 Handle resolved data for modal components and types 2025-09-28 16:06:17 -04:00
Rapptz 89d5cbd78a Move v2 item check from BaseView to View 2025-08-31 14:18:50 -04:00
lmaotrigine 50b0d219b5 Add missing versionadded to some BaseView items 2025-08-24 13:22:35 -04:00
Rapptz 9bda89b0d6 Update total count tracking to always consider the wrapper object 2025-08-21 22:20:12 -04:00
DA344 0309aac335 Add a swap method for dynamic item's dispatching 2025-08-20 18:52:31 -04:00
Rapptz 44a44e938f Reformat entire project with ruff instead of black 2025-08-18 20:16:10 -04:00
Rapptz 3ef6272e07 Fix error with View.from_message when having multiple items 2025-08-18 19:04:19 -04:00
Rapptz d58c055c5b Remove unused import 2025-08-18 15:07:44 -04:00
Rapptz 5d49f11709 Remove View.from_dict typing 2025-08-18 15:00:51 -04:00
Rapptz fc12a41cdf Run black 2025-08-18 14:49:32 -04:00
Rapptz 064cb7af71 Add View.total_children_count 2025-08-18 14:42:55 -04:00
Rapptz f08c042217 Add content_length method to LayoutView and container items 2025-08-18 14:33:15 -04:00
Rapptz 9ef5b054e5 Refactor total children count to an overrideable method 2025-08-18 04:49:20 -04:00
Rapptz 2a69ac4ca8 Document difference between View and LayoutView 2025-08-18 04:34:24 -04:00
Rapptz 38c6407ffd Maintain a reference to View dispatched tasks 2025-08-14 00:47:55 -04:00
Rapptz 3fb627d078 Add support for label components and select in modals 2025-08-14 00:47:55 -04:00
Rapptz 9fb74fd7a1 Remove unnecessary TypeGuard 2025-08-13 21:27:38 -04:00
50caa3c82c Add support for components V2
Co-authored-by: Michael H <michael@michaelhall.tech>
Co-authored-by: Soheab <33902984+Soheab@users.noreply.github.com>
Co-authored-by: owocado <24418520+owocado@users.noreply.github.com>
Co-authored-by: Jay3332 <40323796+jay3332@users.noreply.github.com>
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
2025-08-13 20:37:23 -04:00
Leonardo 7f16a06479 Copy Select options when creating View class 2025-06-20 14:24:06 -04:00
Rapptz 8953938a53 Update Pyright to v1.1.394 2025-02-18 03:29:09 -05:00
DA344 6ab747f9e5 Add support for sending views in stateless webhooks 2025-02-17 18:37:20 -05:00
Soheab 2248fc1946 Fix various code around Message.interaction(_metadata) 2024-05-06 18:17:37 -04:00
ナニカ dc6d33c303 copy over original row position for dynamic items 2024-04-18 03:33:43 -04:00
Rapptz 76666fbcf4 Properly check for maximum number of children 2024-02-17 01:17:31 -05:00
Rapptz 078b500657 Fix dynamic item views having a timeout causing it to evict 2023-12-30 05:00:12 -05:00
Soheab_andDanny 698363e76b Refactor from_components for Select classes
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
2023-09-30 21:21:29 -04:00
z03h e67d00502d Fix View.from_message not creating other Selects 2023-09-12 13:03:29 -04:00
Rapptz 94655cd804 Skip adding views to the synced message store if fully dynamic 2023-09-03 02:52:05 -04:00
Rapptz f793af0456 Add item parameter to DynamicItem.from_custom_id 2023-09-03 02:52:05 -04:00
Rapptz 7c3868ef3b Add Client.remove_dynamic_items 2023-09-03 02:52:05 -04:00
Rapptz a852f90358 Add support for dynamic items that parse custom_id for state 2023-09-03 02:52:05 -04:00
Takagi TasukuandDanny f7e9795495 Call super for __init_subclass__ in View
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
2023-02-12 02:08:39 -05:00
Rapptz 6cb9a84898 Fix views not being removed from message store backing
This uses the original interaction ID if available for cache eviction
2023-01-25 02:37:30 -05:00
5009c83bc9 Implement New Select Types
Co-authored-by: Soheab_ <33902984+Soheab@users.noreply.github.com>
Co-authored-by: rdrescher909 <51489753+rdrescher909@users.noreply.github.com>
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
2022-10-27 10:03:45 -04:00
ster 95b6bd8782 Add coro tag to docstrings that were missing it 2022-10-02 17:52:18 -04:00
Ionite 6981eb69c4 Normalize type formatting in TypeError
Normalize most mixed usages of `__class__`, `__class__!r`, 
`__class__.__name__!r` to the standard form of 
`__class__.__name__`
2022-09-12 15:25:55 -04:00
Bryan Forbes b12b4b18fd Mark public callbacks as positional-only 2022-08-22 15:21:19 -04:00
Rapptz 6327402730 Update View timeout only if interaction_check passes 2022-08-18 18:55:50 -04:00
Mikey 9c38cf3aef Fix ui.Select.values in modals 2022-08-14 15:25:43 -04:00