feat(agent): add learn action flow and grounding guards

This commit is contained in:
Dom
2026-06-02 16:24:10 +02:00
parent 86b3c8f7e7
commit d38f0b0f2f
39 changed files with 5901 additions and 212 deletions

View File

@@ -120,7 +120,7 @@ class TestDispatchPausedAction:
class TestPausedBubbleHeight:
"""Couvre _compute_paused_bubble_height — patch troncature 22 mai 2026."""
"""Couvre _compute_paused_bubble_height — anti-troncature pause UI."""
def test_empty_message_uses_minimum_height(self):
h, scroll = ChatWindow._compute_paused_bubble_height("")
@@ -133,10 +133,27 @@ class TestPausedBubbleHeight:
assert scroll is False
def test_long_single_line_triggers_scrollbar(self):
# ~600 chars sans \n → wrapped_lines = 600 // 60 + 1 = 11
msg = "x" * 600
h, scroll = ChatWindow._compute_paused_bubble_height(msg)
assert h == 11
assert h == 12
assert scroll is True
def test_narrow_window_estimate_keeps_wrong_window_message_visible(self):
"""Cas observé sur Windows : fenêtre Léa ~380px, message wrong_window
coupé après "attendu". Avec ~34 caractères par ligne, il faut
prévoir assez de lignes pour afficher le détail."""
msg = (
"Je m'attendais à voir la bonne fenêtre mais je vois autre chose. "
"Peux-tu vérifier que l'application est au premier plan ? "
"(Fenêtre incorrecte : attendu "
"'http192.168.1.408765dossier.htmlid=.txt - Bloc-notes', "
"actuel 'Program Manager')"
)
h, scroll = ChatWindow._compute_paused_bubble_height(
msg,
chars_per_line=34,
)
assert h >= 7
assert scroll is True
def test_message_with_many_newlines_uses_explicit_count(self):
@@ -150,11 +167,11 @@ class TestPausedBubbleHeight:
assert scroll is False
def test_cap_reached_triggers_scrollbar_even_if_short(self):
"""Quand on dépasse le cap (12 lignes), la scrollbar DOIT
"""Quand on dépasse le cap, la scrollbar DOIT
s'afficher quel que soit la longueur en caractères."""
msg = "\n".join([f"l{i}" for i in range(20)])
h, scroll = ChatWindow._compute_paused_bubble_height(msg)
assert h == 12 # plafond
assert h == 14 # plafond
assert scroll is True
def test_long_content_triggers_scrollbar_at_200_chars(self):
@@ -163,3 +180,18 @@ class TestPausedBubbleHeight:
msg = "x" * 220
h, scroll = ChatWindow._compute_paused_bubble_height(msg)
assert scroll is True
def test_dynamic_small_viewport_caps_rows_and_scrolls(self):
msg = (
"Je m'attendais à voir la bonne fenêtre mais je vois autre chose. "
"Peux-tu vérifier que l'application est au premier plan ? "
"(Post-vérif échouée : fenêtre '*test Bloc-notes' au lieu de "
"'Enregistrer sous')"
)
h, scroll = ChatWindow._compute_paused_bubble_height(
msg,
chars_per_line=32,
max_rows=5,
)
assert h == 5
assert scroll is True