Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(ui): keep skills route calls backward-compatible

Max950d99e41686
diff --git a/tests/test_ui_server_skills_routes.py b/tests/test_ui_server_skills_routes.py
index 5d8b870a0..c0f43be4f 100644
--- a/tests/test_ui_server_skills_routes.py
+++ b/tests/test_ui_server_skills_routes.py
@@ -118,6 +118,57 @@ def test_upload_drops_project_cwd(folderless, monkeypatch):
assert seen["project_dir"] is None # the project cwd was dropped, not errored
+def test_list_preserves_project_id_for_real_project(monkeypatch):
+ async def fake_list(*, scope, project_dir=None, backends=None, project_id=None):
+ assert scope == "project"
+ assert project_dir == "/tmp/project"
+ assert project_id == "proj-real"
+ return {"ok": True, "skills": [{"name": "demo", "scope": "project"}]}
+
+ def fake_resolve(project_id):
+ if project_id == "proj-real":
+ return "/tmp/project"
+ raise LookupError(project_id)
+
+ monkeypatch.setattr(ui_server, "_resolve_project_dir", fake_resolve)
+ monkeypatch.setattr(api, "list_skills", fake_list)
+
+ res = app.test_client().get("/api/skills?scope=project&project_id=proj-real")
+ body = res.get_json()
+
+ assert res.status_code == 200
+ assert body["ok"] is True
+ assert body["skills"][0]["scope"] == "project"
+
+
+def test_upload_preserves_project_id_for_real_project(monkeypatch):
+ seen = {}
+
+ async def fake_upload(payload, *, project_dir=None, project_id=None):
+ seen["project_dir"] = project_dir
+ seen["project_id"] = project_id
+ return {"ok": True, "skills": [], "dir": "/tmp/askill-upload-x"}
+
+ def fake_resolve(project_id):
+ if project_id == "proj-real":
+ return "/tmp/project"
+ raise LookupError(project_id)
+
+ monkeypatch.setattr(ui_server, "_resolve_project_dir", fake_resolve)
+ monkeypatch.setattr(api, "upload_skill_zip", fake_upload)
+
+ client = app.test_client()
+ res = client.post(
+ "/api/skills/upload",
+ json={"content_base64": "", "project_id": "proj-real"},
+ headers=csrf_headers(client),
+ )
+
+ assert res.status_code == 200
+ assert res.get_json()["ok"] is True
+ assert seen == {"project_dir": "/tmp/project", "project_id": "proj-real"}
+
+
@pytest.mark.parametrize(
"method,path,attr,payload",
[
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 06696dad9..7b8a99b86 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -7711,6 +7711,14 @@ def _project_no_folder_error():
)
+def _skills_project_id_kwargs(project_dir: str | None, project_id: str | None) -> dict[str, str]:
+ """Thread stable project ids only for real project-scoped skill requests."""
+
+ if project_dir is None or project_id is None:
+ return {}
+ return {"project_id": project_id}
+
+
@app.route("/api/projects/<project_id>/agents-md", methods=["GET"])
def project_agents_md_get(project_id: str):
"""Read the project's AGENTS.md (falling back to CLAUDE.md) for the editor."""
@@ -7807,8 +7815,8 @@ async def skills_list():
# global skills (with a flag) instead of erroring the whole page.
result = await api.list_skills(
scope="global",
- project_id=project_id,
backends=backends or None,
+ **_skills_project_id_kwargs(None, project_id),
)
if isinstance(result, dict) and result.get("ok"):
result = {**result, "project_no_folder": True}
@@ -7817,8 +7825,8 @@ async def skills_list():
await api.list_skills(
scope=scope,
project_dir=project_dir,
- project_id=project_id,
backends=backends or None,
+ **_skills_project_id_kwargs(project_dir, project_id),
)
)
@@ -7839,7 +7847,7 @@ async def skills_preview():
await api.preview_skill_source(
str(payload.get("source") or ""),
project_dir=project_dir,
- project_id=project_id,
+ **_skills_project_id_kwargs(project_dir, project_id),
)
)
@@ -7953,7 +7961,11 @@ async def skills_upload():
# step picks the scope. Drop the cwd like preview rather than erroring.
project_dir = None
return jsonify(
- await api.upload_skill_zip(payload, project_dir=project_dir, project_id=project_id)
+ await api.upload_skill_zip(
+ payload,
+ project_dir=project_dir,
+ **_skills_project_id_kwargs(project_dir, project_id),
+ )
)