v2.17.0 (#822)
Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Hdandria <henri.dandria@mistral.ai> Co-authored-by: Ivana Dunisijevic <ivana.dunisijevic@mistral.ai> Co-authored-by: Jean Burellier <sheplu@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Mert Unsal <mert.unsal@mistral.ai> Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com> Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Val <102326092+vdeva@users.noreply.github.com> Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com> Co-authored-by: renovate-mistral[bot] <253709520+renovate-mistral[bot]@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
564a14365e
commit
6bedf271ce
223 changed files with 10533 additions and 6947 deletions
|
|
@ -6,6 +6,7 @@ import tomllib
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from vibe.cli.textual_ui.widgets.feedback_bar_manager import FeedbackBarManager
|
||||
from vibe.core.cache_store import FileSystemVibeCodeCacheStore
|
||||
from vibe.core.feedback import (
|
||||
_CACHE_SECTION,
|
||||
_LAST_SHOWN_KEY,
|
||||
|
|
@ -15,24 +16,18 @@ from vibe.core.feedback import (
|
|||
from vibe.core.types import LLMMessage, Role
|
||||
|
||||
|
||||
def _patch_cache_file(tmp_path: Path):
|
||||
from vibe.core.paths._vibe_home import GlobalPath
|
||||
|
||||
return patch(
|
||||
"vibe.core.feedback.CACHE_FILE", GlobalPath(lambda: tmp_path / "cache.toml")
|
||||
)
|
||||
|
||||
|
||||
def _patch_probability(value: float):
|
||||
return patch("vibe.core.feedback.FEEDBACK_PROBABILITY", value)
|
||||
|
||||
|
||||
def _make_agent_loop(
|
||||
cache_path: Path,
|
||||
user_message_count: int = MIN_USER_MESSAGES_FOR_FEEDBACK,
|
||||
telemetry_active: bool = True,
|
||||
) -> MagicMock:
|
||||
loop = MagicMock()
|
||||
loop.telemetry_client.is_active.return_value = telemetry_active
|
||||
loop.cache_store = FileSystemVibeCodeCacheStore(cache_path)
|
||||
messages = [
|
||||
LLMMessage(role=Role.user, content=f"msg {i}")
|
||||
for i in range(user_message_count)
|
||||
|
|
@ -45,20 +40,22 @@ class TestShouldShow:
|
|||
def test_shows_when_conditions_met(self, tmp_path: Path) -> None:
|
||||
manager = FeedbackBarManager()
|
||||
with (
|
||||
_patch_cache_file(tmp_path),
|
||||
_patch_probability(0.2),
|
||||
patch("vibe.core.feedback.random.random", return_value=0.0),
|
||||
):
|
||||
assert manager.should_show(_make_agent_loop()) is True
|
||||
assert (
|
||||
manager.should_show(_make_agent_loop(tmp_path / "cache.toml")) is True
|
||||
)
|
||||
|
||||
def test_does_not_show_when_random_misses(self, tmp_path: Path) -> None:
|
||||
manager = FeedbackBarManager()
|
||||
with (
|
||||
_patch_cache_file(tmp_path),
|
||||
_patch_probability(0.2),
|
||||
patch("vibe.core.feedback.random.random", return_value=1.0),
|
||||
):
|
||||
assert manager.should_show(_make_agent_loop()) is False
|
||||
assert (
|
||||
manager.should_show(_make_agent_loop(tmp_path / "cache.toml")) is False
|
||||
)
|
||||
|
||||
def test_does_not_show_within_cooldown(self, tmp_path: Path) -> None:
|
||||
(tmp_path / "cache.toml").write_text(
|
||||
|
|
@ -66,11 +63,12 @@ class TestShouldShow:
|
|||
)
|
||||
manager = FeedbackBarManager()
|
||||
with (
|
||||
_patch_cache_file(tmp_path),
|
||||
_patch_probability(0.2),
|
||||
patch("vibe.core.feedback.random.random", return_value=0.0),
|
||||
):
|
||||
assert manager.should_show(_make_agent_loop()) is False
|
||||
assert (
|
||||
manager.should_show(_make_agent_loop(tmp_path / "cache.toml")) is False
|
||||
)
|
||||
|
||||
def test_shows_after_cooldown_expires(self, tmp_path: Path) -> None:
|
||||
(tmp_path / "cache.toml").write_text(
|
||||
|
|
@ -78,30 +76,38 @@ class TestShouldShow:
|
|||
)
|
||||
manager = FeedbackBarManager()
|
||||
with (
|
||||
_patch_cache_file(tmp_path),
|
||||
_patch_probability(0.2),
|
||||
patch("vibe.core.feedback.random.random", return_value=0.0),
|
||||
):
|
||||
assert manager.should_show(_make_agent_loop()) is True
|
||||
assert (
|
||||
manager.should_show(_make_agent_loop(tmp_path / "cache.toml")) is True
|
||||
)
|
||||
|
||||
def test_does_not_show_when_telemetry_inactive(self, tmp_path: Path) -> None:
|
||||
manager = FeedbackBarManager()
|
||||
with _patch_cache_file(tmp_path), _patch_probability(0.2):
|
||||
with _patch_probability(0.2):
|
||||
assert (
|
||||
manager.should_show(_make_agent_loop(telemetry_active=False)) is False
|
||||
manager.should_show(
|
||||
_make_agent_loop(tmp_path / "cache.toml", telemetry_active=False)
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
def test_does_not_show_when_too_few_user_messages(self, tmp_path: Path) -> None:
|
||||
manager = FeedbackBarManager()
|
||||
with (
|
||||
_patch_cache_file(tmp_path),
|
||||
_patch_probability(0.2),
|
||||
patch("vibe.core.feedback.random.random", return_value=0.0),
|
||||
):
|
||||
assert manager.should_show(_make_agent_loop(user_message_count=1)) is False
|
||||
assert (
|
||||
manager.should_show(
|
||||
_make_agent_loop(tmp_path / "cache.toml", user_message_count=1)
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
def test_skips_injected_messages_in_count(self, tmp_path: Path) -> None:
|
||||
loop = _make_agent_loop(user_message_count=0)
|
||||
loop = _make_agent_loop(tmp_path / "cache.toml", user_message_count=0)
|
||||
loop.messages = [
|
||||
LLMMessage(role=Role.user, content="real"),
|
||||
LLMMessage(role=Role.user, content="injected", injected=True),
|
||||
|
|
@ -109,7 +115,6 @@ class TestShouldShow:
|
|||
]
|
||||
manager = FeedbackBarManager()
|
||||
with (
|
||||
_patch_cache_file(tmp_path),
|
||||
_patch_probability(0.2),
|
||||
patch("vibe.core.feedback.random.random", return_value=0.0),
|
||||
):
|
||||
|
|
@ -121,8 +126,7 @@ class TestRecordFeedbackAsked:
|
|||
def test_writes_timestamp_to_cache(self, tmp_path: Path) -> None:
|
||||
manager = FeedbackBarManager()
|
||||
before = int(time.time())
|
||||
with _patch_cache_file(tmp_path):
|
||||
manager.record_feedback_asked()
|
||||
with (tmp_path / "cache.toml").open("rb") as f:
|
||||
data = tomllib.load(f)
|
||||
manager.record_feedback_asked(_make_agent_loop(tmp_path / "cache.toml"))
|
||||
with (tmp_path / "cache.toml").open("rb") as f:
|
||||
data = tomllib.load(f)
|
||||
assert data[_CACHE_SECTION][_LAST_SHOWN_KEY] >= before
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue