fix(assessments): expose task blockers and flush Pi output before exit
This commit is contained in:
parent
697f2299fd
commit
a598ffe8ee
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
概览统计可直接查看明细:累计 Token 进入上下文与用量,状态、规划轮次进入运行记录;意图总数和状态计数进入对应队列。「待核对」同时包含结果不明和资源停止待确认的意图。事实、关联漏洞统计进入全部记录的第一页,清除之前的筛选和来源定位;当前意图提供来源回执、执行会话及可访问资产的入口。这些跳转只读取记录,不触发测评执行。
|
||||
|
||||
整条测评受阻与单条意图受阻分别展示。规划器、独立验收或运行环境失败时,测评可能受阻但受阻意图数为 0;页面直接展示最近的任务级受阻事件及时间,并提供运行记录入口。该原因不会被后续执行收尾记录挤掉,旧数据没有受阻事件时沿用已保存摘要。
|
||||
|
||||
节点详情默认使用较宽的阅读栏,可拖动图与详情之间的分隔线调整宽度;键盘聚焦分隔线后,左右方向键调整,Home 或双击恢复默认宽度。「展开阅读」将当前节点铺满工作区,点击「返回图」恢复分栏。摘要、执行说明、原始回执和来源分别展示;正文独立滚动,自动刷新保留阅读位置和已展开的来源,切换节点从顶部开始。窄屏改为上下布局,也可展开阅读。
|
||||
|
||||
较大图显示缩略导航,可点击定位,也可聚焦后用方向键平移。节点类型和状态、关系颜色帮助区分链路;选中节点显示其相连关系的文字,位于画布外或缩得过小时自动定位到可读尺度。循环引用的回边保留,只在计算层级时避开,避免整组挤成单列。多个目标资产链接在正文中折叠展示,不占据固定底部操作区。全图仍按节点分页,大图概览不能保证每个节点的文字同时清晰,可选中节点或展开关联分支阅读。
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package deepassessment
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestOverviewKeepsTaskBlockerAfterWorkerCleanupAndGuidance(t *testing.T) {
|
||||
s, task := fixture(t)
|
||||
const reason = "planning failed: fixture protocol ended early"
|
||||
if err := s.Change(task.ID, "", "blocked", reason, func(v *Task) error {
|
||||
v.Status, v.Summary = "blocked", reason
|
||||
v.Steps = []Step{{ID: "done", Status: "completed"}, {ID: "pending", Status: "pending"}}
|
||||
return nil
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for i := 0; i < 12; i++ {
|
||||
if err := s.Change(task.ID, "pending", "step_result", fmt.Sprint("cleanup ", i), func(*Task) error { return nil }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
s.Change(task.ID, "", "guidance", "new direction", func(v *Task) error { v.Summary = "received new guidance"; return nil })
|
||||
got, _ := s.Get(task.ID)
|
||||
view, err := s.RuntimeOverview(got)
|
||||
if err != nil || view.Blocker == nil || view.Blocker.Message != reason || view.Counts["blocked"] != 0 {
|
||||
t.Fatal(view, err)
|
||||
}
|
||||
for _, event := range view.Recent {
|
||||
if event.Kind == "blocked" {
|
||||
t.Fatal("fixture must place the cause outside recent cleanup events")
|
||||
}
|
||||
}
|
||||
foreign := *task
|
||||
foreign.ID = "other"
|
||||
foreign.Status = "blocked"
|
||||
view, err = s.RuntimeOverview(&foreign)
|
||||
if err != nil || view.Blocker != nil {
|
||||
t.Fatal("cross-assessment blocker", view, err)
|
||||
}
|
||||
got.Status = "running"
|
||||
view, err = s.RuntimeOverview(got)
|
||||
if err != nil || view.Blocker != nil {
|
||||
t.Fatal("old blocker shown after continuation", view, err)
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ type ToolActivity struct {
|
|||
OutputBytes int64 `json:"output_bytes,omitempty"`
|
||||
}
|
||||
type RuntimeOverview struct {
|
||||
Blocker *Event `json:"blocker,omitempty"`
|
||||
Sessions map[string]SessionActivity `json:"sessions"`
|
||||
Intents []IntentActivity `json:"intents"`
|
||||
Live LivePhase `json:"live"`
|
||||
|
|
@ -65,6 +66,16 @@ func (s *Store) RecentEvents(task string, limit int) ([]Event, error) {
|
|||
// No model call, tool execution or task transition is needed to refresh the view.
|
||||
func (s *Store) RuntimeOverview(t *Task) (RuntimeOverview, error) {
|
||||
out := RuntimeOverview{Counts: map[string]int{}, Tools: []ToolActivity{}, Recent: []Event{}, AssetNames: map[string]string{}}
|
||||
if t.Status == "blocked" {
|
||||
var event Event
|
||||
err := s.DB.QueryRow("SELECT id,step_id,kind,message,created_at FROM deep_assessment_events WHERE task_id=? AND kind='blocked' ORDER BY id DESC LIMIT 1", t.ID).Scan(&event.ID, &event.StepID, &event.Kind, &event.Message, &event.CreatedAt)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return out, err
|
||||
}
|
||||
if err == nil {
|
||||
out.Blocker = &event
|
||||
}
|
||||
}
|
||||
for _, st := range t.Steps {
|
||||
out.Counts[st.Status]++
|
||||
if st.Status == "running" || st.Status == "pausing" || st.Status == "uncertain" || st.Status == "cleanup_unconfirmed" {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import { once } from "node:events";
|
||||
|
||||
export const PROTOCOL_VERSION = 1;
|
||||
export const MAX_RECORD_BYTES = 32 * 1024 * 1024;
|
||||
|
||||
|
|
@ -29,8 +27,10 @@ let writes = Promise.resolve();
|
|||
export function send(value: unknown): Promise<void> {
|
||||
const line = JSON.stringify(value) + "\n";
|
||||
if (Buffer.byteLength(line) > MAX_RECORD_BYTES) return Promise.reject(new Error("Protocol output exceeds limit"));
|
||||
writes = writes.then(async () => {
|
||||
if (!process.stdout.write(line)) await once(process.stdout, "drain");
|
||||
});
|
||||
// A true return value only means the stream accepted the data. The worker
|
||||
// exits after its final record, so wait until the underlying write completes.
|
||||
writes = writes.then(() => new Promise<void>((resolve, reject) => {
|
||||
process.stdout.write(line, error => error ? reject(error) : resolve());
|
||||
}));
|
||||
return writes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { spawn } from "node:child_process";
|
||||
import { once } from "node:events";
|
||||
|
||||
test("send waits for the write callback even below the stream high water mark", async () => {
|
||||
const child = spawn(process.execPath, ["--input-type=module", "-e", `
|
||||
import { send } from './dist/protocol.js';
|
||||
const pending = [];
|
||||
process.stdout.write = (line, callback) => { pending.push({line, callback}); return true; };
|
||||
let settled = false;
|
||||
const first = send({type:'event',text:'中文'.repeat(10000)}).then(() => { settled = true; });
|
||||
const second = send({type:'result',text:'last'});
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
if (settled || pending.length !== 1 || typeof pending[0].callback !== 'function') process.exit(2);
|
||||
pending[0].callback();
|
||||
await first;
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
if (pending.length !== 2 || !pending[1].line.endsWith('\\n')) process.exit(3);
|
||||
pending[1].callback();
|
||||
await second;
|
||||
process.exit(0);
|
||||
`], { stdio: ["ignore", "pipe", "pipe"] });
|
||||
let stderr = "";
|
||||
child.stderr.on("data", chunk => stderr += chunk);
|
||||
const [code] = await once(child, "close");
|
||||
assert.equal(code, 0, stderr || "send resolved before buffered output was flushed");
|
||||
});
|
||||
|
||||
test("a slow reader receives the complete final JSON before an immediate exit", async () => {
|
||||
const child = spawn(process.execPath, ["--input-type=module", "-e", `
|
||||
import { send } from './dist/protocol.js';
|
||||
process.stdout._writableState.highWaterMark = 8 * 1024 * 1024;
|
||||
await send({type:'result',text:'x'.repeat(4 * 1024 * 1024)});
|
||||
process.exit(0);
|
||||
`], { stdio: ["ignore", "pipe", "pipe"] });
|
||||
let stderr = "";
|
||||
child.stderr.on("data", chunk => stderr += chunk);
|
||||
const chunks = [];
|
||||
child.stdout.on("data", chunk => chunks.push(chunk));
|
||||
child.stdout.pause();
|
||||
const resume = setTimeout(() => child.stdout.resume(), 100);
|
||||
const [code] = await once(child, "close");
|
||||
clearTimeout(resume);
|
||||
assert.equal(code, 0, stderr);
|
||||
const body = Buffer.concat(chunks).toString();
|
||||
assert.ok(body.endsWith("\n"), "final JSON record was truncated");
|
||||
assert.equal(JSON.parse(body).text.length, 4 * 1024 * 1024);
|
||||
});
|
||||
|
|
@ -715,3 +715,29 @@ test('overview links remain usable for readers and empty lists explain the selec
|
|||
if(process.env.CSAI_SCREENSHOT_DIR)await page.screenshot({path:path.join(process.env.CSAI_SCREENSHOT_DIR,'overview-stat-links-mobile.png'),fullPage:true});
|
||||
assert.ok(state.requests.every(r=>r.method==='GET'));assert.deepEqual(state.errors,[]);
|
||||
});
|
||||
|
||||
test('assessment-level blocking stays visible when there are no blocked intents',async t=>{
|
||||
const {page,state}=await fixture(t),task=state.tasks.get('t0');
|
||||
task.status='blocked';task.summary='收到补充方向';task.steps=[{id:'done',title:'已完成样例',status:'completed'},{id:'pending',title:'待执行样例',status:'pending'}];
|
||||
const cause='规划失败: Pi worker exited without a result: invalid Pi protocol JSON: unexpected end of JSON input <script>window.injected=1</script>';
|
||||
task.runtime={blocker:{id:1,kind:'blocked',message:cause,created_at:new Date().toISOString()},recent:[{id:2,kind:'step_result',message:'context canceled',created_at:new Date().toISOString()}]};
|
||||
task.events=[task.runtime.blocker,...task.runtime.recent];
|
||||
await page.locator('[data-da-action="details"][data-id="t0"]').click();await page.locator('#da-task-blocker').waitFor();
|
||||
assert.match(await page.locator('#da-task-blocker').innerText(),/规划失败: Pi worker/);assert.equal(await page.locator('#da-task-blocker script').count(),0);assert.equal(await page.evaluate(()=>window.injected),undefined);
|
||||
const blocked=page.locator('.da-live-counts [data-status="blocked"]');assert.equal(await blocked.innerText(),'受阻意图 0');await blocked.click();await page.locator('#da-intent-status').waitFor();
|
||||
assert.equal(await page.locator('.da-step').count(),0);assert.match(await page.locator('#da-body').innerText(),/整条测评的原因见上方/);assert.match(await page.locator('#da-task-blocker').innerText(),/unexpected end of JSON input/);
|
||||
await page.evaluate(()=>{document.querySelector('#da-task-blocker pre').dataset.fixture='retained';});await page.evaluate(()=>DeepAssessments.refresh());assert.equal(await page.locator('#da-task-blocker pre').getAttribute('data-fixture'),'retained');
|
||||
await page.locator('#da-title [data-da-action="blocked-reason"]').click();assert.equal(await page.locator('#da-task-blocker').evaluate(el=>document.activeElement===el),true);
|
||||
await page.locator('#da-task-blocker [data-tab="activity"]').click();await page.locator('.da-event').first().waitFor();assert.match(page.url(),/tab=activity/);assert.match(await page.locator('#da-task-blocker').innerText(),/规划失败/);
|
||||
await page.reload();await page.locator('#da-task-blocker').waitFor();assert.match(await page.locator('#da-task-blocker').innerText(),/规划失败/);
|
||||
await page.setViewportSize({width:390,height:844});assert.ok(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1));
|
||||
if(process.env.CSAI_SCREENSHOT_DIR){await page.locator('#page-deep-assessments').evaluate(async el=>{await Promise.all(el.getAnimations({subtree:true}).filter(a=>a.effect?.getComputedTiming().iterations!==Infinity).map(a=>a.finished.catch(()=>{})));});await page.screenshot({path:path.join(process.env.CSAI_SCREENSHOT_DIR,'task-blocker-mobile.png'),fullPage:true});}
|
||||
task.status='running';task.revision++;await page.evaluate(()=>DeepAssessments.refresh());assert.equal(await page.locator('#da-task-blocker').isVisible(),false);
|
||||
assert.ok(state.requests.every(r=>r.method==='GET'));assert.deepEqual(state.errors,[]);
|
||||
});
|
||||
|
||||
test('older blocked assessments explain the saved summary without runtime diagnostics',async t=>{
|
||||
const {page,state}=await fixture(t),task=state.tasks.get('t0');task.status='blocked';task.summary='模型渠道不可用';
|
||||
await page.locator('[data-da-action="details"][data-id="t0"]').click();await page.locator('#da-task-blocker').waitFor();assert.match(await page.locator('#da-task-blocker').innerText(),/模型渠道不可用/);
|
||||
assert.ok(state.requests.every(r=>r.method==='GET'));assert.deepEqual(state.errors,[]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -301,6 +301,12 @@ body.da-drawer-open { overflow: hidden; }
|
|||
.da-node-actions button { font-size:13px; }
|
||||
.da-recovery-notice { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-shrink:0; margin-bottom:12px; padding:12px 14px; border:1px solid #d9770638; border-radius:8px; background:#d977060d; font-size:14px; line-height:1.65; }
|
||||
.da-recovery-notice[hidden] { display:none; }.da-recovery-notice p { margin:4px 0 0; color:var(--text-secondary); }
|
||||
.da-task-blocker { margin-bottom:16px; padding:16px; border:1px solid #d9770650; border-radius:8px; background:#d977060d; }
|
||||
.da-task-blocker[hidden] { display:none; }
|
||||
.da-task-blocker h3 { margin:0 0 8px; font-size:16px; }
|
||||
.da-task-blocker p,.da-task-blocker small { color:var(--text-secondary); font-size:13px; line-height:1.65; }
|
||||
.da-task-blocker pre { white-space:pre-wrap; overflow-wrap:anywhere; max-height:240px; overflow:auto; font-size:14px; line-height:1.65; }
|
||||
.da-task-blocker:focus-visible { outline:2px solid var(--accent-color); outline-offset:2px; }
|
||||
.da-recovery-notice button { flex-shrink:0; }.da-review-step-note { color:var(--text-secondary); font-size:13px; line-height:1.7; }
|
||||
@media(max-width:650px) { .da-recovery-notice { flex-direction:column; align-items:stretch; gap:8px; } }
|
||||
.da-node-links { margin:16px 0; font-size:13px; }
|
||||
|
|
|
|||
|
|
@ -5602,7 +5602,12 @@
|
|||
"native_idle": "Waiting for next turn",
|
||||
"lastNative": "Last activity",
|
||||
"activity": "Run history",
|
||||
"receipts": "View receipts"
|
||||
"receipts": "View receipts",
|
||||
"blockerTitle": "Assessment blocked",
|
||||
"blockerExplanation": "This is an assessment-level problem; blocked intents count individual intents only.",
|
||||
"blockerHint": "Progress and evidence are saved. Continue manually after resolving the cause.",
|
||||
"blockerUnknown": "No specific reason was recorded. Check the run history.",
|
||||
"blockedIntents": "Blocked intents"
|
||||
},
|
||||
"liveUpdates": "Updates available — view latest",
|
||||
"continueStopped": "Continue assessment",
|
||||
|
|
@ -5611,7 +5616,9 @@
|
|||
"reviewSaved": "Review recorded; pending-review list updated",
|
||||
"conflict": "The assessment changed. Refresh and try again.",
|
||||
"stepChanged": "This step executed again during review. Check its latest receipts before confirming.",
|
||||
"noMatchingSteps": "No intents match the current filters."
|
||||
"noMatchingSteps": "No intents match the current filters.",
|
||||
"noBlockedIntents": "No individual intent is blocked. See the assessment-level reason above.",
|
||||
"viewBlocker": "View blocking reason"
|
||||
},
|
||||
"assessmentFindingLinks": {
|
||||
"source": "Source assessment",
|
||||
|
|
|
|||
|
|
@ -5615,7 +5615,12 @@
|
|||
"native_idle": "Ожидание следующего хода",
|
||||
"lastNative": "Последняя активность",
|
||||
"activity": "История выполнения",
|
||||
"receipts": "Посмотреть результаты"
|
||||
"receipts": "Посмотреть результаты",
|
||||
"blockerTitle": "Оценка заблокирована",
|
||||
"blockerExplanation": "Это проблема всей оценки; счётчик учитывает только отдельные заблокированные намерения.",
|
||||
"blockerHint": "Прогресс и доказательства сохранены. После устранения причины продолжите вручную.",
|
||||
"blockerUnknown": "Причина не записана. Проверьте историю выполнения.",
|
||||
"blockedIntents": "Заблокированные намерения"
|
||||
},
|
||||
"liveUpdates": "Есть обновления — показать последние",
|
||||
"continueStopped": "Продолжить оценку",
|
||||
|
|
@ -5624,7 +5629,9 @@
|
|||
"reviewSaved": "Проверка сохранена; список обновлён",
|
||||
"conflict": "Состояние оценки изменилось. Обновите страницу и повторите.",
|
||||
"stepChanged": "Во время проверки шаг выполнялся снова. Проверьте последние результаты перед подтверждением.",
|
||||
"noMatchingSteps": "Нет намерений, соответствующих текущим фильтрам."
|
||||
"noMatchingSteps": "Нет намерений, соответствующих текущим фильтрам.",
|
||||
"noBlockedIntents": "Заблокированных намерений нет. Причина блокировки оценки указана выше.",
|
||||
"viewBlocker": "Причина блокировки"
|
||||
},
|
||||
"assessmentFindingLinks": {
|
||||
"source": "Исходная оценка",
|
||||
|
|
|
|||
|
|
@ -5542,7 +5542,12 @@
|
|||
"native_idle": "等待下一轮",
|
||||
"lastNative": "最近活动",
|
||||
"activity": "运行记录",
|
||||
"receipts": "查看回执"
|
||||
"receipts": "查看回执",
|
||||
"blockerTitle": "测评受阻原因",
|
||||
"blockerExplanation": "这是整条测评的运行问题;“受阻意图”只统计单条意图。",
|
||||
"blockerHint": "进度与证据已保存。排除原因后可手动继续。",
|
||||
"blockerUnknown": "尚未记录明确原因,请查看运行记录。",
|
||||
"blockedIntents": "受阻意图"
|
||||
},
|
||||
"graphRelations": {
|
||||
"via_archive": "经归档",
|
||||
|
|
@ -5555,7 +5560,9 @@
|
|||
"reviewSaved": "已记录核对,待核对列表已更新",
|
||||
"conflict": "测评状态已更新,请刷新后重试。",
|
||||
"stepChanged": "此步骤在核对期间发生了新的执行,请重新查看最新回执后确认。",
|
||||
"noMatchingSteps": "没有符合当前筛选条件的意图。"
|
||||
"noMatchingSteps": "没有符合当前筛选条件的意图。",
|
||||
"noBlockedIntents": "没有单条意图被标记为受阻;整条测评的原因见上方。",
|
||||
"viewBlocker": "查看受阻原因"
|
||||
},
|
||||
"assessmentFindingLinks": {
|
||||
"source": "来源深度测评",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* Live task presentation and per-intent controls. Execution stays in the host/Pi. */
|
||||
(function(){
|
||||
'use strict';
|
||||
const labels={activity:'运行记录',receipts:'查看回执',native_model:'模型处理中',native_tool:'工具处理中',native_compacting:'Pi 正在压缩上下文',native_retrying:'Pi 正在重试模型请求',native_idle:'等待下一轮',lastNative:'最近活动',live:'运行态势',planning:'规划中',reviewing:'独立验收中',executing:'执行中',scheduling:'正在调度',draining:'正在停止并收尾',waiting:'等待新进展',retrying:'等待模型恢复',nextWake:'下次唤醒',recent:'最近进展',noRecent:'暂无新进展记录',active:'当前意图',noActive:'当前没有在执行的意图',tools:'工具活动',noTools:'等待模型或下一次工具调用',facts:'事实',findings:'关联漏洞',queue:'意图队列',openStep:'查看此意图',conversation:'执行会话',pause:'暂停此意图',resume:'继续此意图',priority:'意图优先级',urgent:'优先',high:'较高',normal:'普通',low:'较低',guidance:'给此意图补充方向',targetHint:'只发送给此意图;意图暂停时保存,继续后生效。',send:'提交给此意图',lastDirection:'最近补充',manualPause:'此意图已手动暂停',brief:'目标与测评要求',route:'最近规划路线',summary:'当前结论 / 缺口',output:'已有输出',linkedAssets:'关联资产',elapsed:'已持续',min:'分钟',sec:'秒',emptyReview:'无待核对步骤'};
|
||||
const labels={blockerTitle:'测评受阻原因',blockerExplanation:'这是整条测评的运行问题;“受阻意图”只统计单条意图。',blockerHint:'进度与证据已保存。排除原因后可手动继续。',blockerUnknown:'尚未记录明确原因,请查看运行记录。',blockedIntents:'受阻意图',activity:'运行记录',receipts:'查看回执',native_model:'模型处理中',native_tool:'工具处理中',native_compacting:'Pi 正在压缩上下文',native_retrying:'Pi 正在重试模型请求',native_idle:'等待下一轮',lastNative:'最近活动',live:'运行态势',planning:'规划中',reviewing:'独立验收中',executing:'执行中',scheduling:'正在调度',draining:'正在停止并收尾',waiting:'等待新进展',retrying:'等待模型恢复',nextWake:'下次唤醒',recent:'最近进展',noRecent:'暂无新进展记录',active:'当前意图',noActive:'当前没有在执行的意图',tools:'工具活动',noTools:'等待模型或下一次工具调用',facts:'事实',findings:'关联漏洞',queue:'意图队列',openStep:'查看此意图',conversation:'执行会话',pause:'暂停此意图',resume:'继续此意图',priority:'意图优先级',urgent:'优先',high:'较高',normal:'普通',low:'较低',guidance:'给此意图补充方向',targetHint:'只发送给此意图;意图暂停时保存,继续后生效。',send:'提交给此意图',lastDirection:'最近补充',manualPause:'此意图已手动暂停',brief:'目标与测评要求',route:'最近规划路线',summary:'当前结论 / 缺口',output:'已有输出',linkedAssets:'关联资产',elapsed:'已持续',min:'分钟',sec:'秒',emptyReview:'无待核对步骤'};
|
||||
const L=k=>{const path='deepAssessments.workbench.'+k,v=window.t?.(path);return v&&v!==path?v:labels[k]||k;};
|
||||
const eventLabels={reconciled:'已确认核对',reopened:'继续已停止的测评',started:'开始/继续测评',step_started:'意图开始执行',planning:'更新计划',plan_updated:'计划已更新',checkpoint:'已保存进展',step_result:'意图执行结果',settled:'调度已结束',stop_requested:'暂停/停止请求',intent_pause:'暂停此意图',intent_resume:'意图已恢复排队',intent_priority:'优先级已调整',intent_guidance:'收到定向补充',waiting_progress:'等待新进展',waiting_retry:'等待模型恢复',waiting_input:'等待答复',blocked:'执行受阻',guidance:'收到补充方向',retry_scheduled:'稍后重试模型',review_gap:'验收仍有缺口',shutdown:'保存进度并关闭',retry:'步骤已重新排队'};
|
||||
const eventLabel=kind=>{const key='deepAssessments.workbench.events.'+kind,v=window.t?.(key);return v&&v!==key?v:eventLabels[kind]||L('recent');};
|
||||
|
|
@ -10,6 +10,11 @@
|
|||
const can=p=>typeof window.hasPermission!=='function'||window.hasPermission(p);
|
||||
const time=v=>v?new Date(v).toLocaleString():'—';
|
||||
const elapsed=v=>{const n=Math.max(0,Math.floor((Date.now()-Date.parse(v))/1000));return Number.isFinite(n)?(n>=60?Math.floor(n/60)+' '+L('min'):n+' '+L('sec')):'—';};
|
||||
function blocker(task,data){
|
||||
if(task.status!=='blocked')return '';
|
||||
const event=data?.blocker,reason=event?.message||task.summary||L('blockerUnknown');
|
||||
return `<h3>${esc(L('blockerTitle'))}</h3><p>${esc(L('blockerExplanation'))}</p><pre>${esc(reason)}</pre>${event?.created_at?`<small>${esc(time(event.created_at))}</small>`:''}<p>${esc(L('blockerHint'))}</p>${button('overview-tab',L('activity'),'data-tab="activity"')}`;
|
||||
}
|
||||
function overview(task,data,status){
|
||||
if(!data)return '';
|
||||
const live=data.live||{},counts=data.counts||{},tools=data.tools||[];
|
||||
|
|
@ -24,7 +29,7 @@
|
|||
const names=(can('asset:read')?st.asset_ids||[]:[]).filter(id=>data.asset_names?.[id]);
|
||||
return `<article class="da-live-intent"><div class="da-live-intent-head"><strong>${esc(st.title)}</strong><span class="da-badge da-${esc(st.status)}">${esc(status(st.status))}</span></div>${names.length?`<p>${names.map(id=>button('intent-asset',data.asset_names[id],`data-asset="${esc(id)}"`)).join(' ')}</p>`:(st.asset_ids||[]).length?`<p class="da-muted">${L('linkedAssets')} · ${st.asset_ids.length}</p>`:''}${native?.stage?`<p class="da-live-native">${esc(L('native_'+native.stage))}${native.tool?' · '+esc(native.tool):''} · ${esc(L('lastNative'))} ${esc(time(native.updated_at))}</p>`:''}<div class="da-live-tools">${activity.length?activity.map(call=>`<p><code>${esc(call.tool)}</code> · ${esc(status(call.status==='queued'?'pending':call.status))} · ${esc(L('elapsed'))} <span class="da-live-age" data-started="${esc(call.started_at)}">${esc(elapsed(call.started_at))}</span>${call.output_bytes?` · ${esc(L('output'))} ${Math.ceil(call.output_bytes/1024)} KB`:''}</p>`).join(''):native?.stage?'':`<p class="da-muted">${esc(L('noTools'))}</p>`}</div>${st.summary?`<p class="da-live-summary">${esc(st.summary)}</p>`:''}<div class="da-controls">${button('show-step',L('openStep'),`data-step="${esc(st.id)}"`)}${button('fact-proof',L('receipts'),`data-step="${esc(st.id)}"`)}${st.conversation_id&&can('chat:read')?button('conversation',L('conversation'),`data-conversation="${esc(st.conversation_id)}"`):''}</div></article>`;
|
||||
}).join('');
|
||||
return `<section class="da-live-board"><div class="da-live-heading"><h3>${esc(L('live'))}</h3><strong>${esc(phase)}</strong>${task.next_wake?`<span>${esc(L('nextWake'))}:${esc(time(task.next_wake))}</span>`:''}</div><div class="da-live-counts">${button('queue-status',L('queue')+' '+total,'data-status=""')}${visible.map(k=>button('queue-status',status(k)+' '+(k==='needs_review'?review:counts[k]||0),`data-status="${k}"`)).join('')}${button('overview-tab',L('facts')+' '+(data.facts||0),'data-tab="facts"')}${data.findings_visible&&can('vulnerability:read')?button('overview-tab',L('findings')+' '+(data.findings||0),'data-tab="findings"'):''}</div><h4>${esc(L('active'))}</h4><div class="da-live-intents">${cards||`<p class="da-muted">${esc(L('noActive'))}</p>`}</div><div class="da-live-section-title"><h4>${esc(L('recent'))}</h4>${button('overview-tab',L('activity'),'data-tab="activity"')}</div><div class="da-live-events">${(data.recent||[]).map(event=>`<article><small>${esc(time(event.created_at))} · ${esc(eventLabel(event.kind))}</small><p>${esc(event.message)}</p>${event.step_id?button('show-step',L('openStep'),`data-step="${esc(event.step_id)}"`):''}</article>`).join('')||`<p class="da-muted">${esc(L('noRecent'))}</p>`}</div></section>`;
|
||||
return `<section class="da-live-board"><div class="da-live-heading"><h3>${esc(L('live'))}</h3><strong>${esc(phase)}</strong>${task.next_wake?`<span>${esc(L('nextWake'))}:${esc(time(task.next_wake))}</span>`:''}</div><div class="da-live-counts">${button('queue-status',L('queue')+' '+total,'data-status=""')}${visible.map(k=>button('queue-status',(k==='blocked'?L('blockedIntents'):status(k))+' '+(k==='needs_review'?review:counts[k]||0),`data-status="${k}"`)).join('')}${button('overview-tab',L('facts')+' '+(data.facts||0),'data-tab="facts"')}${data.findings_visible&&can('vulnerability:read')?button('overview-tab',L('findings')+' '+(data.findings||0),'data-tab="findings"'):''}</div><h4>${esc(L('active'))}</h4><div class="da-live-intents">${cards||`<p class="da-muted">${esc(L('noActive'))}</p>`}</div><div class="da-live-section-title"><h4>${esc(L('recent'))}</h4>${button('overview-tab',L('activity'),'data-tab="activity"')}</div><div class="da-live-events">${(data.recent||[]).map(event=>`<article><small>${esc(time(event.created_at))} · ${esc(eventLabel(event.kind))}</small><p>${esc(event.message)}</p>${event.step_id?button('show-step',L('openStep'),`data-step="${esc(event.step_id)}"`):''}</article>`).join('')||`<p class="da-muted">${esc(L('noRecent'))}</p>`}</div></section>`;
|
||||
}
|
||||
function controls(step,task,write,draft){
|
||||
if(!write||task.archived||['completed','cancelled'].includes(task.status)||['completed','retired'].includes(step.status))return '';
|
||||
|
|
@ -36,5 +41,5 @@
|
|||
actions+=`<label>${esc(L('priority'))}<select class="form-control" data-da-intent-priority="${esc(step.id)}" aria-label="${esc(L('priority'))}" ${busy?'disabled':''}>${options.sort((a,b)=>a-b).map(p=>`<option value="${p}" ${p===priority?'selected':''}>${p} · ${esc(({1:L('urgent'),10:L('high'),100:L('normal'),500:L('low')})[p]||p)}</option>`).join('')}</select></label>`;
|
||||
return `<section class="da-intent-controls"><div class="da-controls">${actions}</div>${step.user_paused?`<p class="da-muted">${esc(L('manualPause'))}</p>`:''}<details data-da-detail="intent-guidance:${esc(step.id)}"><summary>${esc(L('guidance'))}</summary><p class="da-muted">${esc(L('targetHint'))}</p>${step.guidance?.length?`<p>${esc(L('lastDirection'))}:${esc(step.guidance.at(-1))}</p>`:''}<form data-da-intent-guidance="${esc(step.id)}"><textarea class="form-control" aria-label="${esc(L('guidance'))}" rows="3" maxlength="8000" required>${esc(draft||'')}</textarea><button type="submit" class="btn-secondary" ${busy?'disabled':''}>${esc(L('send'))}</button></form></details></section>`;
|
||||
}
|
||||
window.AssessmentWorkbench={overview,controls,text:L,refreshClocks(root){root.querySelectorAll('.da-live-age').forEach(el=>el.textContent=elapsed(el.dataset.started));}};
|
||||
window.AssessmentWorkbench={blocker,overview,controls,text:L,refreshClocks(root){root.querySelectorAll('.da-live-age').forEach(el=>el.textContent=elapsed(el.dataset.started));}};
|
||||
})();
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -50,7 +50,7 @@
|
|||
<link rel="stylesheet" href="/static/css/vulnerability-workspace.css?v=20261115-stable-height">
|
||||
<link rel="stylesheet" href="/static/css/vulnerability-list.css?v=20261115-timestamps">
|
||||
<script src="/static/js/router.js?v=20261114-assessment-links"></script>
|
||||
<link rel="stylesheet" href="/static/css/deep-assessments.css?v=20261115-overview-links">
|
||||
<link rel="stylesheet" href="/static/css/deep-assessments.css?v=20261115-blocked-reason">
|
||||
<link rel="stylesheet" href="/static/css/design-system.css?v=20261115-extra-drawers">
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -7141,11 +7141,11 @@
|
|||
<script src="/static/js/vulnerability-download.js?v=20261030-2"></script>
|
||||
<script src="/static/js/webshell.js?v=20261011-token-usage-tool-title"></script>
|
||||
<script src="/static/js/chat-files.js?v=20261103-personal-integration"></script>
|
||||
<script src="/static/js/assessment-workbench.js?v=20261115-overview-links"></script>
|
||||
<script src="/static/js/assessment-workbench.js?v=20261115-blocked-reason"></script>
|
||||
<script src="/static/js/assessment-node-panel.js?v=20261115-graph-live-fixes"></script>
|
||||
<script src="/static/js/assessment-exploration-views.js?v=20261115-overview-links"></script>
|
||||
<script src="/static/js/deep-assessment-graph.js?v=20261115-workbench"></script>
|
||||
<script src="/static/js/deep-assessments.js?v=20261115-overview-links"></script>
|
||||
<script src="/static/js/deep-assessments.js?v=20261115-blocked-reason"></script>
|
||||
<script src="/static/js/tasks.js?v=20261115-queue-label-contrast"></script>
|
||||
<script src="/static/js/workflow-package-client.js"></script>
|
||||
<script src="/static/js/workflows.js"></script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue