2 Commits

Author SHA1 Message Date
Bernd (Hermes) 3f1d688983 Bug 6: Konsistenz _finish_onboarding / _get_onboarding_room_list
- Gleiche Sortierreihenfolge in beiden Funktionen: (not is_catch, name)
- _get_onboarding_room_list liefert jetzt 3-Tupel (rid, name, is_current)
  statt 2-Tupel — '(aktuell)'-Marker kann nun auch in der Auswahlliste
  angezeigt werden (is_current=True für den Operator-DM)
- Tote insert(0,...)-Aufrufe in beiden Funktionen durch append + Kommentar
  'wird nachfolgend einsortiert' ersetzt
- Caller (catch_all_change-Phase) auf 3-Tupel-Unpacking angepasst
2026-07-12 15:04:31 +02:00
Bernd (Hermes) 13575aaf40 Bug 6: Onboarding Catch-All-Auswahl zeigt jetzt DM als Option an
_finish_onboarding: DM-Raum aus _room_info wird immer in die
Catch-All-Auswahlliste aufgenommen (auch wenn nicht in room_map).
DM bekommt '(aktuell)'-Marker statt '(Catch-All)'.

_get_onboarding_room_list: Gleiche Logik — DM immer inkludiert,
mit echtem Namen statt 'Catch-All (legacy)'.

catch_all_change-Phase: DM-Auswahl ist no-op (bleibt Catch-All),
andere Raum-Auswahl setzt _set_catch_all() wie bisher.
2026-07-12 14:58:57 +02:00
+55 -10
View File
@@ -1432,10 +1432,18 @@ class RocketChatAdapter(BasePlatformAdapter):
index = int(single_line) - 1
all_rooms = self._get_onboarding_room_list()
if 0 <= index < len(all_rooms):
rid, name = all_rooms[index]
self._set_catch_all(rid)
await self._post_message_with_retry(operator_room_id, f"🎯 {name} ist jetzt der Catch-All-Raum.")
logger.info("[rocketchat] Catch-All geändert zu: %s", name)
rid, name, _ = all_rooms[index]
dm_room_id = state.get("operator_room_id", "")
# Bug 6: DM auswählen → kein Wechsel nötig (ist bereits Catch-All)
if rid == dm_room_id:
await self._post_message_with_retry(operator_room_id,
f"👍 {name} ist bereits der Catch-All-Raum — bleibt unverändert.")
logger.info("[rocketchat] Catch-All bleibt DM (kein Wechsel nötig)")
else:
self._set_catch_all(rid)
await self._post_message_with_retry(operator_room_id,
f"🎯 {name} ist jetzt der Catch-All-Raum.")
logger.info("[rocketchat] Catch-All geändert zu: %s", name)
else:
await self._post_message_with_retry(operator_room_id, f"❌ Ungültige Nummer. Bitte 1–{len(all_rooms)} wählen.")
return # onboarding_active bleibt True, warte auf korrekte Antwort
@@ -1726,19 +1734,38 @@ class RocketChatAdapter(BasePlatformAdapter):
else:
logger.warning("[rocketchat] B9: FAISS-Index-Rebuild fehlgeschlagen: %s", e)
# Baue nummerierte Raumliste
# Baue nummerierte Raumliste (inkl. Operator-DM als Catch-All-Option)
all_rooms = []
dm_room_id = operator_room_id
dm_room_name = self._room_info.get(dm_room_id, {}).get("name", "DM")
dm_already_in_map = dm_room_id in self.archivar._room_map.rooms
for rid, entry in self.archivar._room_map.rooms.items():
if rid in self.archivar._room_map._excluded_room_ids:
continue
all_rooms.append((rid, entry.name, entry.catch_all))
# Bug 6: DM-Raum mit echtem Namen anzeigen, nicht "Catch-All (legacy)"
if rid == dm_room_id:
all_rooms.append((rid, dm_room_name, True))
else:
all_rooms.append((rid, entry.name, entry.catch_all))
# DM-Raum immer als Option anbieten, auch wenn nicht in room_map
# (wird nachfolgend einsortiert)
if not dm_already_in_map:
all_rooms.append((dm_room_id, dm_room_name, True))
all_rooms.sort(key=lambda x: (not x[2], x[1]))
lines = ["✅ Alle Räume zur Map hinzugefügt.",
"",
"**Aktuelle Raum-Übersicht:**"]
for i, (rid, name, is_catch) in enumerate(all_rooms, 1):
marker = " 🎯 (Catch-All)" if is_catch else ""
if rid == dm_room_id:
marker = " 🎯 (aktuell)"
elif is_catch:
marker = " 🎯 (Catch-All)"
else:
marker = ""
lines.append(f"{i}. {name}{marker}")
lines.append("")
lines.append("Möchtest du den Catch-All-Raum ändern? Antworte mit der Raumnummer, oder **überspringen** zum Behalten.")
@@ -1778,13 +1805,31 @@ class RocketChatAdapter(BasePlatformAdapter):
return keywords[:10]
def _get_onboarding_room_list(self) -> list:
"""Erstellt eine nummerierte Liste aller Räume (ohne excluded)."""
"""Erstellt eine nummerierte Liste aller Räume (ohne excluded), inkl. DM.
Returns list of (rid, name, is_current) tuples — gleiche Sortierung wie
_finish_onboarding, damit Nummerierung in beiden Listen identisch ist.
"""
rooms = []
dm_room_id = self._onboarding_state.get("operator_room_id", "")
dm_room_name = self._room_info.get(dm_room_id, {}).get("name", "DM")
dm_already_in_map = dm_room_id in self.archivar._room_map.rooms
for rid, entry in self.archivar._room_map.rooms.items():
if rid in self.archivar._room_map._excluded_room_ids:
continue
rooms.append((rid, entry.name))
rooms.sort(key=lambda x: x[1]) # alphabetisch
if rid == dm_room_id:
rooms.append((rid, dm_room_name, True))
else:
rooms.append((rid, entry.name, entry.catch_all))
# DM-Raum immer als Option anbieten, auch wenn nicht in room_map
# (wird nachfolgend einsortiert)
if not dm_already_in_map:
rooms.append((dm_room_id, dm_room_name, True))
# Gleiche Sortierung wie _finish_onboarding: Catch-All zuerst, dann alphabetisch
rooms.sort(key=lambda x: (not x[2], x[1]))
return rooms
def _set_catch_all(self, room_id: str) -> None: