Co-authored-by: Alexis Tacnet <alexis@mistral.ai> Co-authored-by: Clément Drouin <clement.drouin@mistral.ai> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Lucas Marandat <31749711+lucasmrdt@users.noreply.github.com> Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@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: p.vezia <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Hiba Chaabnia <Hiba-Chaabnia@users.noreply.github.com> Co-authored-by: Nikhil Bhima <nikhilbhima@users.noreply.github.com> Co-authored-by: Nkipohcs <Nkipohcs@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from textual.pilot import Pilot
|
|
|
|
from tests.snapshots.base_snapshot_test_app import BaseSnapshotTestApp
|
|
from tests.snapshots.snap_compare import SnapCompare
|
|
from vibe.core.types import FunctionCall, LLMMessage, Role, ToolCall
|
|
|
|
|
|
class SnapshotTestAppWithResumedSession(BaseSnapshotTestApp):
|
|
def __init__(self) -> None:
|
|
super().__init__()
|
|
# Simulate a previous session with messages
|
|
user_msg = LLMMessage(role=Role.user, content="Hello, how are you?")
|
|
assistant_msg = LLMMessage(
|
|
role=Role.assistant,
|
|
content="I'm doing well, thank you! Let me read that file for you.",
|
|
tool_calls=[
|
|
ToolCall(
|
|
id="tool_call_1",
|
|
index=0,
|
|
function=FunctionCall(
|
|
name="read", arguments='{"file_path": "test.txt"}'
|
|
),
|
|
)
|
|
],
|
|
)
|
|
tool_result_msg = LLMMessage(
|
|
role=Role.tool,
|
|
content="File content: This is a test file with some content.",
|
|
name="read",
|
|
tool_call_id="tool_call_1",
|
|
)
|
|
|
|
self.agent_loop.messages.extend([user_msg, assistant_msg, tool_result_msg])
|
|
|
|
|
|
def test_snapshot_shows_resumed_session_messages(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
# Wait for the app to initialize and rebuild history
|
|
await pilot.pause(0.5)
|
|
|
|
assert snap_compare(
|
|
"test_ui_snapshot_session_resume.py:SnapshotTestAppWithResumedSession",
|
|
terminal_size=(120, 36),
|
|
run_before=run_before,
|
|
)
|