From ae372df577bddd160ed8e159db4dcf7da1b32aca Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 27 Apr 2026 11:16:18 -0700 Subject: [PATCH] feat(gui): PolicyPage subscribes to PolicyChanged for live refresh Co-Authored-By: Claude Opus 4.7 (1M context) --- gui/src/policy_page.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gui/src/policy_page.rs b/gui/src/policy_page.rs index 7abac95..c16c545 100644 --- a/gui/src/policy_page.rs +++ b/gui/src/policy_page.rs @@ -34,6 +34,25 @@ impl PolicyPage { glib::MainContext::default().spawn_local(async move { p.refresh().await; }); + + // Live-refresh subscriber: external `authforgectl policy set` invocations + // bypass the GUI; without subscribing the page would show stale state. + let p = page.clone(); + glib::MainContext::default().spawn_local(async move { + let daemon = match p.ctx.daemon.borrow().clone() { + Some(d) => d, + None => return, + }; + let mut stream = match daemon.subscribe_policy_changed().await { + Ok(s) => s, + Err(_) => return, + }; + use futures_util::StreamExt; + while stream.next().await.is_some() { + p.refresh().await; + } + }); + page }