Files
hermes-agent/plugins/platforms/discord
kshitijk4poor 606b83456b fix(discord): release the /model picker once it is answered
A switch or cancel in the Discord /model picker set `resolved` but never
called `stop()`. discord.py kept the view registered and its 120 s timeout
running, and when that timeout fired it replaced the "Model Switched" or
"cancelled" card with "Selection expired — no model change" (#143851).
Since #145948 the other prompt views stop when answered, and
ChoicePickerView already did.

`_switch_selected_model` and `_on_cancel` now call `self.stop()` as soon
as they set `resolved`, before any await. A slow switch therefore can't
run into the timeout, and the view leaves discord.py's store at once.
The `on_timeout` guards from the previous commit still handle a timeout
discord.py had already queued when the click landed (stop() can't cancel
that task); both now carry a comment saying so.

Test: the two picker answers join `test_answered_view_is_released`, which
asserts the view is finished.

Fix proposed in #143851 by @jimstratus; the same guard was first
submitted in #69685 by @tuancookiez-hub.

Co-authored-by: Jim Stratus <116782964+jimstratus@users.noreply.github.com>
2026-10-30 11:24:44 +05:30
..