v2.17.1 (#823)
Co-authored-by: Jean Burellier <sheplu@users.noreply.github.com> Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com> Co-authored-by: renovate-mistral[bot] <253709520+renovate-mistral[bot]@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
6bedf271ce
commit
725d3a56ce
35 changed files with 1330 additions and 288 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
|
@ -20,6 +21,14 @@ async def _system_prompt(acp_agent_loop: VibeAcpAgentLoop, session_id: str) -> s
|
|||
return session.agent_loop.messages[0].content or ""
|
||||
|
||||
|
||||
async def _wait_for_background_tasks(
|
||||
acp_agent_loop: VibeAcpAgentLoop, session_id: str
|
||||
) -> None:
|
||||
session = acp_agent_loop.sessions[session_id]
|
||||
while session._tasks:
|
||||
await asyncio.gather(*list(session._tasks))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def acp_agent_loop(
|
||||
backend: FakeBackend, monkeypatch: pytest.MonkeyPatch
|
||||
|
|
@ -66,12 +75,12 @@ class TestWorkspaceTrustExtMethods:
|
|||
"cwd": str(tmp_working_directory.resolve()),
|
||||
"repoRoot": None,
|
||||
"ignoredFiles": ["AGENTS.md"],
|
||||
"availableDecisions": ["trust_cwd", "trust_session", "decline"],
|
||||
"availableDecisions": ["trust_cwd", "decline"],
|
||||
},
|
||||
}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_workspace_trust_decision_trusts_session_and_reloads_session(
|
||||
async def test_workspace_trust_decision_trusts_cwd_and_reloads_session(
|
||||
self, acp_agent_loop: VibeAcpAgentLoop, tmp_working_directory: Path
|
||||
) -> None:
|
||||
(tmp_working_directory / "AGENTS.md").write_text(
|
||||
|
|
@ -90,19 +99,74 @@ class TestWorkspaceTrustExtMethods:
|
|||
"trust/decision",
|
||||
{
|
||||
"cwd": str(tmp_working_directory),
|
||||
"decision": "trust_session",
|
||||
"decision": "trust_cwd",
|
||||
"session_id": session_response.session_id,
|
||||
},
|
||||
)
|
||||
|
||||
assert response == {"trust_status": "session", "details": None}
|
||||
assert response == {"trust_status": "trusted", "details": None}
|
||||
normalized = str(tmp_working_directory.resolve())
|
||||
assert normalized in trusted_folders_manager._session_trusted
|
||||
assert normalized not in trusted_folders_manager._trusted
|
||||
assert normalized not in trusted_folders_manager._session_trusted
|
||||
assert normalized in trusted_folders_manager._trusted
|
||||
await _wait_for_background_tasks(acp_agent_loop, session_response.session_id)
|
||||
assert "Reloaded session instructions" in await _system_prompt(
|
||||
acp_agent_loop, session_response.session_id
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_workspace_trust_decision_returns_before_reload_completes(
|
||||
self,
|
||||
acp_agent_loop: VibeAcpAgentLoop,
|
||||
tmp_working_directory: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
(tmp_working_directory / "AGENTS.md").write_text(
|
||||
"Slow reload instructions", encoding="utf-8"
|
||||
)
|
||||
|
||||
session_response = await acp_agent_loop.new_session(
|
||||
cwd=str(tmp_working_directory), mcp_servers=[]
|
||||
)
|
||||
assert session_response.session_id is not None
|
||||
|
||||
reload_started = asyncio.Event()
|
||||
release_reload = asyncio.Event()
|
||||
|
||||
async def slow_reload_session_config(session) -> None:
|
||||
reload_started.set()
|
||||
await release_reload.wait()
|
||||
|
||||
monkeypatch.setattr(
|
||||
acp_agent_loop, "_reload_session_config", slow_reload_session_config
|
||||
)
|
||||
|
||||
decision_task = asyncio.create_task(
|
||||
acp_agent_loop.ext_method(
|
||||
"trust/decision",
|
||||
{
|
||||
"cwd": str(tmp_working_directory),
|
||||
"decision": "trust_cwd",
|
||||
"session_id": session_response.session_id,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
await asyncio.wait_for(reload_started.wait(), timeout=1)
|
||||
await asyncio.sleep(0)
|
||||
|
||||
assert decision_task.done()
|
||||
assert decision_task.result() == {
|
||||
"trust_status": "trusted",
|
||||
"details": None,
|
||||
}
|
||||
finally:
|
||||
release_reload.set()
|
||||
await decision_task
|
||||
await _wait_for_background_tasks(
|
||||
acp_agent_loop, session_response.session_id
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_workspace_trust_decision_rejects_unavailable_decision(
|
||||
self, acp_agent_loop: VibeAcpAgentLoop, tmp_working_directory: Path
|
||||
|
|
@ -117,6 +181,12 @@ class TestWorkspaceTrustExtMethods:
|
|||
{"cwd": str(tmp_working_directory), "decision": "trust_repo"},
|
||||
)
|
||||
|
||||
with pytest.raises(InvalidRequestError):
|
||||
await acp_agent_loop.ext_method(
|
||||
"trust/decision",
|
||||
{"cwd": str(tmp_working_directory), "decision": "trust_session"},
|
||||
)
|
||||
|
||||
assert trusted_folders_manager.is_trusted(tmp_working_directory) is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -132,7 +202,7 @@ class TestWorkspaceTrustExtMethods:
|
|||
"trust/decision",
|
||||
{
|
||||
"cwd": str(tmp_working_directory),
|
||||
"decision": "trust_session",
|
||||
"decision": "trust_cwd",
|
||||
"session_id": "missing-session",
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue