fix(tasks): allow refreshing step inspectors before retrying

This commit is contained in:
Sycun 2026-11-13 23:28:49 +08:00
parent 310007fab3
commit 8bd86ba633
7 changed files with 34 additions and 10 deletions

View File

@ -86,3 +86,12 @@ test('new parent rows above the viewport preserve the visible reading anchor',as
const y=await page.locator('#lt-list').evaluate((root,id)=>[...root.children].find(row=>row.dataset.recordId===id).getBoundingClientRect().top,anchor.id);
assert.ok(Math.abs(y-anchor.y)<2,`reading anchor moved from ${anchor.y} to ${y}`);
});
test('a stale step snapshot can be refreshed explicitly before retry',async t=>{
const {page,state,select,refresh}=await fixture(t);await select('a');await page.locator('#lt-steps [data-record-open=s1]').first().click();
state.tasks.get('a').revision++;state.tasks.get('a').steps[0].summary='New checked result';await refresh();
await page.locator('[data-step-retry]').click();await page.waitForFunction(()=>document.querySelector('[data-step-error]').textContent.includes('revision conflict'));
await page.locator('[data-step-refresh]').click();await page.waitForFunction(()=>document.querySelector('.task-inspector-body').textContent.includes('New checked result'));
await page.locator('[data-step-retry]').click();await page.locator('#task-step-inspector').waitFor({state:'detached'});assert.equal(state.tasks.get('a').steps[0].status,'pending');
});

View File

@ -5388,6 +5388,7 @@
"guidanceAndEvents": "Guidance and activity",
"loading": "Loading…",
"result": "Execution result",
"error": "Error"
"error": "Error",
"refreshDetail": "Refresh details"
}
}

View File

@ -5401,6 +5401,7 @@
"guidanceAndEvents": "Указания и события",
"loading": "Загрузка…",
"result": "Результат выполнения",
"error": "Ошибка"
"error": "Ошибка",
"refreshDetail": "Обновить сведения"
}
}

View File

@ -5376,6 +5376,7 @@
"guidanceAndEvents": "补充方向与任务动态",
"loading": "正在加载…",
"result": "执行结果",
"error": "错误信息"
"error": "错误信息",
"refreshDetail": "刷新详情"
}
}

View File

