From 802143b7233edf973007de7b0e395f15db7acc69 Mon Sep 17 00:00:00 2001 From: ymq Date: Fri, 14 Aug 2026 15:44:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20create=5Fproject=20=E8=AE=BE=E7=BD=AE=20?= =?UTF-8?q?workspace=5Fdir=20+=20org=5Fid=20=E5=B9=B6=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=B8=93=E5=B1=9E=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:_t_create_project 未设置 workspace_dir,导致 _resolve_workspace 回退到 ~/pipeline_ws/default,所有项目共用同一目录,设计文档互相覆盖;前端 get_workspace_path 又回退到 /d/pipeline/workspaces//<项目名>,两处不一致导致工作空间浏览器显示'不可用'而文档实际写在 default --- pipeline_service/agent_loop_v2.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pipeline_service/agent_loop_v2.py b/pipeline_service/agent_loop_v2.py index df8373e..7b7154b 100644 --- a/pipeline_service/agent_loop_v2.py +++ b/pipeline_service/agent_loop_v2.py @@ -651,17 +651,33 @@ class AgentExecutor: return f"未找到项目: {name}" async def _t_create_project(self, sor, p, pid): + import os from appPublic.uniqueID import getID + from .workspace import WORKSPACE_BASE name = p.get("name", "").strip() desc = p.get("description", "") if not name: return "需要项目名称" + # 查当前用户 org_id(工作空间按 org 隔离) + org_id = "0" + if self.user_id: + _u = await sor.sqlExe( + "SELECT orgid FROM users WHERE id=${u}$ LIMIT 1", {"u": self.user_id}) + if _u: + org_id = getattr(_u[0], "orgid", "0") or "0" + + # 项目专属工作空间目录(与 workspace.py get_workspace_path 回退逻辑一致) + # 不设置 workspace_dir 会导致 _resolve_workspace 回退到 ~/pipeline_ws/default, + # 所有项目共用同一目录,设计文档/代码互相覆盖。 + workspace_dir = os.path.join(WORKSPACE_BASE, str(org_id), name) + os.makedirs(workspace_dir, exist_ok=True) + pid_val = getID() await sor.C("sd_projects", { "id": pid_val, "name": name, "description": desc, - "status": "active", + "status": "active", "org_id": org_id, "workspace_dir": workspace_dir, }) await sor.C("sd_iterations", { "id": getID(), "project_id": pid_val,