Skip to content

Commit fec19b1

Browse files
committed
Merge remote-tracking branch 'origin/main' into codex/qa0803-feishu-webhook-route-boundary
2 parents 7875c64 + d29b9ad commit fec19b1

313 files changed

Lines changed: 13786 additions & 1368 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/.i18n/native-source.json‎

Lines changed: 268 additions & 140 deletions
Large diffs are not rendered by default.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ final class ControlChannel {
103103
didSet {
104104
CanvasManager.shared.refreshDebugStatus()
105105
guard oldValue != self.state else { return }
106+
if self.state != .connected {
107+
self.lastPingMs = nil
108+
self.authSourceLabel = nil
109+
}
106110
NotificationCenter.default.post(name: .controlChannelStateDidChange, object: nil)
107111
switch self.state {
108112
case .connected:

‎apps/macos/Sources/OpenClaw/CritterStatusLabel+Behavior.swift‎

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,20 +345,48 @@ extension CritterStatusLabel {
345345
}
346346

347347
private var gatewayNeedsAttention: Bool {
348-
if self.isSleeping { return false }
349-
switch self.gatewayStatus {
350-
case .failed, .stopped:
351-
return !self.isPaused
352-
case .starting, .running, .attachedExisting:
348+
Self.needsAttention(
349+
connectionMode: self.connectionMode,
350+
controlState: self.controlChannelState,
351+
gatewayStatus: self.gatewayStatus,
352+
isPaused: self.isPaused,
353+
isSleeping: self.isSleeping)
354+
}
355+
356+
static func needsAttention(
357+
connectionMode: AppState.ConnectionMode,
358+
controlState: ControlChannel.ConnectionState,
359+
gatewayStatus: GatewayProcessManager.Status,
360+
isPaused: Bool,
361+
isSleeping: Bool) -> Bool
362+
{
363+
guard !isPaused else { return false }
364+
switch connectionMode {
365+
case .unconfigured:
353366
return false
367+
case .remote:
368+
return GatewayConnectionPresentation(state: controlState).needsAttention
369+
case .local:
370+
guard !isSleeping else { return false }
371+
switch gatewayStatus {
372+
case .failed, .stopped:
373+
return true
374+
case .starting, .running, .attachedExisting:
375+
return false
376+
}
354377
}
355378
}
356379

357380
private var gatewayBadgeColor: Color {
381+
if self.connectionMode == .remote,
382+
GatewayConnectionPresentation(state: self.controlChannelState).needsAttention
383+
{
384+
return .red
385+
}
358386
switch self.gatewayStatus {
359-
case .failed: .red
360-
case .stopped: .orange
361-
default: .clear
387+
case .failed: return .red
388+
case .stopped: return .orange
389+
default: return .clear
362390
}
363391
}
364392
}
@@ -375,6 +403,8 @@ extension CritterStatusLabel {
375403
blinkTick: 1,
376404
sendCelebrationTick: 1,
377405
gatewayStatus: .running(details: nil),
406+
connectionMode: .local,
407+
controlChannelState: .connected,
378408
animationsEnabled: true,
379409
iconState: .workingMain(.tool(.bash)),
380410
voiceWakeMeterActive: true)
@@ -421,6 +451,8 @@ extension CritterStatusLabel {
421451
blinkTick: 0,
422452
sendCelebrationTick: 0,
423453
gatewayStatus: .failed("boom"),
454+
connectionMode: .local,
455+
controlChannelState: .connected,
424456
animationsEnabled: false,
425457
iconState: .idle,
426458
voiceWakeMeterActive: false)
@@ -435,6 +467,8 @@ extension CritterStatusLabel {
435467
blinkTick: 0,
436468
sendCelebrationTick: 0,
437469
gatewayStatus: .stopped,
470+
connectionMode: .local,
471+
controlChannelState: .connected,
438472
animationsEnabled: false,
439473
iconState: .idle,
440474
voiceWakeMeterActive: false)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ struct CritterStatusLabel: View {
88
var blinkTick: Int
99
var sendCelebrationTick: Int
1010
var gatewayStatus: GatewayProcessManager.Status
11+
var connectionMode: AppState.ConnectionMode
12+
var controlChannelState: ControlChannel.ConnectionState
1113
var animationsEnabled: Bool
1214
var iconState: IconState
1315
var voiceWakeMeterActive: Bool = false

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ enum DashboardGatewayCatalog {
9797

9898
@MainActor
9999
static func primaryHealth(for state: ControlChannel.ConnectionState) -> DashboardGatewayHealth {
100-
// ControlChannel currently has no failed state. Keep every representable
101-
// non-connected state neutral instead of painting a speculative error.
102-
if case .connected = state { return .ok }
103-
return .unknown
100+
switch state {
101+
case .connected: .ok
102+
case .degraded: .error
103+
case .connecting, .disconnected: .unknown
104+
}
104105
}
105106

106107
@MainActor

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum DashboardGatewayMenuModel {
3030

3131
static func connectionLabel(
3232
mode: AppState.ConnectionMode,
33+
controlState: ControlChannel.ConnectionState,
3334
entries: [DashboardGatewayEntry]) -> String
3435
{
3536
guard entries.count >= 2,
@@ -39,7 +40,7 @@ enum DashboardGatewayMenuModel {
3940
case .unconfigured:
4041
String(localized: "OpenClaw Not Configured")
4142
case .remote:
42-
String(localized: "Remote OpenClaw Active")
43+
self.remoteConnectionLabel(state: controlState)
4344
case .local:
4445
String(localized: "OpenClaw Active")
4546
}
@@ -48,9 +49,29 @@ enum DashboardGatewayMenuModel {
4849
case .unconfigured:
4950
String(localized: "OpenClaw Not Configured — \(primaryName)")
5051
case .remote:
51-
String(localized: "Remote OpenClaw Active — \(primaryName)")
52+
self.remoteConnectionLabel(state: controlState, primaryName: primaryName)
5253
case .local:
5354
String(localized: "OpenClaw Active — \(primaryName)")
5455
}
5556
}
57+
58+
private static func remoteConnectionLabel(
59+
state: ControlChannel.ConnectionState,
60+
primaryName: String? = nil) -> String
61+
{
62+
switch (state, primaryName) {
63+
case (.connected, nil):
64+
String(localized: "Remote OpenClaw Active")
65+
case let (.connected, .some(name)):
66+
String(localized: "Remote OpenClaw Active — \(name)")
67+
case (.connecting, nil):
68+
String(localized: "Remote OpenClaw Connecting")
69+
case let (.connecting, .some(name)):
70+
String(localized: "Remote OpenClaw Connecting — \(name)")
71+
case (.disconnected, nil), (.degraded, nil):
72+
String(localized: "Remote OpenClaw Needs Attention")
73+
case let (.disconnected, .some(name)), let (.degraded, .some(name)):
74+
String(localized: "Remote OpenClaw Needs Attention — \(name)")
75+
}
76+
}
5677
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import Foundation
2+
3+
enum GatewayConnectionTone: Equatable {
4+
case healthy
5+
case transient
6+
case attention
7+
}
8+
9+
struct GatewayConnectionPresentation: Equatable {
10+
let statusLine: String
11+
let generalTitle: String
12+
let generalSubtitle: String
13+
let symbolName: String
14+
let tone: GatewayConnectionTone
15+
let showsConnectionAction: Bool
16+
let needsAttention: Bool
17+
18+
init(state: ControlChannel.ConnectionState) {
19+
switch state {
20+
case .connected:
21+
self.statusLine = String(localized: "Connected")
22+
self.generalTitle = String(localized: "OpenClaw active")
23+
self.generalSubtitle = String(localized: "Connected to your remote Gateway.")
24+
self.symbolName = "checkmark"
25+
self.tone = .healthy
26+
self.showsConnectionAction = false
27+
self.needsAttention = false
28+
case .connecting:
29+
self.statusLine = String(localized: "Connecting…")
30+
self.generalTitle = String(localized: "OpenClaw connecting")
31+
self.generalSubtitle = String(localized: "Connecting to your remote Gateway…")
32+
self.symbolName = "arrow.trianglehead.2.clockwise.rotate.90"
33+
self.tone = .transient
34+
self.showsConnectionAction = false
35+
self.needsAttention = false
36+
case .disconnected:
37+
self.statusLine = String(localized: "Disconnected")
38+
self.generalTitle = String(localized: "OpenClaw needs attention")
39+
self
40+
.generalSubtitle =
41+
String(localized: "Disconnected from your remote Gateway. Open Connection settings to fix it.")
42+
self.symbolName = "exclamationmark.triangle.fill"
43+
self.tone = .attention
44+
self.showsConnectionAction = true
45+
self.needsAttention = false
46+
case let .degraded(message):
47+
let reason = message.trimmingCharacters(in: .whitespacesAndNewlines)
48+
self.statusLine = reason.isEmpty ? String(localized: "Gateway connection failed.") : reason
49+
self.generalTitle = String(localized: "OpenClaw needs attention")
50+
self.generalSubtitle = self.statusLine + " " + String(localized: "Open Connection settings to fix it.")
51+
self.symbolName = "exclamationmark.triangle.fill"
52+
self.tone = .attention
53+
self.showsConnectionAction = true
54+
self.needsAttention = true
55+
}
56+
}
57+
}
58+
59+
struct GeneralStatusPresentation: Equatable {
60+
let title: String
61+
let subtitle: String
62+
let symbolName: String
63+
let tone: GatewayConnectionTone
64+
let showsConnectionAction: Bool
65+
66+
static func resolve(
67+
mode: AppState.ConnectionMode,
68+
isPaused: Bool,
69+
controlState: ControlChannel.ConnectionState) -> Self
70+
{
71+
if isPaused {
72+
return Self(
73+
title: String(localized: "OpenClaw paused"),
74+
subtitle: String(localized: "Gateway work is paused; incoming messages will wait."),
75+
symbolName: "pause.fill",
76+
tone: .transient,
77+
showsConnectionAction: false)
78+
}
79+
80+
switch mode {
81+
case .local:
82+
return Self(
83+
title: String(localized: "OpenClaw active"),
84+
subtitle: String(localized: "Processing messages through the local Gateway on this Mac."),
85+
symbolName: "checkmark",
86+
tone: .healthy,
87+
showsConnectionAction: false)
88+
case .unconfigured:
89+
return Self(
90+
title: String(localized: "OpenClaw active"),
91+
subtitle: String(localized: "Ready to run after you choose a Gateway connection."),
92+
symbolName: "checkmark",
93+
tone: .healthy,
94+
showsConnectionAction: false)
95+
case .remote:
96+
let connection = GatewayConnectionPresentation(state: controlState)
97+
return Self(
98+
title: connection.generalTitle,
99+
subtitle: connection.generalSubtitle,
100+
symbolName: connection.symbolName,
101+
tone: connection.tone,
102+
showsConnectionAction: connection.showsConnectionAction)
103+
}
104+
}
105+
}

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

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -218,27 +218,40 @@ struct GeneralSettings: View {
218218
}
219219

220220
private var openClawStatusPanel: some View {
221-
HStack(alignment: .center, spacing: 14) {
221+
let presentation = GeneralStatusPresentation.resolve(
222+
mode: self.state.connectionMode,
223+
isPaused: self.state.isPaused,
224+
controlState: ControlChannel.shared.state)
225+
226+
return HStack(alignment: .center, spacing: 14) {
222227
ZStack {
223228
Circle()
224-
.fill(self.state.isPaused ? Color.orange.opacity(0.18) : Color.green.opacity(0.18))
225-
Image(systemName: self.state.isPaused ? "pause.fill" : "checkmark")
229+
.fill(self.statusColor(presentation.tone).opacity(0.18))
230+
Image(systemName: presentation.symbolName)
226231
.font(.system(size: 16, weight: .bold))
227-
.foregroundStyle(self.state.isPaused ? .orange : .green)
232+
.foregroundStyle(self.statusColor(presentation.tone))
228233
}
229234
.frame(width: 42, height: 42)
230235

231236
VStack(alignment: .leading, spacing: 4) {
232-
Text(self.state.isPaused ? "OpenClaw paused" : "OpenClaw active")
237+
Text(verbatim: presentation.title)
233238
.font(.headline)
234-
Text(self.generalStatusSubtitle)
239+
Text(verbatim: presentation.subtitle)
235240
.font(.footnote)
236241
.foregroundStyle(.secondary)
237242
.fixedSize(horizontal: false, vertical: true)
238243
}
239244

240245
Spacer(minLength: 20)
241246

247+
if presentation.showsConnectionAction {
248+
Button("Open Connection Settings") {
249+
AppNavigationActions.openSettings(tab: .connection)
250+
}
251+
.buttonStyle(.bordered)
252+
.controlSize(.small)
253+
}
254+
242255
Toggle("OpenClaw active", isOn: self.activeBinding)
243256
.labelsHidden()
244257
.toggleStyle(.switch)
@@ -252,17 +265,11 @@ struct GeneralSettings: View {
252265
}
253266
}
254267

255-
private var generalStatusSubtitle: String {
256-
if self.state.isPaused {
257-
return "Gateway work is paused; incoming messages will wait."
258-
}
259-
switch self.state.connectionMode {
260-
case .local:
261-
return "Processing messages through the local Gateway on this Mac."
262-
case .remote:
263-
return "Connected to a remote Gateway configuration."
264-
case .unconfigured:
265-
return "Ready to run after you choose a Gateway connection."
268+
private func statusColor(_ tone: GatewayConnectionTone) -> Color {
269+
switch tone {
270+
case .healthy: .green
271+
case .transient: .orange
272+
case .attention: .red
266273
}
267274
}
268275

@@ -363,7 +370,9 @@ struct GeneralSettings: View {
363370

364371
Spacer(minLength: 18)
365372

366-
if let ping = ControlChannel.shared.lastPingMs {
373+
if ControlChannel.shared.state == .connected,
374+
let ping = ControlChannel.shared.lastPingMs
375+
{
367376
Text("\(Int(ping)) ms")
368377
.font(.caption.weight(.semibold))
369378
.padding(.horizontal, 8)
@@ -701,12 +710,7 @@ struct GeneralSettings: View {
701710
}
702711

703712
private var controlStatusLine: String {
704-
switch ControlChannel.shared.state {
705-
case .connected: "Connected"
706-
case .connecting: "Connecting…"
707-
case .disconnected: "Disconnected"
708-
case let .degraded(msg): msg
709-
}
713+
GatewayConnectionPresentation(state: ControlChannel.shared.state).statusLine
710714
}
711715

712716
@ViewBuilder

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct OpenClawApp: App {
4444
blinkTick: self.state.blinkTick,
4545
sendCelebrationTick: self.state.sendCelebrationTick,
4646
gatewayStatus: self.gatewayManager.status,
47+
connectionMode: self.state.connectionMode,
48+
controlChannelState: self.controlChannel.state,
4749
animationsEnabled: self.state.iconAnimationsEnabled && !self.isGatewaySleeping,
4850
iconState: self.effectiveIconState,
4951
voiceWakeMeterActive: self.state.voiceWakeMeterActive)

0 commit comments

Comments
 (0)