feat(filesystem): add multi-root local folder support in backend

This commit is contained in:
Anish Sarkar 2026-04-24 01:44:23 +05:30
parent daac6b5269
commit 6721919398
7 changed files with 422 additions and 30 deletions

View file

@ -8,7 +8,9 @@ from app.agents.new_chat.filesystem_selection import (
FilesystemMode,
FilesystemSelection,
)
from app.agents.new_chat.middleware.local_folder_backend import LocalFolderBackend
from app.agents.new_chat.middleware.multi_root_local_folder_backend import (
MultiRootLocalFolderBackend,
)
pytestmark = pytest.mark.unit
@ -17,16 +19,16 @@ class _RuntimeStub:
state = {"files": {}}
def test_backend_resolver_returns_local_backend_for_local_mode(tmp_path: Path):
def test_backend_resolver_returns_multi_root_backend_for_single_root(tmp_path: Path):
selection = FilesystemSelection(
mode=FilesystemMode.DESKTOP_LOCAL_FOLDER,
client_platform=ClientPlatform.DESKTOP,
local_root_path=str(tmp_path),
local_root_paths=(str(tmp_path),),
)
resolver = build_backend_resolver(selection)
backend = resolver(_RuntimeStub())
assert isinstance(backend, LocalFolderBackend)
assert isinstance(backend, MultiRootLocalFolderBackend)
def test_backend_resolver_uses_cloud_mode_by_default():
@ -35,3 +37,19 @@ def test_backend_resolver_uses_cloud_mode_by_default():
# StateBackend class name check keeps this test decoupled
# from internal deepagents runtime class identity.
assert backend.__class__.__name__ == "StateBackend"
def test_backend_resolver_returns_multi_root_backend_for_multiple_roots(tmp_path: Path):
root_one = tmp_path / "resume"
root_two = tmp_path / "notes"
root_one.mkdir()
root_two.mkdir()
selection = FilesystemSelection(
mode=FilesystemMode.DESKTOP_LOCAL_FOLDER,
client_platform=ClientPlatform.DESKTOP,
local_root_paths=(str(root_one), str(root_two)),
)
resolver = build_backend_resolver(selection)
backend = resolver(_RuntimeStub())
assert isinstance(backend, MultiRootLocalFolderBackend)