@ -81,7 +81,18 @@
const step=task.steps.find(item=>item.id===id);if(!step)return;
const terminal=['completed','cancelled'].includes(task.status);
const retry=writable()&&!terminal&&!active(task)&&['failed','blocked','interrupted','cleanup_unconfirmed'].includes(step.status);
const dialog=V.openDrawer(tr('stepDetail'),`${badge(step.status)}<h4>${esc(tr('taskContent'))}</h4><p>${esc(step.title)}</p><h4>${esc(tr('instruction'))}</h4><p>${esc(step.instruction)}</p><h4>${esc(tr('depends'))}</h4><p>${esc((step.depends_on||[]).join(', ')||tr('independent'))}</p><h4>${esc(tr('result'))}</h4><pre>${esc(step.summary||tr('noResult'))}</pre><p class="lt-form-error" data-step-error hidden></p>`,`${step.conversation_id?`<a class="btn-secondary" href="#chat?conversation=${encodeURIComponent(step.conversation_id)}">${esc(tr('trace'))}</a>`:''}${retry?`<button type="button" class="btn-primary" data-step-retry>${esc(tr('retry'))}</button>`:''}`);
const dialog=V.openDrawer(tr('stepDetail'),`${badge(step.status)}<h4>${esc(tr('taskContent'))}</h4><p>${esc(step.title)}</p><h4>${esc(tr('instruction'))}</h4><p>${esc(step.instruction)}</p><h4>${esc(tr('depends'))}</h4><p>${esc((step.depends_on||[]).join(', ')||tr('independent'))}</p><h4>${esc(tr('result'))}</h4><pre>${esc(step.summary||tr('noResult'))}</pre><p class="lt-form-error" data-step-error hidden></p>`,`${step.conversation_id?`<a class="btn-secondary" href="#chat?conversation=${encodeURIComponent(step.conversation_id)}">${esc(tr('trace'))}</a>`:''}<button type="button" class="btn-secondary" data-step-refresh>${esc(tr('refreshDetail'))}</button>${retry?`<button type="button" class="btn-primary" data-step-retry>${esc(tr('retry'))}</button>`:''}`);
dialog.querySelector('[data-step-refresh]').addEventListener('click',async event=>{
event.target.disabled=true;
try {
const data=await api('/'+encodeURIComponent(task.id));
if(!dialog.isConnected||!dialog.open||!current(task))return;
const scroll=dialog.querySelector('.task-inspector-body').scrollTop;
state.task=data.task;renderTask();openStep(data.task,id);
document.querySelector('#task-step-inspector .task-inspector-body')?.scrollTo(0,scroll);
}catch(error){if(dialog.isConnected){const box=dialog.querySelector('[data-step-error]');box.hidden=false;box.textContent=error.message;}}
finally{if(event.target.isConnected)event.target.disabled=false;}
});
dialog.querySelector('[data-step-retry]')?.addEventListener('click',async event=>{
if(!confirm(tr('retryConfirm')))return;event.target.disabled=true;
try { const data=await control('retry',{step_id:id,cleanup_confirmed:true},task);if(data&&dialog.isConnected)V.closeDrawer(); }

View File

@ -56,12 +56,13 @@
const editable=batchQueueAllowsSubtaskMutation(queue)&&task.status!=='running';
dialog.querySelector('.task-inspector-body').innerHTML=`<div data-task-overview><span class="lt-status lt-status-${V.esc(task.status)}">${V.esc(V.tr('status.'+task.status))}</span><h4>${V.esc(V.tr('taskContent'))}</h4><p>${V.esc(task.message)}</p>${task.startedAt?`<h4>${V.esc(_t('batchQueueDetailModal.startLabel'))}</h4><p>${V.esc(new Date(task.startedAt).toLocaleString())}</p>`:''}${task.completedAt?`<h4>${V.esc(_t('batchQueueDetailModal.completeLabel'))}</h4><p>${V.esc(new Date(task.completedAt).toLocaleString())}</p>`:''}<h4>${V.esc(V.tr('result'))}</h4><pre>${V.esc(task.result||V.tr('noResult'))}</pre>${task.error?`<h4>${V.esc(V.tr('error'))}</h4><pre>${V.esc(task.error)}</pre>`:''}</div><form data-task-editor hidden><label>${V.esc(V.tr('taskContent'))}<textarea name="message" required>${V.esc(task.message)}</textarea></label><div class="lt-actions"><button class="btn-primary" type="submit">${V.esc(V.tr('save'))}</button><button type="button" class="btn-secondary" data-checklist-action="cancel-edit">${V.esc(V.tr('cancelEdit'))}</button></div></form><p class="lt-form-error" data-inspector-error role="alert" hidden></p>`;
dialog.querySelector('.task-inspector-actions').hidden=false;
dialog.querySelector('.task-inspector-actions').innerHTML=`${task.conversationId&&allowed('chat:read')?`<button type="button" class="btn-secondary" data-checklist-action="conversation">${V.esc(V.tr('trace'))}</button>`:''}${allowed('tasks:write')&&batchQueueCanRunSingleTask(queue,task)?`<button type="button" class="btn-primary" data-checklist-action="run">${V.esc(_t('tasks.runSingleTask'))}</button>`:''}${editable&&allowed('tasks:write')?`<button type="button" class="btn-secondary" data-checklist-action="edit">${V.esc(_t('common.edit'))}</button>`:''}${editable&&allowed('tasks:delete')?`<button type="button" class="btn-secondary btn-delete" data-checklist-action="delete">${V.esc(V.tr('delete'))}</button>`:''}`;
dialog.querySelector('.task-inspector-actions').innerHTML=`<button type="button" class="btn-secondary" data-checklist-action="refresh">${V.esc(V.tr('refreshDetail'))}</button>${task.conversationId&&allowed('chat:read')?`<button type="button" class="btn-secondary" data-checklist-action="conversation">${V.esc(V.tr('trace'))}</button>`:''}${allowed('tasks:write')&&batchQueueCanRunSingleTask(queue,task)?`<button type="button" class="btn-primary" data-checklist-action="run">${V.esc(_t('tasks.runSingleTask'))}</button>`:''}${editable&&allowed('tasks:write')?`<button type="button" class="btn-secondary" data-checklist-action="edit">${V.esc(_t('common.edit'))}</button>`:''}${editable&&allowed('tasks:delete')?`<button type="button" class="btn-secondary btn-delete" data-checklist-action="delete">${V.esc(V.tr('delete'))}</button>`:''}`;
}catch(error){if(current())dialog.querySelector('.task-inspector-body').innerHTML=`<p role="alert" class="lt-form-error">${V.esc(error.message)}</p>`;}
}
dialog.addEventListener('click',async event=>{
const button=event.target.closest('[data-checklist-action]');if(!button||busy||!task)return;
const action=button.dataset.checklistAction;
if(action==='refresh'){busy=true;button.disabled=true;const restore=V.captureScroll(dialog);try{await load();restore();}finally{busy=false;if(button.isConnected)button.disabled=false;}return;}
if(action==='edit'||action==='cancel-edit'){
dialog.querySelector('[data-task-overview]').hidden=action==='edit';dialog.querySelector('[data-task-editor]').hidden=action!=='edit';
dialog.querySelector('.task-inspector-actions').hidden=action==='edit';

View File

@ -50,7 +50,7 @@
<link rel="stylesheet" href="/static/css/vulnerability-workspace.css?v=20261113-aligned-overview">
<link rel="stylesheet" href="/static/css/vulnerability-list.css?v=20261113-compact-rows">
<script src="/static/js/router.js?v=20261011-token-settings"></script>
<link rel="stylesheet" href="/static/css/long-tasks.css?v=20261113-task-rows">
<link rel="stylesheet" href="/static/css/long-tasks.css?v=20261113-task-rows-2">
</head>
<body>
<div id="login-overlay" class="login-overlay" style="display: none;">
@ -7158,10 +7158,10 @@
<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/task-list-view.js?v=20261113-task-rows"></script>
<script src="/static/js/tasks.js?v=20261113-task-rows"></script>
<script src="/static/js/task-checklist-view.js?v=20261113-task-rows"></script>
<script src="/static/js/long-tasks.js?v=20261113-task-rows"></script>
<script src="/static/js/task-list-view.js?v=20261113-task-rows-2"></script>
<script src="/static/js/tasks.js?v=20261113-task-rows-2"></script>
<script src="/static/js/task-checklist-view.js?v=20261113-task-rows-2"></script>
<script src="/static/js/long-tasks.js?v=20261113-task-rows-2"></script>
<script src="/static/js/workflow-package-client.js"></script>
<script src="/static/js/workflows.js"></script>
<script src="/static/js/update.js?v={{.Version}}-update-status"></script>