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:
Mathias Gesbert 2026-06-04 18:26:35 +02:00 committed by GitHub
parent ad0d5c9520
commit 3f8487f761
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
197 changed files with 10819 additions and 2830 deletions

View file

@ -2,6 +2,8 @@ from __future__ import annotations
from pathlib import Path
import pytest
from vibe.core.autocompletion.path_prompt import (
build_path_prompt_payload,
build_title_segments,
@ -22,6 +24,47 @@ def test_deduplicates_same_file_mentioned_twice(tmp_path: Path) -> None:
assert len(payload.all_resources) == 2
class TestTildeExpansion:
def test_tilde_path_expands_and_attaches(
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("HOME", str(tmp_path))
shot = tmp_path / "shot.png"
shot.write_bytes(b"\x89PNG")
payload = build_path_prompt_payload("look at @~/shot.png", base_dir=tmp_path)
assert len(payload.resources) == 1
resource = payload.resources[0]
assert resource.path == shot.resolve()
assert resource.alias == "~/shot.png"
assert resource.kind == "image"
def test_bare_tilde_attaches_home_as_folder(
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv("HOME", str(tmp_path))
payload = build_path_prompt_payload("go to @~", base_dir=tmp_path)
assert len(payload.resources) == 1
assert payload.resources[0].path == tmp_path.resolve()
assert payload.resources[0].kind == "folder"
def test_unknown_user_tilde_does_not_crash(self, tmp_path: Path) -> None:
payload = build_path_prompt_payload(
"see @~nonexistentuser1234/x.png", base_dir=tmp_path
)
assert payload.resources == []
def test_tilde_mid_token_without_anchor_stays_text(self, tmp_path: Path) -> None:
payload = build_path_prompt_payload("foo~bar baz", base_dir=tmp_path)
assert payload.resources == []
assert payload.prompt_text == "foo~bar baz"
class TestBuildTitleSegments:
def test_empty_message(self) -> None:
assert build_title_segments("") == []