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>
75 lines
2.3 KiB
Python
75 lines
2.3 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import cast
|
|
from unittest.mock import patch
|
|
|
|
from textual.app import App, ComposeResult
|
|
from textual.containers import VerticalScroll
|
|
from textual.pilot import Pilot
|
|
|
|
from tests.snapshots.snap_compare import SnapCompare
|
|
from vibe.cli.textual_ui.widgets.status_message import StatusMessage
|
|
from vibe.cli.textual_ui.widgets.tools import ToolCallMessage
|
|
from vibe.core.tools.builtins.read import Read, ReadArgs
|
|
from vibe.core.types import ToolCallEvent
|
|
|
|
|
|
class ToolCallStreamingUpdateTest(App):
|
|
CSS_PATH = "../../vibe/cli/textual_ui/app.tcss"
|
|
|
|
def __init__(self) -> None:
|
|
super().__init__()
|
|
self._widget: ToolCallMessage | None = None
|
|
|
|
def compose(self) -> ComposeResult:
|
|
partial_event = ToolCallEvent(
|
|
tool_call_id="tc_streaming",
|
|
tool_call_index=0,
|
|
tool_name="read",
|
|
tool_class=Read,
|
|
args=None,
|
|
)
|
|
self._widget = ToolCallMessage(partial_event)
|
|
|
|
with VerticalScroll():
|
|
yield self._widget
|
|
|
|
def update_with_full_event(self) -> None:
|
|
if self._widget is None:
|
|
return
|
|
|
|
full_event = ToolCallEvent(
|
|
tool_call_id="tc_streaming",
|
|
tool_call_index=0,
|
|
tool_name="read",
|
|
tool_class=Read,
|
|
args=ReadArgs(file_path="/test/example.py"),
|
|
)
|
|
self._widget.update_event(full_event)
|
|
|
|
|
|
def test_snapshot_tool_call_partial(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await pilot.pause(0.1)
|
|
|
|
with patch.object(StatusMessage, "start_spinner_timer"):
|
|
assert snap_compare(
|
|
"test_ui_snapshot_streaming_tool_call.py:ToolCallStreamingUpdateTest",
|
|
terminal_size=(80, 10),
|
|
run_before=run_before,
|
|
)
|
|
|
|
|
|
def test_snapshot_tool_call_updated(snap_compare: SnapCompare) -> None:
|
|
async def run_before(pilot: Pilot) -> None:
|
|
await pilot.pause(0.1)
|
|
app = cast(ToolCallStreamingUpdateTest, pilot.app)
|
|
app.update_with_full_event()
|
|
await pilot.pause(0.1)
|
|
|
|
with patch.object(StatusMessage, "start_spinner_timer"):
|
|
assert snap_compare(
|
|
"test_ui_snapshot_streaming_tool_call.py:ToolCallStreamingUpdateTest",
|
|
terminal_size=(80, 10),
|
|
run_before=run_before,
|
|
)
|