mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-18 13:51:39 +00:00
fix(watch): migrate canonical approval outcomes
This commit is contained in:
@@ -71,6 +71,18 @@ struct WatchChatStatusLocalizationTests {
|
||||
#expect(status.command == .sendChat)
|
||||
}
|
||||
|
||||
@Test func `legacy approval outcomes recover semantic localization`() throws {
|
||||
let allowed = try #require(
|
||||
WatchExecApprovalOutcome.decodeLegacyLocalizedText("Approval allowed once."))
|
||||
let custom = try #require(
|
||||
WatchExecApprovalOutcome.decodeLegacyLocalizedText("Gateway custom outcome"))
|
||||
|
||||
#expect(allowed.code == .allowedOnce)
|
||||
#expect(allowed.verbatim == nil)
|
||||
#expect(custom.code == .verbatim)
|
||||
#expect(custom.verbatim == "Gateway custom outcome")
|
||||
}
|
||||
|
||||
@Test func `gateway presentation localizes key and keeps backend override verbatim`() {
|
||||
let localized = OpenClawWatchAppStatus(
|
||||
code: .gatewayProblem,
|
||||
|
||||
@@ -377,7 +377,28 @@ struct WatchExecApprovalOutcome: Codable, Equatable {
|
||||
|
||||
static func decodeLegacyLocalizedText(_ text: String) -> Self? {
|
||||
guard !text.isEmpty else { return nil }
|
||||
return Self(code: .verbatim, verbatim: text)
|
||||
return switch text {
|
||||
case "Allowed once", "Approval allowed once.", "This approval was already allowed once.":
|
||||
Self(code: .allowedOnce)
|
||||
case "Approval set to Always Allow.", "This approval was already set to Always Allow.":
|
||||
Self(code: .allowedAlways)
|
||||
case "Denied", "Approval denied.", "This approval was already denied.":
|
||||
Self(code: .denied)
|
||||
case "Approval resolved":
|
||||
Self(code: .resolved)
|
||||
case "Approval expired":
|
||||
Self(code: .expired)
|
||||
case "Approval no longer available":
|
||||
Self(code: .notFound)
|
||||
case "Approval resolved elsewhere", "This approval was already resolved elsewhere.":
|
||||
Self(code: .resolvedElsewhere)
|
||||
case "Approval replaced":
|
||||
Self(code: .replaced)
|
||||
case "Approval unavailable":
|
||||
Self(code: .unavailable)
|
||||
default:
|
||||
Self(code: .verbatim, verbatim: text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -743,7 +743,8 @@ extension WatchInboxStore {
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
.prefix(160)
|
||||
let outcome = if let normalizedOutcomeText, !normalizedOutcomeText.isEmpty {
|
||||
WatchExecApprovalOutcome(code: .verbatim, verbatim: String(normalizedOutcomeText))
|
||||
WatchExecApprovalOutcome.decodeLegacyLocalizedText(String(normalizedOutcomeText))
|
||||
?? WatchExecApprovalOutcome(code: .unavailable)
|
||||
} else if message.source == "another-reviewer" {
|
||||
WatchExecApprovalOutcome(code: .resolvedElsewhere)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user