v2.10.1 (#702)
Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Michel Thomazo <51709227+michelTho@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: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
228f3c65a9
commit
f71bfd3b8c
57 changed files with 2950 additions and 402 deletions
|
|
@ -2,7 +2,11 @@ from __future__ import annotations
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from vibe.core.autocompletion.path_prompt import build_path_prompt_payload
|
||||
from vibe.core.autocompletion.path_prompt import (
|
||||
build_path_prompt_payload,
|
||||
build_title_segments,
|
||||
)
|
||||
from vibe.core.session.title_format import MentionSegment, TextSegment
|
||||
|
||||
|
||||
def test_deduplicates_same_file_mentioned_twice(tmp_path: Path) -> None:
|
||||
|
|
@ -16,3 +20,58 @@ def test_deduplicates_same_file_mentioned_twice(tmp_path: Path) -> None:
|
|||
assert len(payload.resources) == 1
|
||||
assert payload.resources[0].path == readme
|
||||
assert len(payload.all_resources) == 2
|
||||
|
||||
|
||||
class TestBuildTitleSegments:
|
||||
def test_empty_message(self) -> None:
|
||||
assert build_title_segments("") == []
|
||||
|
||||
def test_plain_text_no_mentions(self) -> None:
|
||||
segments = build_title_segments("hello world")
|
||||
assert segments == [TextSegment(text="hello world")]
|
||||
|
||||
def test_matched_file_mention_uses_basename(self, tmp_path: Path) -> None:
|
||||
nested = tmp_path / "src" / "auth"
|
||||
nested.mkdir(parents=True)
|
||||
target = nested / "foo.py"
|
||||
target.write_text("x", encoding="utf-8")
|
||||
|
||||
segments = build_title_segments(
|
||||
"Refactor @src/auth/foo.py please", base_dir=tmp_path
|
||||
)
|
||||
assert segments == [
|
||||
TextSegment(text="Refactor "),
|
||||
MentionSegment(name="foo.py"),
|
||||
TextSegment(text=" please"),
|
||||
]
|
||||
|
||||
def test_unmatched_mention_stays_as_text(self, tmp_path: Path) -> None:
|
||||
segments = build_title_segments("Look at @nope.py here", base_dir=tmp_path)
|
||||
assert segments == [TextSegment(text="Look at @nope.py here")]
|
||||
|
||||
def test_folder_mention_uses_basename(self, tmp_path: Path) -> None:
|
||||
folder = tmp_path / "components"
|
||||
folder.mkdir()
|
||||
|
||||
segments = build_title_segments("Update @components", base_dir=tmp_path)
|
||||
assert segments == [
|
||||
TextSegment(text="Update "),
|
||||
MentionSegment(name="components"),
|
||||
]
|
||||
|
||||
def test_multiple_mentions_keep_text_in_between(self, tmp_path: Path) -> None:
|
||||
(tmp_path / "a.py").write_text("", encoding="utf-8")
|
||||
(tmp_path / "b.py").write_text("", encoding="utf-8")
|
||||
|
||||
segments = build_title_segments("@a.py vs @b.py", base_dir=tmp_path)
|
||||
assert segments == [
|
||||
MentionSegment(name="a.py"),
|
||||
TextSegment(text=" vs "),
|
||||
MentionSegment(name="b.py"),
|
||||
]
|
||||
|
||||
def test_mention_with_no_surrounding_text(self, tmp_path: Path) -> None:
|
||||
(tmp_path / "only.py").write_text("", encoding="utf-8")
|
||||
|
||||
segments = build_title_segments("@only.py", base_dir=tmp_path)
|
||||
assert segments == [MentionSegment(name="only.py")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue