fix(hilfe): vollständigen Hilfetext über zwei Teile ausgeben statt kürzen
Andreas' Entscheidung: lieber den vollständigen Hilfetext über zwei
Textblöcke ausgeben, als eine unvollständige Seite. Der progressive
Kürzungs-Fix (f74d206) schnitt Subcommand-Details weg (::keywords
review/status, ::butler mode-Optionen) — nicht akzeptabel.
- build_help_text() gibt wieder den vollständigen, ungekürzten Text zurück
- progressiven Kürzungs-Fix (Stufe 1-3) entfernt
- room_map_summary-Kürzungs-Fix (P1) beibehalten (optionale Sektion)
- NEU: build_help_text_parts() teilt bei > 4500 Zeichen in zwei Teile:
Teil 1 = Core + Standard + RC-Befehle, Teil 2 = Natürliche Sprache +
Status + Tipp
- adapter.py: _post_help_text() postet beide Teile nacheinander; alle
Aufrufer (::hilfe, ::commands, natürliche Hilfe, unbekannter Befehl,
Command-Question, Onboarding-Review) umgestellt
- Tests: test_build_help_text_full (alle Subcommands), test_build_help_text_split
(zwei Teile < 4500), test_build_help_text_split_single_part_when_short
This commit is contained in:
@@ -318,19 +318,9 @@ class TestBuildHelpText:
|
||||
assert "Raum-Map: 1 Raum" in text
|
||||
assert len(text) <= 4000
|
||||
|
||||
def test_build_help_text_length_with_all_commands(self):
|
||||
"""P1b-Fix: Hilfe-Text bleibt auch OHNE room_map_summary unter 4500 Zeichen.
|
||||
|
||||
Die Hilfe-Seite ist durch Subcommand-Ergänzungen (mode proactive,
|
||||
mode silent_collector, Routing-Modi-Hinweis) über das Payload-Limit
|
||||
gewachsen. Der P1-Fix griff nur bei gesetzter room_map_summary.
|
||||
Dieser Test registriert ALLE realen Befehle (inkl. Subcommands) und
|
||||
prüft, dass der Text auch ohne room_map_summary < 4500 Zeichen bleibt.
|
||||
"""
|
||||
from archivar.inline_commands import (
|
||||
InlineCommandRegistry,
|
||||
build_help_text,
|
||||
)
|
||||
def _build_full_registry(self):
|
||||
"""Baut eine Registry mit ALLEN realen Befehlen (inkl. Subcommands)."""
|
||||
from archivar.inline_commands import InlineCommandRegistry
|
||||
|
||||
registry = InlineCommandRegistry()
|
||||
async def dummy(room_id, args):
|
||||
@@ -475,33 +465,103 @@ class TestBuildHelpText:
|
||||
"Kontext manuell komprimieren (::Variante von /compress)",
|
||||
category="Standard",
|
||||
)
|
||||
return registry
|
||||
|
||||
# OHNE room_map_summary — der P1-Fix greift hier NICHT.
|
||||
def test_build_help_text_full(self):
|
||||
"""Vollständiger Text: ALLE Subcommands müssen vorhanden sein.
|
||||
|
||||
Andreas' Entscheidung: lieber den vollständigen Hilfetext über zwei
|
||||
Textblöcke ausgeben, als eine unvollständige Seite. Der progressive
|
||||
Kürzungs-Fix (f74d206) schnitt Subcommand-Details weg — das ist
|
||||
nicht akzeptabel. Dieser Test prüft, dass KEIN Subcommand fehlt.
|
||||
"""
|
||||
from archivar.inline_commands import build_help_text
|
||||
|
||||
registry = self._build_full_registry()
|
||||
text = build_help_text(registry, room_map_summary="")
|
||||
assert len(text) < 4500, (
|
||||
f"Hilfe-Text ist {len(text)} Zeichen lang, "
|
||||
f"maximal erlaubt sind < 4500 (Payload-Limit ~5000)"
|
||||
)
|
||||
|
||||
# MIT room_map_summary — beide Fixes müssen greifen.
|
||||
big_summary = "Rocket.Chat Raum-Map:\n"
|
||||
for i in range(5):
|
||||
big_summary += (
|
||||
f" {i+1}. #Raum{i+1} (room_id_{i+1}...) — "
|
||||
f"Thema: Dies ist ein sehr langer Beschreibungstext für Raum {i+1} "
|
||||
f"um die Länge der Hilfeseite künstlich zu erhöhen\n"
|
||||
# keywords Subcommands
|
||||
assert "::keywords review" in text
|
||||
assert "::keywords status" in text
|
||||
# butler Subcommands
|
||||
assert "::butler mode" in text
|
||||
assert "::butler mode proactive" in text
|
||||
assert "::butler mode silent_collector" in text
|
||||
# onboarding Subcommands
|
||||
assert "::onboarding start" in text
|
||||
assert "::onboarding status" in text
|
||||
assert "::onboarding resume" in text
|
||||
assert "::onboarding pause" in text
|
||||
assert "::onboarding abort" in text
|
||||
assert "::onboarding reset" in text
|
||||
# approve Subcommands
|
||||
assert "::approve session" in text
|
||||
assert "::approve always" in text
|
||||
# setstatus Subcommands
|
||||
assert "::setstatus on" in text
|
||||
assert "::setstatus off" in text
|
||||
assert "::setstatus status" in text
|
||||
# reasoning Subcommands
|
||||
assert "::reasoning none" in text
|
||||
assert "::reasoning low" in text
|
||||
assert "::reasoning medium" in text
|
||||
assert "::reasoning high" in text
|
||||
assert "::reasoning xhigh" in text
|
||||
assert "::reasoning show" in text
|
||||
assert "::reasoning hide" in text
|
||||
assert "::reasoning reset" in text
|
||||
assert "::reasoning --global" in text
|
||||
|
||||
def test_build_help_text_split(self):
|
||||
"""Bei > 4500 Zeichen werden zwei Teile geliefert, beide < 4500."""
|
||||
from archivar.inline_commands import build_help_text_parts
|
||||
|
||||
registry = self._build_full_registry()
|
||||
parts = build_help_text_parts(registry, room_map_summary="")
|
||||
|
||||
# Der vollständige Text ist > 4500 Zeichen → zwei Teile
|
||||
assert len(parts) == 2, f"Erwartet 2 Teile, bekam {len(parts)}"
|
||||
for i, part in enumerate(parts, start=1):
|
||||
assert len(part) < 4500, (
|
||||
f"Teil {i} ist {len(part)} Zeichen lang, "
|
||||
f"maximal erlaubt sind < 4500"
|
||||
)
|
||||
text_with_map = build_help_text(registry, room_map_summary=big_summary)
|
||||
assert len(text_with_map) < 4500, (
|
||||
f"Hilfe-Text mit room_map_summary ist {len(text_with_map)} Zeichen lang, "
|
||||
f"maximal erlaubt sind < 4500"
|
||||
|
||||
# Teil 1 enthält die Befehlslisten (Core + Standard + RC)
|
||||
assert "Core-Befehle" in parts[0]
|
||||
assert "Standard-Hermes-Befehle" in parts[0]
|
||||
assert "RC-Plugin-spezifische Befehle" in parts[0]
|
||||
# Teil 2 enthält natürliche Sprache + Status + Tipp
|
||||
assert "Natürliche Sprach-Befehle" in parts[1]
|
||||
assert "Plugin-Status" in parts[1]
|
||||
assert "Tipp" in parts[1]
|
||||
|
||||
# KEIN Subcommand darf fehlen — über beide Teile hinweg
|
||||
combined = "\n".join(parts)
|
||||
for sub in (
|
||||
"::keywords review", "::keywords status",
|
||||
"::butler mode", "::butler mode proactive",
|
||||
"::butler mode silent_collector",
|
||||
):
|
||||
assert sub in combined, f"Subcommand {sub} fehlt in beiden Teilen"
|
||||
|
||||
def test_build_help_text_split_single_part_when_short(self):
|
||||
"""Kurzer Text (wenige Befehle) → nur EIN Teil."""
|
||||
from archivar.inline_commands import (
|
||||
InlineCommandRegistry,
|
||||
build_help_text_parts,
|
||||
)
|
||||
|
||||
# Core-Befehle, RC-Plugin-Befehle und Plugin-Status müssen erhalten bleiben.
|
||||
assert "Core-Befehle" in text
|
||||
assert "RC-Plugin-spezifische Befehle" in text
|
||||
assert "Plugin-Status" in text
|
||||
assert "::butler" in text
|
||||
registry = InlineCommandRegistry()
|
||||
async def dummy(room_id, args):
|
||||
return "ok"
|
||||
|
||||
registry.register("hilfe", dummy, "Zeigt diese Hilfeseite", category="Hilfe")
|
||||
registry.register("status", dummy, "Zeigt Plugin-Status", category="Hilfe")
|
||||
|
||||
parts = build_help_text_parts(registry, room_map_summary="")
|
||||
assert len(parts) == 1
|
||||
assert len(parts[0]) < 4500
|
||||
|
||||
|
||||
class TestBuildStatusText:
|
||||
|
||||
Reference in New Issue
Block a user