feat(AI 建任务): 直接创建 + 草稿沉淀 + MCP de_snapshot;修「建任务页收不到 done」
用户报的"探索完无法点击创建任务"真因:一个 run 的事件原先只有**一条** queue.Queue, 聊天页与建任务页同时开着时两个 EventSource 会**瓜分**它——建任务页的回放卡在中间、 `done` 被聊天页取走 → 永远等不到草稿,页面上自然没有可点的"创建"。 一、修(根因 + 表现) - `web/agent_api.py` 新增 `_Fanout`:**每个订阅者一个专属队列**,多开页面各看各的, 还带单轮事件缓冲(晚订阅/刷新重连也能补齐回放,终止事件一定送达)。 实测两路订阅者收到完全一致的 1039 条事件(含 done)。 - `static/admin/agent.js`:断线重连的兜底订阅也按 `mode` 让开(此前漏了这一处)。 二、补齐上一批的三项 - **「直接创建」**:`POST /api/agent/task_draft/create`(草稿体只在服务端、创建前再校验一次、 成功后清草稿避免重复建)+ 草稿预览里的「✓ 直接创建任务」按钮 + 「探索完直接创建任务」勾选框。 - **草稿沉淀经验/动作**:designer 轮次也走 `_distill_experience/_distill_actions`, 但**只在草稿通过校验时**(没走通的试错不入库,免得把误点当经验)。 - **MCP `de_snapshot`**(第 20 个工具):截图+元素树一次取齐(省一次来回、不会因界面在动而错位), 附带 `screen_state`/`unstable`;两套提示词都改为优先用它。 平台侧 `/api/uiauto/snapshot` 随之多返回 `screen_state`。 三、文档 - AI_TASK_GEN §10:§10.3 记两个 bug 的真因与修法、§10.4 三项标完成、§10.5 剩余项。 - AI_CONSOLE(扇出语义、多页面同时看一轮)、API(task_draft/create、snapshot 字段)、 MCP/MCP_DESIGN/staffdeck/README/ARCHITECTURE:工具数 19→20 + de_snapshot 条目。 - backlog:记一条新发现的缺陷——`mcp_server/platform_client._login()` 会把"登录页 200" 当成登录成功(现场进程缺 `MCP_PLATFORM_PASS` 时表现为含糊的 platform_unavailable)。 自测:真机浏览器端到端(勾上"探索完直接创建")→ 探索 12 步 → 草稿 → 自动建任务成功; `de_snapshot` 直连真机校验;校验器 21 条用例、扇出单元用例、本地工具契约用例全绿。 自测产生的任务/草稿已全部清理(未碰用户既有数据)。
This commit is contained in:
@@ -366,6 +366,9 @@ body{background:var(--bg);font-family:var(--body);color:var(--text);font-size:14
|
||||
.tg-hint{font-size:11px;color:var(--text-light);line-height:1.5}
|
||||
.tg-actions{display:flex;gap:8px}
|
||||
.tg-actions .btn{flex:1}
|
||||
.tg-check{display:flex;align-items:flex-start;gap:6px;font-size:11.5px;color:var(--text-light);cursor:pointer;line-height:1.5}
|
||||
.tg-check input{margin-top:2px;flex:none}
|
||||
.tg-check b{color:var(--text)}
|
||||
.tg-status{font-size:11.5px;color:var(--text-light);min-height:16px;line-height:1.5}
|
||||
.tg-right-head{display:flex;justify-content:space-between;align-items:center;font-size:12.5px;font-weight:700;color:#374151}
|
||||
.tg-stream{flex:1;min-height:120px;overflow-y:auto;border:1px solid #e5e7eb;border-radius:12px;background:#fff;padding:10px;display:flex;flex-direction:column;gap:6px}
|
||||
@@ -688,6 +691,10 @@ body{background:var(--bg);font-family:var(--body);color:var(--text);font-size:14
|
||||
<button class="btn btn-primary" id="tg-start" onclick="startExplore()">🚀 开始探索</button>
|
||||
<button class="btn btn-danger" id="tg-stop" style="display:none" onclick="stopExplore()">■ 停止</button>
|
||||
</div>
|
||||
<label class="tg-check" title="勾上后:探索出草稿就直接建成任务(不再等你点确认)。草稿入库前仍会再校验一次;任务建好后可在任务页编辑/停用">
|
||||
<input type="checkbox" id="tg-auto-create">
|
||||
<span>探索完<b>直接创建任务</b>(跳过人工核对)</span>
|
||||
</label>
|
||||
<div class="tg-status" id="tg-status"></div>
|
||||
|
||||
<div class="tg-card" id="tg-live-card" style="display:none">
|
||||
|
||||
Reference in New Issue
Block a user