fix(assistant): close review gaps in delivery and action recovery

Address PR4 comments 66-69 with safe delivery retries, capacity stops, preserved effect evidence and stale proposal rejection. Prevent archived queue snapshots from resurrecting cancelled reminders.
This commit is contained in:
abaishu0730 committed 2026-10-29 11:51:03 +08:00
1 parent 1d5dcead84
commit 5ceffb935a
24 files changed
+1425 -125

No files matched your search

+40 -3
View File
@@ -21,14 +21,31 @@ window.AssistantSchedules = {
visible = false,
tasks = [],
history = [],
conversations = [],
timer = null,
loading = false,
lastSignature = '';
const root = host.closest('.assistant-workspace');
host.innerHTML =
'<h3>定时任务</h3><p class="small text-secondary">使用 DSH 原生调度,在原会话中定时调用模型。关闭页面后仍可运行,服务停止期间不会调用模型。</p><div class="btn-list"><button type="button" class="btn btn-primary btn-sm" data-schedule-new>新建定时任务</button><button type="button" class="btn btn-sm" data-schedule-refresh>刷新任务</button></div><p role="alert" class="small text-danger" data-schedule-error></p><div data-schedule-tasks></div><h4 class="mt-3">最近调用</h4><div data-schedule-history></div>';
'<h3>定时任务</h3><p class="small text-secondary">使用 DSH 原生调度,在原会话中定时调用模型。关闭页面后仍可运行,服务停止期间不会调用模型。</p><div class="btn-list"><button type="button" class="btn btn-primary btn-sm" data-schedule-new>新建定时任务</button><button type="button" class="btn btn-sm" data-schedule-refresh>刷新任务</button></div><p role="alert" class="small text-danger" data-schedule-error></p><div data-schedule-recovery></div><div data-schedule-tasks></div><h4 class="mt-3">最近调用</h4><div data-schedule-history></div>';
const error = host.querySelector('[data-schedule-error]'),
create = host.querySelector('[data-schedule-new]');
const recovery = window.AssistantScheduleRecovery.mount(
host.querySelector('[data-schedule-recovery]'),
{
root,
api,
esc,
formatDate,
user,
isActive,
getConversations: () => conversations,
onChanged: async (id) => {
await onChanged(id);
await refresh();
},
},
);
const writable = () =>
user.role !== 'viewer' && !getConversation()?.archived && !getConversation()?.deletedAt;
function timing(t) {
@@ -45,6 +62,7 @@ window.AssistantSchedules = {
}
function draw() {
create.disabled = busy || !writable();
recovery.update(history);
const signature = JSON.stringify([tasks, history, busy, writable()]);
if (signature === lastSignature) return;
lastSignature = signature;
@@ -60,12 +78,17 @@ window.AssistantSchedules = {
esc(
t.status === 'active'
? '下次触发:' + formatDate(t.scheduledAt)
: '已触发(不再重复)',
: t.status === 'inactive'
? '已触发(不再重复)'
: window.AssistantScheduleRecovery.taskStatus(t.status),
) +
'</p><p class="aw-schedule-prompt">' +
esc(t.prompt) +
'</p>' +
(t.lastError ? '<p class="text-danger">' + esc(t.lastError) + '</p>' : '') +
(t.capacityWarning
? '<p class="text-warning small">' + esc(t.capacityWarning) + '</p>'
: '') +
'<div class="btn-list"><button type="button" class="btn btn-sm" data-schedule-edit="' +
esc(t.id) +
'" aria-label="编辑任务 ' +
@@ -95,6 +118,8 @@ window.AssistantSchedules = {
running: '正在调用',
success: '已回复',
error: '调用失败',
not_started: '尚未调用',
waiting_capacity: '等待选择其他会话',
cancelled: '已取消',
needs_review: '待核实',
}[h.status] || h.status,
@@ -128,6 +153,7 @@ window.AssistantSchedules = {
if (disposed || !isActive() || id !== cid || at !== generation) return;
tasks = data.tasks;
history = data.history;
conversations = data.conversations || [];
error.textContent = data.error || '';
draw();
} catch (e) {
@@ -362,7 +388,17 @@ window.AssistantSchedules = {
let body = { confirm: true, request },
url = '/assistant/conversations/' + owner + '/schedules';
if (task) {
const { sessionId, status, lastDelivery, lastError, ...expected } = task;
const {
sessionId,
status,
lastDelivery,
lastError,
turnCount,
remainingTurns,
maxTurns,
capacityWarning,
...expected
} = task;
const changes = { title: request.title, prompt: request.prompt };
if (timingChanged) changes.change = { kind: fields.kind.value, ...selector() };
body = { confirm: true, expected, changes };
@@ -432,6 +468,7 @@ window.AssistantSchedules = {
},
dispose() {
disposed = true;
recovery.dispose();
generation++;
clearInterval(timer);
},