feat(slack): Block Kit buttons for clarify prompts — with tests, chunking, and resolve-state editing - #61943
Conversation
|
Thanks for filling a verified Slack parity gap. Current remote GitHub comparison shows that the 87 commits after the PR base did not modify Automated hermes-sweeper review. |
Rebased onto origin/main (was based on 46cf87b; main advanced 440 commits). Reset-hard + cherry-pick to drop the stale merge commit (1a35c6940) that would have caused a replay explosion. Conflict resolved in plugins/platforms/slack/adapter.py action-handler registration block: main added the 'hermes_feedback' action registration at the same site where this commit registers the clarify action handlers ('hermes_clarify_choice' / 'hermes_clarify_other'). Kept BOTH. send_clarify override signature matches the now-canonical base.py send_clarify (chat_id, question, choices, clarify_id, session_key, metadata) that standardized across Telegram/Discord/WhatsApp on main; open-ended prompts delegate to super().send_clarify().
1a35c69 to
a69f5c9
Compare
|
Rebased onto current Worth noting what the rebase surfaced: since this PR was opened, the clarify-buttons pattern standardized on main across Telegram/Discord/WhatsApp — and our Slack override's Suites re-verified post-rebase via On consolidation: #51547 and #28885 target the same gap and remain unrebased against the migrated layout — our offer stands to fold whichever pieces reviewers prefer, but this branch is current, tested, and matches the canonical adapter contract today. A maintainer review would unblock it. |
|
@copilot review Updated head: |
Slack now overrides send_clarify to render multi-choice clarify prompts as native Block Kit buttons (one per choice + a final '✏️ Other…' free-text button), mirroring the Telegram/Discord adapters and the existing Slack approval-button pattern. - Unique hermes_clarify_choice_<idx> action_ids (Slack rejects duplicate action_ids within one actions block); dispatch via a compiled-regex action matcher plus hermes_clarify_other. - Chunks elements across actions blocks in groups of 5 so a larger choice list degrades gracefully instead of 400ing (invalid_blocks). - Choice taps resolve through tools.clarify_gateway .resolve_gateway_clarify with the canonical registered choice text — the same applier the typed-reply path uses — then edit the message to show the outcome and drop the buttons. - 'Other' flips the entry into text-capture via mark_awaiting_text (only on tap, never at send time) so the gateway text-intercept captures the next typed message. - Auth-gated via _is_interactive_user_authorized; atomic-pop double-click guard mirrors _approval_resolved; late taps on evicted entries surface an honest expiry notice instead of a false ✓. - Open-ended prompts delegate to the base plain-text render. Salvaged from PR #61943 by @100yenadmin. Earliest implementation of this feature was PR #28885 by @cypres0099; sibling implementations #66606 (@jaaro-ai) and #51547 (@Mongol-Jimmi) are superseded. Closes #52369
Slack now overrides send_clarify to render multi-choice clarify prompts as native Block Kit buttons (one per choice + a final '✏️ Other…' free-text button), mirroring the Telegram/Discord adapters and the existing Slack approval-button pattern. - Unique hermes_clarify_choice_<idx> action_ids (Slack rejects duplicate action_ids within one actions block); dispatch via a compiled-regex action matcher plus hermes_clarify_other. - Chunks elements across actions blocks in groups of 5 so a larger choice list degrades gracefully instead of 400ing (invalid_blocks). - Choice taps resolve through tools.clarify_gateway .resolve_gateway_clarify with the canonical registered choice text — the same applier the typed-reply path uses — then edit the message to show the outcome and drop the buttons. - 'Other' flips the entry into text-capture via mark_awaiting_text (only on tap, never at send time) so the gateway text-intercept captures the next typed message. - Auth-gated via _is_interactive_user_authorized; atomic-pop double-click guard mirrors _approval_resolved; late taps on evicted entries surface an honest expiry notice instead of a false ✓. - Open-ended prompts delegate to the base plain-text render. Salvaged from PR #61943 by @100yenadmin. Earliest implementation of this feature was PR #28885 by @cypres0099; sibling implementations #66606 (@jaaro-ai) and #51547 (@Mongol-Jimmi) are superseded. Closes #52369
|
Merged via #69318 — your commit was cherry-picked onto current main with your authorship preserved in git history: your implementation (buttons, >5 chunking, resolve-state editing, tests) was the chosen base and was cherry-picked with authorship. Thanks for the contribution! |
Slack now overrides send_clarify to render multi-choice clarify prompts as native Block Kit buttons (one per choice + a final '✏️ Other…' free-text button), mirroring the Telegram/Discord adapters and the existing Slack approval-button pattern. - Unique hermes_clarify_choice_<idx> action_ids (Slack rejects duplicate action_ids within one actions block); dispatch via a compiled-regex action matcher plus hermes_clarify_other. - Chunks elements across actions blocks in groups of 5 so a larger choice list degrades gracefully instead of 400ing (invalid_blocks). - Choice taps resolve through tools.clarify_gateway .resolve_gateway_clarify with the canonical registered choice text — the same applier the typed-reply path uses — then edit the message to show the outcome and drop the buttons. - 'Other' flips the entry into text-capture via mark_awaiting_text (only on tap, never at send time) so the gateway text-intercept captures the next typed message. - Auth-gated via _is_interactive_user_authorized; atomic-pop double-click guard mirrors _approval_resolved; late taps on evicted entries surface an honest expiry notice instead of a false ✓. - Open-ended prompts delegate to the base plain-text render. Salvaged from PR NousResearch#61943 by @100yenadmin. Earliest implementation of this feature was PR NousResearch#28885 by @cypres0099; sibling implementations NousResearch#66606 (@jaaro-ai) and NousResearch#51547 (@Mongol-Jimmi) are superseded. Closes NousResearch#52369
What this does
Slack is the last button-capable platform where the
clarifytool still degrades to a numbered text list — Telegram, Discord, and WhatsApp Cloud all render interactive choices. This adds thesend_clarifyoverride and Bolt action handlers so Slack users tap a button instead of typing "2".How it works
send_clarifyrenders a Block Kitsection(question, mrkdwn-escaped) plusactionsrows: one button per choice and a final "✏️ Other…" button. Rows chunk at Slack's five-element cap, so buttons keep working ifMAX_CHOICESis raised later (feat(clarify): raise MAX_CHOICES from 4 to 10 #28900).hermes_clarify_choice_<idx>action ID, satisfying Slack's per-block uniqueness requirement. One anchored Bolt regex listener routes those indexed IDs; the existing compactclarify_id|idxvalue and server-side choice lookup remain unchanged.resolve_gateway_clarifywith the exact server-side choice string, then edits the message to show the selection. Amsg_ts-keyed guard makes double-clicks inert, following the existing approval-button pattern.mark_awaiting_text; the gateway's platform-agnostic text intercept resolves the next typed message. No new Slack-specific text machinery is introduced.Event flow
Relationship to the other open PRs
#51547 and #28885 address the same Slack parity gap. This PR keeps the send and action paths together and adds:
thread_ts, resolve behavior, double-click protection, authorization, expiry, Other-to-text capture, chunking, and base fallback;hermes_clarify_choice_0and rejects the old unindexed form;This therefore supersedes the earlier alternatives while preserving their intended user experience. The implementation can still be consolidated with either author if maintainers prefer a different landing path.
Review fix
The review finding in discussion_r3593877536 was valid: the original patch reused
hermes_clarify_choicewithin one actions block. Commit5fb2a2703assigns indexed IDs, registers an anchored regex listener, preserves value routing, and adds render plus registration regressions. The thread has been answered and resolved.Validation
Validated on head
5fb2a2703after syncing withmainat659d1123c:scripts/run_tests.sh tests/gateway/test_slack.py tests/gateway/test_slack_clarify_buttons.py— 257 passed;git diff --check— clean.