fix: Butler 2. Stufe Keywords als lesbarer Text + max 3 Buttons/Zeile

This commit is contained in:
Bernd (Hermes)
2026-07-23 20:31:15 +02:00
parent 6b16381818
commit 6825ba9149
2 changed files with 35 additions and 3 deletions
+24 -1
View File
@@ -2027,7 +2027,16 @@ class RocketChatAdapter(BasePlatformAdapter):
# V8.2.1 A2: Nachklärung bei stay_once — Strategie-Buttons senden # V8.2.1 A2: Nachklärung bei stay_once — Strategie-Buttons senden
if _MULTIROOM() and self.archivar is not None: if _MULTIROOM() and self.archivar is not None:
if self.archivar._should_trigger_nachklaerung("stay_once"): if self.archivar._should_trigger_nachklaerung("stay_once"):
nachklaerung_buttons = self.archivar._get_nachklaerung_buttons() # Keywords des Zielraums als lesbaren Text einbauen
target_room_id = move_req.get("target_room", "")
target_keywords = []
if target_room_id and self.archivar._room_map is not None:
target_entry = self.archivar._room_map.rooms.get(target_room_id)
if target_entry:
target_keywords = target_entry.keywords_100[:5]
nachklaerung_buttons = self.archivar._get_nachklaerung_buttons(
keywords=target_keywords if target_keywords else None
)
await self._send_archivar_buttons( await self._send_archivar_buttons(
room_id, room_id,
nachklaerung_buttons["text"], nachklaerung_buttons["text"],
@@ -4105,6 +4114,20 @@ class RocketChatAdapter(BasePlatformAdapter):
"actions": buttons, "actions": buttons,
}] }]
# Split buttons into groups of max 3 per attachment (UX: mobile readability)
MAX_BUTTONS_PER_ROW = 3
if len(buttons) > MAX_BUTTONS_PER_ROW:
attachments = []
for i in range(0, len(buttons), MAX_BUTTONS_PER_ROW):
chunk = buttons[i:i + MAX_BUTTONS_PER_ROW]
attachments.append({
"color": "#1d74f5",
"actions": chunk,
})
# First attachment gets the title
if attachments:
attachments[0]["title"] = text
success = await self._post_message_with_retry(room_id, text, attachments=attachments) success = await self._post_message_with_retry(room_id, text, attachments=attachments)
if success is not None: if success is not None:
# Mark room so the response stays here (no Archivar routing) # Mark room so the response stays here (no Archivar routing)
+11 -2
View File
@@ -1223,14 +1223,23 @@ class ArchivarMessageHandler:
strategie_topics = {"absprache", "planung", "strategie", "entscheidung"} strategie_topics = {"absprache", "planung", "strategie", "entscheidung"}
return topic.lower().strip() in strategie_topics return topic.lower().strip() in strategie_topics
def _get_nachklaerung_buttons(self) -> dict: def _get_nachklaerung_buttons(self, keywords: Optional[list] = None) -> dict:
"""Gibt die Nachklärungs-Buttons für A2 zurück. """Gibt die Nachklärungs-Buttons für A2 zurück.
Args:
keywords: Optionale Liste von Keywords des Zielraums,
die als lesbarer Text in die Nachricht eingebaut werden.
Returns: Returns:
Button-Template mit Strategie-Optionen. Button-Template mit Strategie-Optionen.
""" """
text = "Ist es eines dieser Themen?"
if keywords:
kw_list = ", ".join(keywords)
text = f"Ist es eines dieser Themen?\nKeywords: {kw_list}"
return { return {
"text": "Ist es eines dieser Themen?", "text": text,
"actions": [ "actions": [
{"text": "🤝 Absprache", "type": "absprache"}, {"text": "🤝 Absprache", "type": "absprache"},
{"text": "📋 Planung", "type": "planung"}, {"text": "📋 Planung", "type": "planung"},