fix(gateway): treat active sessions as configured

This commit is contained in:
Frank Song 2026-05-25 21:48:51 +08:00
parent 4ea762ae0d
commit aa6daf82f2
3 changed files with 10 additions and 5 deletions

View file

@ -3,6 +3,10 @@
## [Unreleased]
### Fixed
- Gateway status now treats existing messaging-session metadata as configured when `gateway.status` is unavailable, avoiding a misleading "Gateway not configured" warning for multi-container deployments with active gateway sessions.
## [v0.51.134] — 2026-05-25 — Release DF (stage-batch16 — single-PR Windows path defaults)
### Fixed

View file

@ -4754,7 +4754,7 @@ def handle_get(handler, parsed) -> bool:
configured = True
else: # alive is None → gateway not configured / unavailable
running = bool(identity_map)
configured = False
configured = bool(identity_map)
platforms_set: set[str] = set()
for meta in identity_map.values():

View file

@ -124,7 +124,8 @@ def test_gateway_status_running_true_and_platforms_when_agent_health_alive_and_s
def test_gateway_status_alive_none_falls_back_to_identity_map_heuristic(monkeypatch):
"""When alive=None (not configured) but sessions exist, running reflects identity_map.
configured=false tells the frontend to show 'not configured' state."""
configured=true because sessions metadata proves a gateway is configured
even if gateway.status cannot be imported in this WebUI process."""
from api import routes
monkeypatch.setattr(
@ -144,8 +145,8 @@ def test_gateway_status_alive_none_falls_back_to_identity_map_heuristic(monkeypa
result = handler.get_json()
# Fallback to identity_map: sessions exist → running=true
assert result["running"] is True
# But configured=false because alive was None (no gateway metadata)
assert result["configured"] is False
# Existing gateway sessions prove the gateway has been configured.
assert result["configured"] is True
def test_gateway_status_handles_corrupted_sessions_json(monkeypatch):
@ -244,4 +245,4 @@ def test_gateway_status_last_active_empty_when_alive_and_no_sessions_path(monkey
assert result["configured"] is True
# In test context, sessions_path won't exist (no real filesystem),
# so last_active must be empty.
assert result["last_active"] == ""
assert result["last_active"] == ""