@@ -2,7 +2,6 @@ import { afterEach, describe, expect, it, vi } from "vitest";
22import { runOpenClawStateWriteTransaction } from "../../state/openclaw-state-db.js" ;
33import { getDetachedTaskLifecycleRuntime } from "../../tasks/detached-task-runtime.js" ;
44import * as taskExecutor from "../../tasks/task-executor.js" ;
5- import { finalizeTaskRunByRunIdCore } from "../../tasks/task-executor.js" ;
65import * as taskRegistry from "../../tasks/task-registry.js" ;
76import { markTaskLostById } from "../../tasks/task-registry.js" ;
87import { listTaskRegistryRecordsByRuntimeSourceIdFromSqlite } from "../../tasks/task-registry.store.sqlite.js" ;
@@ -412,7 +411,7 @@ describe("cron task run terminal records", () => {
412411 ) ;
413412 } ) ;
414413
415- it ( "keeps operator cancellation while attaching terminal run history " , async ( ) => {
414+ it ( "keeps operator cancellation reason when webhook delivery is interrupted " , async ( ) => {
416415 await withOpenClawTestState (
417416 { layout : "state-only" , prefix : "openclaw-cron-cancelled-task-" } ,
418417 async ( ) => {
@@ -443,13 +442,12 @@ describe("cron task run terminal records", () => {
443442 if ( ! taskRunId ) {
444443 throw new Error ( "expected cron task run id" ) ;
445444 }
446- finalizeTaskRunByRunIdCore ( {
445+ taskExecutor . finalizeTaskRunByRunIdCore ( {
447446 runId : taskRunId ,
448447 runtime : "cron" ,
449448 status : "cancelled" ,
450449 endedAt : startedAt + 50 ,
451- error : "cancelled by operator" ,
452- terminalSummary : "Cancelled by operator." ,
450+ error : "Cancelled by operator." ,
453451 } ) ;
454452
455453 tryFinishCronTaskRun ( state , {
@@ -460,6 +458,9 @@ describe("cron task run terminal records", () => {
460458 action : "finished" ,
461459 job,
462460 status : "ok" ,
461+ summary : "payload complete" ,
462+ delivered : false ,
463+ deliveryError : "cron webhook delivery cancelled: Cancelled by operator." ,
463464 runAtMs : startedAt ,
464465 durationMs : 100 ,
465466 } ,
@@ -472,9 +473,9 @@ describe("cron task run terminal records", () => {
472473 expect ( row ) . toMatchObject ( {
473474 status : "cancelled" ,
474475 endedAt : startedAt + 100 ,
476+ error : "Cancelled by operator." ,
475477 detail : { kind : "cron-run" , status : "ok" , durationMs : 100 } ,
476478 } ) ;
477- expect ( row ?. error ) . toBeUndefined ( ) ;
478479 expect ( row ?. terminalSummary ) . toBeUndefined ( ) ;
479480 expect (
480481 readCronTaskRunHistoryPage ( {
@@ -486,6 +487,9 @@ describe("cron task run terminal records", () => {
486487 jobId : job . id ,
487488 status : "ok" ,
488489 error : undefined ,
490+ summary : "payload complete" ,
491+ delivered : false ,
492+ deliveryError : "cron webhook delivery cancelled: Cancelled by operator." ,
489493 } ) ,
490494 ] ) ;
491495 } ,
@@ -810,7 +814,7 @@ describe("cron task run terminal records", () => {
810814 } ) ,
811815 ) ;
812816 expect ( recovery . taskRunId ) . toBe ( legacyRunId ) ;
813- finalizeTaskRunByRunIdCore ( {
817+ taskExecutor . finalizeTaskRunByRunIdCore ( {
814818 runId : legacyRunId ,
815819 runtime : "cron" ,
816820 status : "timed_out" ,
0 commit comments