Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849"""A workspace path that merely starts with the workspace path still resolves.
`_remote_path` spells a local workspace path in the remote root, and itsdocstring promises anything else passes through. `str.startswith` accepted asibling directory (`<cwd>-sibling/file.txt`), then `relative_to` raisedValueError, so a remote command crashed instead of passing the path through.e2e drives remote commands with real sessions and never names a sibling ofthe workspace, so the prefix/subpath mismatch stays invisible there."""
from __future__ import annotations
import sysimport unittestfrom pathlib import Path
ROOT = Path(__file__).resolve().parents[2]sys.path.insert(0, str(ROOT / "python"))
from albedo_plugins.remote import RemoteConnection, _remote_path # noqa: E402
class RemotePathTest(unittest.TestCase): def test_a_workspace_file_maps_into_the_remote_root(self) -> None: under = Path.cwd() / "notes" / "todo.md" self.assertEqual( _remote_path(RemoteConnection({"remote_cwd": "/remote/root"}), str(under)), "/remote/root/notes/todo.md", )
def test_a_sibling_of_the_workspace_passes_through(self) -> None: sibling = str(Path.cwd()) + "-sibling/file.txt" self.assertEqual( _remote_path(RemoteConnection({"remote_cwd": "/remote/root"}), sibling), sibling, )
def test_an_unrelated_path_passes_through(self) -> None: self.assertEqual( _remote_path( RemoteConnection({"remote_cwd": "/remote/root"}), "/etc/hostname" ), "/etc/hostname", )
if __name__ == "__main__": unittest.main()