Skip to content

Commit 819f855

Browse files
committed
fix(macos): keep cron routing inventory stable
1 parent 6f229ea commit 819f855

2 files changed

Lines changed: 24 additions & 28 deletions

File tree

‎apps/macos/Sources/OpenClaw/CronModels.swift‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,9 @@ enum CronDeliveryMode: String, CaseIterable, Identifiable, Codable {
5757

5858
struct CronDelivery: Codable, Equatable {
5959
var mode: CronDeliveryMode
60-
var channel: String?
61-
var to: String?
62-
var bestEffort: Bool?
63-
// The Gateway owns validation for these heterogeneous routing values. Keep
64-
// their exact JSON representation so native edits do not erase them.
65-
// Defaults keep ordinary delivery construction terse while exposing the fields when needed.
66-
// swiftlint:disable implicit_optional_initialization
67-
var threadId: AnyCodable? = nil
68-
var completionDestination: [String: AnyCodable]? = nil
69-
var failureDestination: [String: AnyCodable]? = nil
70-
// swiftlint:enable implicit_optional_initialization
60+
var channel: String?, to: String?, bestEffort: Bool?, threadId: AnyCodable?
61+
/// Preserve Gateway-validated destination objects exactly so native edits cannot erase routing state.
62+
var completionDestination: [String: AnyCodable]?, failureDestination: [String: AnyCodable]?
7163
}
7264

7365
enum CronSchedule: Codable, Equatable {

‎apps/macos/Sources/OpenClaw/CronSettings+Rows.swift‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ extension CronSettings {
231231
if let thinking, !thinking.isEmpty { StatusPill(text: "think \(thinking)", tint: .secondary) }
232232
if let timeoutSeconds { StatusPill(text: "\(timeoutSeconds)s", tint: .secondary) }
233233
if job.supportsAnnounceDelivery {
234-
let delivery = job.delivery
235-
if let delivery {
234+
if let delivery = job.delivery {
235+
self.advancedDeliveryPills(delivery)
236236
if delivery.mode == .announce {
237237
StatusPill(text: "announce", tint: .secondary)
238238
if let channel = delivery.channel, !channel.isEmpty {
@@ -242,21 +242,6 @@ extension CronSettings {
242242
} else {
243243
StatusPill(text: "no delivery", tint: .secondary)
244244
}
245-
if let threadId = delivery.threadId?.value {
246-
StatusPill.verbatim(
247-
"threadId \(String(describing: threadId))",
248-
tint: .secondary)
249-
}
250-
if let to = delivery.completionDestination?["to"]?.value as? String {
251-
StatusPill.verbatim("completionDestination \(to)", tint: .secondary)
252-
}
253-
if let failure = delivery.failureDestination {
254-
let target = failure["to"]?.value as? String
255-
?? failure["channel"]?.value as? String
256-
?? failure["accountId"]?.value as? String
257-
let suffix = target.map { " \($0)" } ?? ""
258-
StatusPill.verbatim("failureDestination" + suffix, tint: .secondary)
259-
}
260245
}
261246
}
262247
}
@@ -286,4 +271,23 @@ extension CronSettings {
286271
}
287272
}
288273
}
274+
275+
@ViewBuilder
276+
private func advancedDeliveryPills(_ delivery: CronDelivery) -> some View {
277+
if let threadId = delivery.threadId?.value {
278+
StatusPill.verbatim(
279+
"threadId \(String(describing: threadId))",
280+
tint: .secondary)
281+
}
282+
if let to = delivery.completionDestination?["to"]?.value as? String {
283+
StatusPill.verbatim("completionDestination \(to)", tint: .secondary)
284+
}
285+
if let failure = delivery.failureDestination {
286+
let target = failure["to"]?.value as? String
287+
?? failure["channel"]?.value as? String
288+
?? failure["accountId"]?.value as? String
289+
let suffix = target.map { " \($0)" } ?? ""
290+
StatusPill.verbatim("failureDestination" + suffix, tint: .secondary)
291+
}
292+
}
289293
}

0 commit comments

Comments
 (0)