feat(gui): PolicyPage subscribes to PolicyChanged for live refresh

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
michael
2026-04-27 11:16:18 -07:00
parent a28b5c9ebe
commit ae372df577

View File

@@ -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
}