The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(discord): release the /model picker once it is answered
kshitijk4poor606b83456bfa
diff --git a/plugins/platforms/discord/adapter.py b/plugins/platforms/discord/adapter.pyindex 1f63644e729..e4a155574f8 100644--- a/plugins/platforms/discord/adapter.py+++ b/plugins/platforms/discord/adapter.py@@ -6442,7 +6442,7 @@ def _define_discord_view_classes() -> None:item.label = _t_discord(key, _DISCORD_BUTTON_LABEL_LIMIT)async def on_timeout(self):- # A click already resolved the prompt: keep its "Approved/Denied by" footer.+ # stop() can't cancel an on_timeout discord.py queued in the tick a click landed: keep the answer.if self.resolved:returnself.resolved = True@@ -6661,6 +6661,7 @@ def _define_discord_view_classes() -> None:if not await self._gate(interaction, resolved_msg=t("platform.discord.picker.already_resolved"), unauth_msg=_unauthorized()):returnself.resolved = True+ self.stop() # answered: release the view and its timeout now, before any awaitself.clear_items()await self._edit(interaction, t("platform.discord.picker.switching", model=model_id),@@ -6712,10 +6713,12 @@ def _define_discord_view_classes() -> None:if not await self._gate(interaction, resolved_msg=None, unauth_msg=_unauthorized()):returnself.resolved = True+ self.stop() # answered: release the view and its timeout now, before any awaitself.clear_items()await self._edit(interaction, t("platform.discord.picker.cancelled"), color=discord.Color.greyple())async def on_timeout(self):+ # stop() can't cancel an on_timeout discord.py queued in the tick a click landed: keep the answer.if self.resolved:returnself.resolved = Truediff --git a/tests/gateway/test_discord_view_base_parity.py b/tests/gateway/test_discord_view_base_parity.pyindex cc3f441e44d..fe707eb1231 100644--- a/tests/gateway/test_discord_view_base_parity.py+++ b/tests/gateway/test_discord_view_base_parity.py@@ -23,6 +23,7 @@ def _interaction(user_id=1):return SimpleNamespace(user=SimpleNamespace(id=user_id, display_name="alice", roles=[]),response=SimpleNamespace(send_message=AsyncMock(), edit_message=AsyncMock(), defer=AsyncMock()),+ edit_original_response=AsyncMock(),message=SimpleNamespace(embeds=[]),data={"values": ["x"]},channel_id=5,@@ -85,6 +86,8 @@ async def test_unauthorized_click_uses_the_shared_notice(monkeypatch, name, call("update", lambda v, i: v._respond(i, "y", None, "x")),("clarify", lambda v, i: v._resolve_choice(i, 0, "a")),("clarify", lambda v, i: v._on_other(i)),+ ("model", lambda v, i: v._switch_selected_model(i, "m2")),+ ("model", lambda v, i: v._on_cancel(i)),],)async def test_answered_view_is_released(monkeypatch, tmp_path, name, call):