fix(qconnect): refresh session snapshot when badge popup opens

In compiled builds, the session snapshot can be stale when the badge
popup opens — the deferred_renderer_join completes after the initial
snapshot was fetched, so QBZ doesn't appear in the renderer list.

Now fetches a fresh snapshot from the backend every time the popup
opens, ensuring the renderer list is always current. Uses a local
$state copy that syncs from the prop but can be updated independently.

cc
This commit is contained in:
vicrodh committed 2026-03-20 10:06:29 -06:00
1 parent f1f084c994
commit a4782c645e
1 file changed
+20 -2
+20 -2
View File
@@ -13,17 +13,35 @@
let {
connected,
sessionSnapshot = null,
sessionSnapshot: sessionSnapshotProp = null,
onToggleConnection,
busy = false,
}: Props = $props();
// Local snapshot that can be refreshed independently of the prop
let sessionSnapshot = $state<QconnectSessionSnapshot | null>(null);
$effect(() => {
sessionSnapshot = sessionSnapshotProp;
});
let isPopupOpen = $state(false);
let isInfoHovering = $state(false);
let settingRenderer = $state(false);
function togglePopup(): void {
async function togglePopup(): Promise<void> {
isPopupOpen = !isPopupOpen;
// Force a fresh session snapshot when opening — the session state
// may have stale renderer list from before deferred_renderer_join
if (isPopupOpen && connected) {
try {
const fresh = await invoke<QconnectSessionSnapshot>('v2_qconnect_session_snapshot');
if (fresh && fresh.renderers.length > 0) {
sessionSnapshot = fresh;
}
} catch {
// non-fatal
}
}
}
function closePopup(): void {