From 09d51b87c76703389267a22b19aa79c46ff2187c Mon Sep 17 00:00:00 2001 From: ymq Date: Sun, 9 Aug 2026 23:55:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=5Fload=5Fctx=20fallback=20=E2=80=94=20r?= =?UTF-8?q?ecover=20project=5Fid=20from=20conversation=20history=20when=20?= =?UTF-8?q?settings=20table=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/cockpit_chat.dspy | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 8f1bb7c..0edfbb5 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -83,6 +83,11 @@ async def _load_ctx(sor, uid): ctx = {'pid':'','pname':'','ws':'','skills_dir':'','repos':[]} if not recs: return ctx ctx['pid'] = getattr(recs[0],'current_project_id','') or '' + if not ctx['pid']: + # Fallback: recover from most recent conversation's iteration_id (which stores project_id) + last = await sor.sqlExe("SELECT iteration_id FROM pipeline_conversations WHERE created_by=${u}$ AND iteration_id != '' ORDER BY created_at DESC LIMIT 1",{"u":uid}) + if last: + ctx['pid'] = getattr(last[0],'iteration_id','') or '' if ctx['pid']: projs = await sor.sqlExe("SELECT name,workspace_dir,org_id FROM sd_projects WHERE id=${p}$",{"p":ctx['pid']}) if projs: