mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:40:49 +00:00
fix(cron): clarify no-delivery previews
This commit is contained in:
@@ -103,10 +103,13 @@ struct SessionRow: Identifiable {
|
||||
}
|
||||
|
||||
enum SessionKind {
|
||||
case direct, group, global, unknown
|
||||
case cron, direct, group, global, unknown
|
||||
|
||||
static func from(key: String) -> SessionKind {
|
||||
if key == "global" { return .global }
|
||||
let parts = key.lowercased().split(separator: ":").filter { !$0.isEmpty }
|
||||
if parts.first == "cron" { return .cron }
|
||||
if parts.count >= 3, parts[0] == "agent", parts[2] == "cron" { return .cron }
|
||||
if key.hasPrefix("group:") { return .group }
|
||||
if key.contains(":group:") { return .group }
|
||||
if key.contains(":channel:") { return .group }
|
||||
@@ -116,6 +119,7 @@ enum SessionKind {
|
||||
|
||||
var label: String {
|
||||
switch self {
|
||||
case .cron: "Cron"
|
||||
case .direct: "Direct"
|
||||
case .group: "Group"
|
||||
case .global: "Global"
|
||||
@@ -125,6 +129,7 @@ enum SessionKind {
|
||||
|
||||
var tint: Color {
|
||||
switch self {
|
||||
case .cron: .green
|
||||
case .direct: .accentColor
|
||||
case .group: .orange
|
||||
case .global: .purple
|
||||
|
||||
@@ -5,6 +5,8 @@ import Testing
|
||||
struct SessionDataTests {
|
||||
@Test func `session kind from key detects common kinds`() {
|
||||
#expect(SessionKind.from(key: "global") == .global)
|
||||
#expect(SessionKind.from(key: "cron:daily") == .cron)
|
||||
#expect(SessionKind.from(key: "agent:main:cron:daily") == .cron)
|
||||
#expect(SessionKind.from(key: "discord:group:engineering") == .group)
|
||||
#expect(SessionKind.from(key: "unknown") == .unknown)
|
||||
#expect(SessionKind.from(key: "user@example.com") == .direct)
|
||||
|
||||
Reference in New Issue
Block a user