feat(workspace): 新增 get_session_context(per-session 优先读 project+iteration) 支持多 tab 项目上下文隔离
This commit is contained in:
parent
50b3b37f26
commit
f84da9d189
@ -127,6 +127,38 @@ async def get_session_project_id(sor, uid, session_id=''):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
async def get_session_context(sor, uid, session_id=''):
|
||||||
|
"""按会话解析 (project_id, iteration_id)。per-session 优先,回退 per-user 全局。
|
||||||
|
|
||||||
|
多 tab 隔离:session_id 非空时优先读 pipeline_session_settings(每个 user+session 一条),
|
||||||
|
无记录回退 pipeline_agent_settings.current_project_id/current_iteration_id。
|
||||||
|
"""
|
||||||
|
if session_id:
|
||||||
|
try:
|
||||||
|
recs = await sor.sqlExe(
|
||||||
|
"SELECT current_project_id, current_iteration_id FROM pipeline_session_settings "
|
||||||
|
"WHERE user_id=${u}$ AND session_id=${s}$",
|
||||||
|
{"u": uid, "s": session_id})
|
||||||
|
if recs:
|
||||||
|
pid = getattr(recs[0], 'current_project_id', '') or ''
|
||||||
|
iid = getattr(recs[0], 'current_iteration_id', '') or ''
|
||||||
|
if pid or iid:
|
||||||
|
return pid, iid
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
recs = await sor.sqlExe(
|
||||||
|
"SELECT current_project_id, current_iteration_id FROM pipeline_agent_settings "
|
||||||
|
"WHERE user_id=${u}$",
|
||||||
|
{"u": uid})
|
||||||
|
if recs:
|
||||||
|
return (getattr(recs[0], 'current_project_id', '') or '',
|
||||||
|
getattr(recs[0], 'current_iteration_id', '') or '')
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return '', ''
|
||||||
|
|
||||||
|
|
||||||
async def get_workspace_dir(sor, uid, session_id=''):
|
async def get_workspace_dir(sor, uid, session_id=''):
|
||||||
"""读当前项目的 workspace 目录(统一 workspace_*.dspy 的重复逻辑)。
|
"""读当前项目的 workspace 目录(统一 workspace_*.dspy 的重复逻辑)。
|
||||||
|
|
||||||
@ -414,6 +446,8 @@ def load_workspace():
|
|||||||
g.get_space_dir = get_space_dir
|
g.get_space_dir = get_space_dir
|
||||||
g.get_project_dir = get_project_dir
|
g.get_project_dir = get_project_dir
|
||||||
g.get_project_apps_modules = get_project_apps_modules
|
g.get_project_apps_modules = get_project_apps_modules
|
||||||
|
g.get_session_project_id = get_session_project_id
|
||||||
|
g.get_session_context = get_session_context
|
||||||
g.build_workspace_path = build_workspace_path
|
g.build_workspace_path = build_workspace_path
|
||||||
g.build_space_path = build_space_path
|
g.build_space_path = build_space_path
|
||||||
g.resolve_workspace_path = resolve_workspace_path
|
g.resolve_workspace_path = resolve_workspace_path
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user