fix(P1-4): Status-Farben und Flughafen-Prinzip in ::hilfe und ::status
This commit is contained in:
@@ -211,12 +211,19 @@ class InlineCommandRegistry:
|
||||
# ── Help-Text-Generator ─────────────────────────────────────────────────
|
||||
|
||||
|
||||
def build_help_text(registry: InlineCommandRegistry, room_map_summary: str = "") -> str:
|
||||
def build_help_text(
|
||||
registry: InlineCommandRegistry,
|
||||
room_map_summary: str = "",
|
||||
presence_enabled: Optional[bool] = None,
|
||||
current_status: str = "online",
|
||||
) -> str:
|
||||
"""Baut die Hilfeseite mit ::-Befehlen und natürlichen Sprach-Befehlen.
|
||||
|
||||
Args:
|
||||
registry: Die InlineCommandRegistry mit allen registrierten Befehlen.
|
||||
room_map_summary: Optionale Raum-Map-Übersicht für den Status-Teil.
|
||||
presence_enabled: Ob die PresenceEngine aktiv ist (None = nicht verfügbar).
|
||||
current_status: Aktueller Presence-Status ('online', 'away', 'busy').
|
||||
|
||||
Returns:
|
||||
Formatierte Hilfeseite als Markdown-String.
|
||||
@@ -290,6 +297,26 @@ def build_help_text(registry: InlineCommandRegistry, room_map_summary: str = "")
|
||||
lines.append("### 📋 Plugin-Status")
|
||||
lines.append("")
|
||||
|
||||
# P1-4: Status-Farben (Flughafen-Prinzip) — nur wenn PresenceEngine aktiv
|
||||
if presence_enabled:
|
||||
status_emoji = {
|
||||
"online": "🟢 online (idle, verfügbar)",
|
||||
"away": "🟡 away (Hintergrund-Task aktiv, Heartbeat pulsiert)",
|
||||
"busy": "🔴 busy (verarbeitet Nachricht)",
|
||||
}
|
||||
lines.append("### 🚦 Status-Farben")
|
||||
lines.append("")
|
||||
lines.append(
|
||||
"Der Bot zeigt seinen Status nach dem **Flughafen-Prinzip** an: "
|
||||
"wie eine Ampel signalisiert er, ob er bereit (grün), beschäftigt "
|
||||
"(rot) oder im Hintergrund aktiv (gelb) ist."
|
||||
)
|
||||
lines.append("")
|
||||
for status, label in status_emoji.items():
|
||||
marker = " ← aktuell" if status == current_status else ""
|
||||
lines.append(f"- {label}{marker}")
|
||||
lines.append("")
|
||||
|
||||
if room_map_summary:
|
||||
lines.append(room_map_summary)
|
||||
else:
|
||||
@@ -314,6 +341,9 @@ def build_status_text(
|
||||
butler_mode: str = "unknown",
|
||||
onboarding_active: bool = False,
|
||||
room_map_summary: str = "",
|
||||
presence_enabled: Optional[bool] = None,
|
||||
current_status: str = "online",
|
||||
pulse_active: bool = False,
|
||||
) -> str:
|
||||
"""Baut die Status-Seite mit aktuellen Plugin-Informationen.
|
||||
|
||||
@@ -323,6 +353,9 @@ def build_status_text(
|
||||
butler_mode: Butler-Modus ('cognitive', 'strict', 'off').
|
||||
onboarding_active: Ob Onboarding gerade läuft.
|
||||
room_map_summary: Raum-Map-Übersicht.
|
||||
presence_enabled: Ob die PresenceEngine aktiv ist (None = nicht anzeigen).
|
||||
current_status: Aktueller Presence-Status ('online', 'away', 'busy').
|
||||
pulse_active: Ob der PulseController gerade pulsiert.
|
||||
|
||||
Returns:
|
||||
Formatierte Status-Seite.
|
||||
@@ -342,6 +375,21 @@ def build_status_text(
|
||||
f"- **Onboarding:** {'🔄 Läuft' if onboarding_active else '✅ Abgeschlossen'}",
|
||||
]
|
||||
|
||||
# P1-4: PresenceEngine-Info (nur wenn presence_enabled explizit gesetzt)
|
||||
if presence_enabled is not None:
|
||||
status_labels = {
|
||||
"online": "🟢 online (idle, verfügbar)",
|
||||
"away": "🟡 away (Hintergrund-Task aktiv)",
|
||||
"busy": "🔴 busy (verarbeitet Nachricht)",
|
||||
}
|
||||
pulse_label = "💓 aktiv" if pulse_active else "⏸️ inaktiv"
|
||||
if presence_enabled:
|
||||
lines.append(f"- **PresenceEngine:** ✅ Aktiv")
|
||||
lines.append(f"- **Aktueller Status:** {status_labels.get(current_status, current_status)}")
|
||||
lines.append(f"- **Pulse:** {pulse_label}")
|
||||
else:
|
||||
lines.append(f"- **PresenceEngine:** ❌ Inaktiv")
|
||||
|
||||
if room_map_summary:
|
||||
lines.append("")
|
||||
lines.append(room_map_summary)
|
||||
|
||||
@@ -1092,3 +1092,142 @@ class TestCommandHandlersMocked:
|
||||
assert handler is not None
|
||||
result = await handler("room1", "")
|
||||
assert "hermes update" in result
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# P1-4: Status-Farben in ::hilfe und ::status
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
|
||||
class TestHelpTextPresenceColors:
|
||||
"""P1-4: build_help_text zeigt Status-Farben-Sektion wenn presence_enabled."""
|
||||
|
||||
def test_help_text_includes_status_colors_when_presence_enabled(self):
|
||||
"""presence_enabled=True → 'Status-Farben' Sektion erscheint."""
|
||||
from archivar.inline_commands import InlineCommandRegistry, build_help_text
|
||||
|
||||
registry = InlineCommandRegistry()
|
||||
text = build_help_text(registry, presence_enabled=True, current_status="online")
|
||||
|
||||
assert "Status-Farben" in text, (
|
||||
f"Status-Farben Sektion fehlt:\n{text}"
|
||||
)
|
||||
assert "online" in text
|
||||
assert "away" in text
|
||||
assert "busy" in text
|
||||
# Flughafen-Prinzip erklärt
|
||||
assert "flughafen" in text.lower() or "ampel" in text.lower(), (
|
||||
f"Flughafen-Prinzip nicht erklärt:\n{text}"
|
||||
)
|
||||
|
||||
def test_help_text_no_status_colors_when_presence_disabled(self):
|
||||
"""presence_enabled=False → keine Status-Farben Sektion."""
|
||||
from archivar.inline_commands import InlineCommandRegistry, build_help_text
|
||||
|
||||
registry = InlineCommandRegistry()
|
||||
text = build_help_text(registry, presence_enabled=False)
|
||||
|
||||
assert "Status-Farben" not in text, (
|
||||
f"Status-Farben Sektion sollte nicht erscheinen:\n{text}"
|
||||
)
|
||||
|
||||
def test_help_text_no_status_colors_when_presence_none(self):
|
||||
"""presence_enabled=None (default) → keine Status-Farben Sektion."""
|
||||
from archivar.inline_commands import InlineCommandRegistry, build_help_text
|
||||
|
||||
registry = InlineCommandRegistry()
|
||||
text = build_help_text(registry)
|
||||
|
||||
assert "Status-Farben" not in text
|
||||
|
||||
|
||||
class TestStatusTextPresenceInfo:
|
||||
"""P1-4: build_status_text zeigt PresenceEngine-Info wenn presence_enabled."""
|
||||
|
||||
def test_status_text_includes_presence_info_when_enabled(self):
|
||||
"""presence_enabled=True → PresenceEngine + Status + Pulse Zeilen."""
|
||||
from archivar.inline_commands import build_status_text
|
||||
|
||||
text = build_status_text(
|
||||
room_count=3,
|
||||
archivar_active=True,
|
||||
butler_mode="cognitive",
|
||||
presence_enabled=True,
|
||||
current_status="online",
|
||||
pulse_active=True,
|
||||
)
|
||||
|
||||
assert "PresenceEngine" in text, (
|
||||
f"PresenceEngine-Zeile fehlt:\n{text}"
|
||||
)
|
||||
assert "Aktiv" in text # ✅ Aktiv
|
||||
assert "online" in text, (
|
||||
f"Aktueller Status fehlt:\n{text}"
|
||||
)
|
||||
assert "aktiv" in text.lower(), (
|
||||
f"Pulse-Info fehlt:\n{text}"
|
||||
)
|
||||
|
||||
def test_status_text_includes_presence_info_when_disabled(self):
|
||||
"""presence_enabled=False → PresenceEngine ❌ Inaktiv."""
|
||||
from archivar.inline_commands import build_status_text
|
||||
|
||||
text = build_status_text(
|
||||
room_count=0,
|
||||
archivar_active=False,
|
||||
butler_mode="off",
|
||||
presence_enabled=False,
|
||||
current_status="online",
|
||||
pulse_active=False,
|
||||
)
|
||||
|
||||
assert "PresenceEngine" in text
|
||||
assert "Inaktiv" in text
|
||||
|
||||
def test_status_text_no_presence_info_when_default(self):
|
||||
"""presence_enabled=False (default) → keine PresenceEngine-Zeile."""
|
||||
from archivar.inline_commands import build_status_text
|
||||
|
||||
text = build_status_text(
|
||||
room_count=1,
|
||||
archivar_active=True,
|
||||
butler_mode="strict",
|
||||
)
|
||||
|
||||
assert "PresenceEngine" not in text, (
|
||||
f"PresenceEngine sollte nicht erscheinen (default):\n{text}"
|
||||
)
|
||||
|
||||
def test_status_text_shows_away_status(self):
|
||||
"""current_status='away' → 🟡 away im Status-Text."""
|
||||
from archivar.inline_commands import build_status_text
|
||||
|
||||
text = build_status_text(
|
||||
room_count=2,
|
||||
archivar_active=True,
|
||||
butler_mode="cognitive",
|
||||
presence_enabled=True,
|
||||
current_status="away",
|
||||
pulse_active=True,
|
||||
)
|
||||
|
||||
assert "away" in text, (
|
||||
f"away-Status fehlt:\n{text}"
|
||||
)
|
||||
|
||||
def test_status_text_shows_busy_status(self):
|
||||
"""current_status='busy' → 🔴 busy im Status-Text."""
|
||||
from archivar.inline_commands import build_status_text
|
||||
|
||||
text = build_status_text(
|
||||
room_count=2,
|
||||
archivar_active=True,
|
||||
butler_mode="cognitive",
|
||||
presence_enabled=True,
|
||||
current_status="busy",
|
||||
pulse_active=False,
|
||||
)
|
||||
|
||||
assert "busy" in text, (
|
||||
f"busy-Status fehlt:\n{text}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user