v2.14.0 (#743)
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>
This commit is contained in:
parent
ad0d5c9520
commit
3f8487f761
197 changed files with 10819 additions and 2830 deletions
78
tests/cli/textual_ui/test_user_message_attachments.py
Normal file
78
tests/cli/textual_ui/test_user_message_attachments.py
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from weakref import WeakKeyDictionary
|
||||
|
||||
from vibe.cli.textual_ui.widgets.messages import UserMessage
|
||||
from vibe.cli.textual_ui.windowing.history import build_history_widgets
|
||||
from vibe.core.types import ImageAttachment, LLMMessage, Role
|
||||
|
||||
|
||||
def _att(path: Path, alias: str) -> ImageAttachment:
|
||||
path.write_bytes(b"\x89PNG")
|
||||
return ImageAttachment(path=path, alias=alias, mime_type="image/png")
|
||||
|
||||
|
||||
def test_attachments_footer_singular(tmp_path: Path) -> None:
|
||||
att = _att(tmp_path / "shot.png", "shot.png")
|
||||
|
||||
rendered = UserMessage._format_attachments_footer([att])
|
||||
|
||||
assert "attached image:" in rendered
|
||||
assert '[link="file://' in rendered
|
||||
assert "]shot.png[/link]" in rendered
|
||||
|
||||
|
||||
def test_attachments_footer_plural(tmp_path: Path) -> None:
|
||||
a = _att(tmp_path / "a.png", "a.png")
|
||||
b = _att(tmp_path / "b.png", "b.png")
|
||||
|
||||
rendered = UserMessage._format_attachments_footer([a, b])
|
||||
|
||||
assert "attached images:" in rendered
|
||||
assert rendered.count('[link="file://') == 2
|
||||
assert "a.png" in rendered
|
||||
assert "b.png" in rendered
|
||||
|
||||
|
||||
def test_attachments_footer_escapes_alias_brackets(tmp_path: Path) -> None:
|
||||
att = _att(tmp_path / "shot.png", "weird [bracket].png")
|
||||
|
||||
rendered = UserMessage._format_attachments_footer([att])
|
||||
|
||||
# Rich's escape() turns "[" into "\[".
|
||||
assert "\\[bracket]" in rendered
|
||||
|
||||
|
||||
def test_resumed_user_message_with_images_renders_footer(tmp_path: Path) -> None:
|
||||
att = _att(tmp_path / "shot.png", "shot.png")
|
||||
msg = LLMMessage(role=Role.user, content="look at @shot.png", images=[att])
|
||||
|
||||
widgets = build_history_widgets(
|
||||
[msg],
|
||||
tool_call_map={},
|
||||
start_index=0,
|
||||
tools_collapsed=False,
|
||||
history_widget_indices=WeakKeyDictionary(),
|
||||
)
|
||||
|
||||
assert len(widgets) == 1
|
||||
user_widget = widgets[0]
|
||||
assert isinstance(user_widget, UserMessage)
|
||||
assert user_widget._images == [att]
|
||||
|
||||
|
||||
def test_resumed_user_message_with_images_only_still_mounts(tmp_path: Path) -> None:
|
||||
att = _att(tmp_path / "shot.png", "shot.png")
|
||||
msg = LLMMessage(role=Role.user, content="", images=[att])
|
||||
|
||||
widgets = build_history_widgets(
|
||||
[msg],
|
||||
tool_call_map={},
|
||||
start_index=0,
|
||||
tools_collapsed=False,
|
||||
history_widget_indices=WeakKeyDictionary(),
|
||||
)
|
||||
|
||||
assert len(widgets) == 1
|
||||
assert isinstance(widgets[0], UserMessage)
|
||||
Loading…
Add table
Add a link
Reference in a new issue