1+ /** Resolves cron delivery and failure-notification routing from job config. */
12import {
23 normalizeLowercaseStringOrEmpty ,
34 normalizeOptionalLowercaseString ,
@@ -42,6 +43,8 @@ function resolveAnnounceChannel(params: {
4243 if ( params . channel && params . channel !== "last" ) {
4344 return params . channel ;
4445 }
46+ // A prefixed recipient like "slack:C123" is enough to infer the channel when
47+ // the cron config intentionally leaves channel at "last" or unset.
4548 return (
4649 ( resolveTargetPrefixedChannel ( params . to ) as CronMessageChannel | undefined ) ??
4750 params . channel ??
@@ -101,6 +104,8 @@ export function resolveCronDeliveryPlan(job: CronJob): CronDeliveryPlan {
101104 ( job . sessionTarget === "isolated" ||
102105 job . sessionTarget === "current" ||
103106 job . sessionTarget . startsWith ( "session:" ) ) ;
107+ // Isolated/current/session cron jobs default to announce delivery so their
108+ // output reaches the initiating session unless the job opts out.
104109 const resolvedMode = isIsolatedAgentTurn ? "announce" : "none" ;
105110
106111 return {
@@ -196,6 +201,7 @@ export function resolveFailureDestination(
196201
197202 const resolvedMode = mode ?? "announce" ;
198203 if ( resolvedMode === "webhook" && ! to ) {
204+ // Webhook failure destinations are only useful with a concrete URL/target.
199205 return null ;
200206 }
201207
@@ -207,6 +213,7 @@ export function resolveFailureDestination(
207213 } ;
208214
209215 if ( delivery && isSameDeliveryTarget ( delivery , result ) ) {
216+ // Avoid sending the same failure text through the primary delivery route twice.
210217 return null ;
211218 }
212219
0 commit comments