fix: /task 弹窗 widget url 用 base_url 拼完整绝对路径(前端 absurl 需完整 URL)

This commit is contained in:
ymq 2026-08-18 12:53:55 +08:00
parent 20395a78b6
commit 6add7ff4fa
3 changed files with 13 additions and 5 deletions

View File

@ -62,6 +62,7 @@ class AgentExecutor:
workspace_dir: str = "",
model_name: str = None,
role: str = "", # 产线内角色(可选,如 develop/design驾驶舱 agent 为空)
base_url: str = "", # 请求 base_urlscheme://host/),供 slash 命令生成 widget 绝对 URL
):
self.config = config
self.project_id = project_id
@ -71,6 +72,7 @@ class AgentExecutor:
self.role = role # 产线内角色(技能/工具/prompt 按角色加载)
self.workspace_dir = workspace_dir or WORKSPACE_BASE
self.model_name = model_name or config.model_name
self.base_url = base_url
# 运行状态
self._msgs: List[dict] = [] # LLM 消息数组
@ -653,10 +655,11 @@ class AgentExecutor:
}
def _build_slash_ctx(self) -> dict:
"""构造传给 slash 命令 handler 的上下文(含 executor 引用 + role)。"""
"""构造传给 slash 命令 handler 的上下文(含 executor 引用 + role + base_url)。"""
ctx = self._build_ctx()
ctx["executor"] = self
ctx["role"] = self.role
ctx["base_url"] = getattr(self, "base_url", "") or ""
return ctx
async def _execute_ability_tool(self, tool_name: str, params: dict) -> Optional[str]:

View File

@ -109,7 +109,8 @@ class Gateway:
# ── 统一消息入口 ──
async def run_message(self, channel: str, user_id: str, content: str,
history=None, role: str = "", generic: bool = False) -> AsyncGenerator[str, None]:
history=None, role: str = "", generic: bool = False,
base_url: str = "") -> AsyncGenerator[str, None]:
"""统一消息入口:解析上下文 → 加载产线能力 → AgentExecutor 执行 → yield 事件流。
Args:
@ -153,7 +154,8 @@ class Gateway:
if ctx.get("default_llm_name"):
config.model_name = ctx["default_llm_name"]
executor = AgentExecutor(
config=config, project_id=ctx["pid"], user_id=user_id, role=role)
config=config, project_id=ctx["pid"], user_id=user_id, role=role,
base_url=base_url)
# 4. 转发标准化事件流
async for chunk in executor.run(content, history=history):

View File

@ -1477,6 +1477,9 @@ async def _slash_tasks(args, ctx):
async def _slash_task(args, ctx):
"""任务树 + 输入输出ResourceBrowser 弹窗)。返回 widget dict前端 AgentOut 检测 widgettype 渲染。"""
base = (ctx.get("base_url") or "").rstrip("/")
tree_url = f"{base}/pipeline-sdlc/api/task_tree.dspy"
io_url = f"{base}/pipeline-sdlc/api/task_io.dspy"
return {
"widgettype": "PopupWindow",
"options": {
@ -1492,7 +1495,7 @@ async def _slash_task(args, ctx):
"tree_options": {
"widgettype": "Tree",
"options": {
"dataurl": "/pipeline-sdlc/api/task_tree.dspy",
"dataurl": tree_url,
"textField": "label",
"idField": "id",
"cfontsize": 1.0,
@ -1500,7 +1503,7 @@ async def _slash_task(args, ctx):
},
"browser_options": {
"widgettype": "urlwidget",
"options": {"url": "/pipeline-sdlc/api/task_io.dspy"},
"options": {"url": io_url},
},
"tree_width": "300px",
},