feat(feishu): add native update prompt cards - #22448
Merged
Merged
Conversation
Contributor
🔎 Lint report:
|
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvage of #21911 by @heathley onto current
main.What this does
Adds
send_update_prompt()to the Feishu adapter so whenhermes update --gatewayneedsy/nconfirmation (stash restore, config migration), Feishu users get an interactive Yes / No card with proper authorization gating instead of the plain-text fallback.Today,
gateway/run.pydoesgetattr(type(adapter), "send_update_prompt", None) is not Noneand falls back to plain text when the method isn't defined. Discord, Telegram, and qqbot (#21353) already implement it — Feishu was the gap.Implementation
Mirrors the existing Feishu approval-card architecture (
send_exec_approval/_handle_approval_card_action/_resolve_approval/_build_resolved_approval_card):_update_prompt_statedict + counter for prompt-id trackingsend_update_prompt()builds an interactive Card V2 payload, sends via_feishu_send_with_retry, stores state on success_handle_update_prompt_card_action()handles button clicks: validates prompt_id, validates answer (y/n), authorizes operator against existing_adminsand_allowed_group_usersallowlists, schedules resolution, returns a resolved-state replacement card_resolve_update_prompt()pops state and atomically writes~/.hermes/.update_response(matches qqbot's_write_update_responsesemantics)(chat_id, prompt, default, session_key, metadata)matches Discord's exactlyBonus:
_submit_on_loopnow returnsboolso callers can detect scheduling failures (loop closed, RuntimeError) and avoid showing a card as resolved when the resolution coroutine couldn't actually be scheduled. The existing approval handler picks up the same fix.Tests
13 new test cases integrated into
tests/gateway/test_feishu_approval_buttons.py:Full Feishu test suite: 256 passed across
test_feishu_approval_buttons.py,test_feishu.py,test_feishu_onboard.py.Why salvage
PR #21911 was 486 commits behind
main, but only 3 unrelated commits had touchedfeishu.pysince (monotonic deadlines, topic-thread cleanup, topic-reply threading) — none overlapped with the PR's hunks. Cherry-pick auto-merged cleanly with+433/-3matching the PR's stats exactly. @heathley's authorship preserved.Closes #21911.
Use
--rebasemerge to preserve @heathley's authorship.