From 9018683c79c35072a52b1b1c433d2e8ad3d76038 Mon Sep 17 00:00:00 2001 From: "Bernd (Hermes)" Date: Thu, 13 Aug 2026 18:55:58 +0200 Subject: [PATCH] =?UTF-8?q?fix(P-066-followup):=20send=5Fclarify=20nutzt?= =?UTF-8?q?=20button=5Fbuilder-Pipeline=20=E2=80=94=20Emojis,=20Chunking,?= =?UTF-8?q?=20action=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ROOT CAUSE: send_clarify baute Buttons manuell mit _build_custom_buttons (plain '1','2','3' ohne Emojis, alle in EINEM Attachment ohne Chunking). FIX: - build_button_attachments() aus archivar/button_builder.py statt manueller Buttons - Emoji-Nummern (1️⃣2️⃣3️⃣) via EMOJI_NUMBERS - Chunking: max 3 Buttons pro Attachment - action_id in jedem Button (P-051-konform) - Other-Button als separates Attachment (altes Format CLARIFY::other) - Payload-Format CLARIFY:: (ohne ::) — der ::-Handler war ein No-Op, das alte Format funktioniert korrekt mit resolve_gateway_clarify() --- plugin/adapter.py | 52 ++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/plugin/adapter.py b/plugin/adapter.py index 123b9c3..2bab562 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -7250,27 +7250,41 @@ class RocketChatAdapter(BasePlatformAdapter): ) text += f"\n\n{option_lines}" - # Build buttons with short labels to avoid truncation - button_labels = [str(i + 1) for i in range(len(choices))] - buttons = _build_custom_buttons(button_labels, prefix=f"CLARIFY:{clarify_id}") - - # Add "Other" button with special handling + # P-066-Follow-up: Nutze button_builder-Pipeline statt manueller Buttons. + # build_button_attachments liefert Emoji-Nummern (1️⃣2️⃣3️⃣), + # Chunking (max 3 pro Attachment) und action_id pro Button. + # Wir nutzen das ALTE Payload-Format CLARIFY:: (ohne ::), + # weil der ::-Handler in _handle_message ein No-Op ist (P-066-Follow-up). + from archivar.button_builder import build_button_attachments, EMOJI_NUMBERS + + num_buttons = [] + for i, choice_text in enumerate(choices): + idx = i + 1 # 1-basierte Indizes (kompatibel mit CLARIFY-Handler) + num_buttons.append((choice_text, f"CLARIFY:{clarify_id}:{idx}")) + + attachments = build_button_attachments( + num_buttons, + special_buttons=[], # Other-Button manuell (altes Format) + color="#1d74f5", + title="Bitte wähle eine Option:", + number_buttons=True, + button_style="primary", + ) + + # Other-Button als separates Attachment (altes Format CLARIFY::other) other_payload = f"CLARIFY:{clarify_id}:other" - buttons.append({ - "type": "button", - "text": "✏️ Andere (Freitext)", - "msg": other_payload, - "msg_in_chat_window": True, - "style": "default", - "action_id": hashlib.sha1(f"{other_payload}:0".encode()).hexdigest()[:12], - }) - - # Create attachment with buttons - attachments = [{ + other_attachment = { "color": "#1d74f5", - "title": "Bitte wähle eine Option:", - "actions": buttons, - }] + "actions": [{ + "type": "button", + "text": "✏️ Andere (Freitext)", + "msg": other_payload, + "msg_in_chat_window": True, + "style": "default", + "action_id": hashlib.sha1(f"{other_payload}:0".encode()).hexdigest()[:12], + }], + } + attachments.append(other_attachment) # Send message with buttons success = await self._post_message_with_retry(real_room_id, text, attachments=attachments)