Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/OpenClaw.Shared/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,24 @@ public class ChannelHealth
public string? AuthAge { get; set; }
public string? Type { get; set; }

private static readonly HashSet<string> s_healthyStatuses =
new(StringComparer.OrdinalIgnoreCase) { "ok", "connected", "running", "active", "ready" };

private static readonly HashSet<string> s_intermediateStatuses =
new(StringComparer.OrdinalIgnoreCase) { "stopped", "idle", "paused", "configured", "pending", "connecting", "reconnecting" };

/// <summary>
/// Returns true if the given status string represents a healthy/running channel.
/// Use this instead of inline status checks to keep the healthy-status set consistent.
/// </summary>
public static bool IsHealthyStatus(string? status) =>
status?.ToLowerInvariant() is "ok" or "connected" or "running" or "active" or "ready";
status is not null && s_healthyStatuses.Contains(status);

/// <summary>
/// Returns true if the given status string represents an intermediate (not yet healthy, not error) state.
/// </summary>
public static bool IsIntermediateStatus(string? status) =>
status?.ToLowerInvariant() is "stopped" or "idle" or "paused" or "configured" or "pending"
or "connecting" or "reconnecting";
status is not null && s_intermediateStatuses.Contains(status);

public string DisplayText
{
Expand Down
9 changes: 5 additions & 4 deletions src/OpenClaw.Shared/OpenClawGatewayClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -870,18 +870,19 @@ private void UpdateTrackedSession(string sessionKey, bool isMain, string? curren
SessionInfo[] snapshot;
lock (_sessionsLock)
{
if (!_sessions.ContainsKey(sessionKey))
if (!_sessions.TryGetValue(sessionKey, out var session))
{
_sessions[sessionKey] = new SessionInfo
session = new SessionInfo
{
Key = sessionKey,
IsMain = isMain,
Status = "active"
};
_sessions[sessionKey] = session;
}

_sessions[sessionKey].CurrentActivity = currentActivity;
_sessions[sessionKey].LastSeen = DateTime.UtcNow;
session.CurrentActivity = currentActivity;
session.LastSeen = DateTime.UtcNow;

snapshot = GetSessionListInternal();
}
Expand Down