From 3a030548c02197df17c3764185502a38e440172c Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Sun, 12 Apr 2026 11:57:12 -0400 Subject: [PATCH] Fix profile not updating --- hbd/server/http.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/hbd/server/http.py b/hbd/server/http.py index 195b2af..9046991 100644 --- a/hbd/server/http.py +++ b/hbd/server/http.py @@ -756,17 +756,39 @@ async def start( templates_dir = config.get("templates_dir", os.path.join(pkg_dir, "templates")) env = jinja2.Environment(loader=jinja2.FileSystemLoader(templates_dir)) - # Build host access summary for this user + # Build host access summary for this user. + # Merge live hosts with config-only hosts (not yet seen) so the profile + # reflects the config file immediately after a reload. + from . import config as config_mod owned, managed, monitored = [], [], [] if current_user: - for hostname, host in sorted(hbdclass.Host.hosts.items()): - if host.is_owner(current_user.username): + # Collect all known hostnames: live + configured + cfg_hostnames = set(config.get("hosts", {}).keys()) + live_hostnames = set(hbdclass.Host.hosts.keys()) + all_hostnames = sorted(cfg_hostnames | live_hostnames) + + for hostname in all_hostnames: + live_host = hbdclass.Host.hosts.get(hostname) + if live_host is not None: + # Use live object — it has apply_access already called + is_own = live_host.is_owner(current_user.username) + is_mgr = not is_own and live_host.is_manager(current_user.username) + is_mon = not is_own and not is_mgr and live_host.is_monitor(current_user.username) + else: + # Config-only host — read access directly from config + access = config_mod.get_host_access(config, hostname) + is_own = access["owner"] == current_user.username + is_mgr = current_user.username in access["managers"] + is_mon = current_user.username in access["monitors"] + + if is_own: owned.append(hostname) - elif host.is_manager(current_user.username): + elif is_mgr: managed.append(hostname) - elif host.is_monitor(current_user.username): + elif is_mon: monitored.append(hostname) + # Resolve notification channel configs for display notif_channels = [] if current_user: