Fix service tiles showing stale enabled state by overlaying runtime hub-overrides

Agent-Logs-Url: https://github.com/naturallaw777/staging_alpha/sessions/e840f6c9-69a3-4ced-b6ef-128a0775321c

Co-authored-by: naturallaw777 <99053422+naturallaw777@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-03 01:29:21 +00:00
committed by GitHub
parent 12eb68abdf
commit cba66e86df

View File

@@ -156,6 +156,12 @@ FEATURE_SERVICE_MAP = {
"bitcoin-core": None, "bitcoin-core": None,
} }
# For features that share a unit, disambiguate by icon field
FEATURE_ICON_MAP = {
"bip110": "bip110",
"bitcoin-core": "bitcoin-core",
}
ROLE_LABELS = { ROLE_LABELS = {
"server_plus_desktop": "Server + Desktop", "server_plus_desktop": "Server + Desktop",
"desktop": "Desktop Only", "desktop": "Desktop Only",
@@ -616,12 +622,31 @@ async def api_services():
cfg = load_config() cfg = load_config()
services = cfg.get("services", []) services = cfg.get("services", [])
# Build reverse map: unit → feature_id (for features with a unit)
unit_to_feature = {
unit: feat_id
for feat_id, unit in FEATURE_SERVICE_MAP.items()
if unit is not None
}
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
# Read runtime feature overrides from hub-overrides.nix
overrides, _ = await loop.run_in_executor(None, _read_hub_overrides)
async def get_status(entry): async def get_status(entry):
unit = entry.get("unit", "") unit = entry.get("unit", "")
scope = entry.get("type", "system") scope = entry.get("type", "system")
icon = entry.get("icon", "")
enabled = entry.get("enabled", True) enabled = entry.get("enabled", True)
# Overlay runtime feature state from hub-overrides.nix
feat_id = unit_to_feature.get(unit)
if feat_id is None:
feat_id = FEATURE_ICON_MAP.get(icon)
if feat_id is not None and feat_id in overrides:
enabled = overrides[feat_id]
if enabled: if enabled:
status = await loop.run_in_executor( status = await loop.run_in_executor(
None, lambda: sysctl.is_active(unit, scope) None, lambda: sysctl.is_active(unit, scope)
@@ -636,7 +661,7 @@ async def api_services():
"name": entry.get("name", ""), "name": entry.get("name", ""),
"unit": unit, "unit": unit,
"type": scope, "type": scope,
"icon": entry.get("icon", ""), "icon": icon,
"enabled": enabled, "enabled": enabled,
"category": entry.get("category", "other"), "category": entry.get("category", "other"),
"status": status, "status": status,