Skip to content

Commit b16ddff

Browse files
committed
fix(cli): keep config fallback out of local listings
Signed-off-by: phernandez <paul@basicmachines.co>
1 parent bf743b3 commit b16ddff

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

src/basic_memory/cli/commands/project.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,10 @@ def _fetch_cloud_workspace_results() -> tuple[
503503
# The two commands must agree on whether a configured project exists.
504504
# Outcome: seed a local-keyed row from config so the project still renders;
505505
# the row-building logic below derives its display from the config entry.
506-
# Constraint: only fill from config for the local-inclusive view. A pure
507-
# --cloud listing (no local_result) or a --workspace-filtered view is
508-
# deliberately scoped, so configured local projects must not leak into it.
509-
if local_result is not None and not workspace_filter_requested:
506+
# Constraint: only fill from config for the default combined view. Explicit
507+
# --local, --cloud, and --workspace listings are deliberately scoped, so
508+
# configured projects must not leak into them.
509+
if not local and local_result is not None and not workspace_filter_requested:
510510
seeded_permalinks = {permalink for _, permalink in row_names_by_key}
511511
for permalink, project_name in configured_names_by_permalink.items():
512512
if permalink not in seeded_permalinks:

tests/cli/test_project_list_and_ls.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,3 +1108,33 @@ async def fake_list_projects(self):
11081108
# The configured project is now visible instead of an empty table.
11091109
main_line = next(line for line in result.stdout.splitlines() if "│ main" in line)
11101110
assert "cloud" in main_line # cloud-mode projects route to the cloud CLI
1111+
1112+
1113+
def test_project_list_local_excludes_cloud_mode_config_fallback(
1114+
runner: CliRunner, write_config, mock_client, tmp_path, monkeypatch
1115+
):
1116+
"""An explicit local listing must only contain projects returned by the local API."""
1117+
write_config(
1118+
{
1119+
"env": "dev",
1120+
"projects": {
1121+
"main": {
1122+
"path": "",
1123+
"mode": "cloud",
1124+
"workspace_id": None,
1125+
"local_sync_path": None,
1126+
}
1127+
},
1128+
"default_project": "main",
1129+
}
1130+
)
1131+
1132+
async def fake_list_projects(self):
1133+
return ProjectList.model_validate({"projects": [], "default_project": "main"})
1134+
1135+
monkeypatch.setattr(ProjectClient, "list_projects", fake_list_projects)
1136+
1137+
result = runner.invoke(app, ["project", "list", "--local", "--json"])
1138+
1139+
assert result.exit_code == 0, f"Exit code: {result.exit_code}, output: {result.stdout}"
1140+
assert json.loads(result.stdout) == {"projects": []}

0 commit comments

Comments
 (0)