From 8bd86ba633b51ff0c912409a6ea52d50685f4e5c Mon Sep 17 00:00:00 2001 From: Sycun <165354365+Sycun@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:28:49 +0800 Subject: [PATCH] fix(tasks): allow refreshing step inspectors before retrying --- scripts/task-pagination-browser.test.cjs | 9 +++++++++ web/static/i18n/en-US.json | 3 ++- web/static/i18n/ru-RU.json | 3 ++- web/static/i18n/zh-CN.json | 3 ++- web/static/js/long-tasks.js | 13 ++++++++++++- web/static/js/task-checklist-view.js | 3 ++- web/templates/index.html | 10 +++++----- 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/scripts/task-pagination-browser.test.cjs b/scripts/task-pagination-browser.test.cjs index 3c14d908..90e546d1 100644 --- a/scripts/task-pagination-browser.test.cjs +++ b/scripts/task-pagination-browser.test.cjs @@ -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'); +}); diff --git a/web/static/i18n/en-US.json b/web/static/i18n/en-US.json index dd25bacb..d77e21f2 100644 --- a/web/static/i18n/en-US.json +++ b/web/static/i18n/en-US.json @@ -5388,6 +5388,7 @@ "guidanceAndEvents": "Guidance and activity", "loading": "Loading…", "result": "Execution result", - "error": "Error" + "error": "Error", + "refreshDetail": "Refresh details" } } diff --git a/web/static/i18n/ru-RU.json b/web/static/i18n/ru-RU.json index d2771c03..616776ff 100644 --- a/web/static/i18n/ru-RU.json +++ b/web/static/i18n/ru-RU.json @@ -5401,6 +5401,7 @@ "guidanceAndEvents": "Указания и события", "loading": "Загрузка…", "result": "Результат выполнения", - "error": "Ошибка" + "error": "Ошибка", + "refreshDetail": "Обновить сведения" } } diff --git a/web/static/i18n/zh-CN.json b/web/static/i18n/zh-CN.json index ac76d9e5..bf212c1f 100644 --- a/web/static/i18n/zh-CN.json +++ b/web/static/i18n/zh-CN.json @@ -5376,6 +5376,7 @@ "guidanceAndEvents": "补充方向与任务动态", "loading": "正在加载…", "result": "执行结果", - "error": "错误信息" + "error": "错误信息", + "refreshDetail": "刷新详情" } } diff --git a/web/static/js/long-tasks.js b/web/static/js/long-tasks.js index e390da8a..8d179abd 100644 --- a/web/static/js/long-tasks.js +++ b/web/static/js/long-tasks.js @@ -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)}
${esc(step.title)}
${esc(step.instruction)}
${esc((step.depends_on||[]).join(', ')||tr('independent'))}
${esc(step.summary||tr('noResult'))}`,`${step.conversation_id?`${esc(tr('trace'))}`:''}${retry?``:''}`);
+ const dialog=V.openDrawer(tr('stepDetail'),`${badge(step.status)}${esc(step.title)}
${esc(step.instruction)}
${esc((step.depends_on||[]).join(', ')||tr('independent'))}
${esc(step.summary||tr('noResult'))}`,`${step.conversation_id?`${esc(tr('trace'))}`:''}${retry?``:''}`);
+ 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(); }
diff --git a/web/static/js/task-checklist-view.js b/web/static/js/task-checklist-view.js
index cb9670b0..2baf5699 100644
--- a/web/static/js/task-checklist-view.js
+++ b/web/static/js/task-checklist-view.js
@@ -56,12 +56,13 @@
const editable=batchQueueAllowsSubtaskMutation(queue)&&task.status!=='running';
dialog.querySelector('.task-inspector-body').innerHTML=`${V.esc(task.message)}
${task.startedAt?`${V.esc(new Date(task.startedAt).toLocaleString())}
`:''}${task.completedAt?`${V.esc(new Date(task.completedAt).toLocaleString())}
`:''}${V.esc(task.result||V.tr('noResult'))}${task.error?`${V.esc(task.error)}`:''}${V.esc(error.message)}
`;} } 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'; diff --git a/web/templates/index.html b/web/templates/index.html index 08841c89..68e42b28 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -50,7 +50,7 @@ - +