From 73d221833692d50e42c68a5fd1e01c61519d909f Mon Sep 17 00:00:00 2001 From: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co> Date: Wed, 8 Jul 2026 10:18:48 -0400 Subject: [PATCH] perf(huddle): slow frontend fallback polls Finding: L7 huddle frontend poll reductions.\n\nKeep event-driven huddle state updates and immediate initial checks, but slow the fallback timers that hit sync/lightweight IPC and duplicate membership refresh paths. This reduces steady-state huddle IPC/relay traffic without touching Rust huddle ownership. Co-authored-by: Tyler Longwell Signed-off-by: Tyler Longwell --- desktop/src/features/huddle/HuddleContext.tsx | 3 ++- .../features/huddle/components/HuddleBar.tsx | 17 +++++++++++++---- .../features/huddle/lib/useTtsSubscription.ts | 4 +++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/desktop/src/features/huddle/HuddleContext.tsx b/desktop/src/features/huddle/HuddleContext.tsx index 42fcf4b4a4..1bbaeccc07 100644 --- a/desktop/src/features/huddle/HuddleContext.tsx +++ b/desktop/src/features/huddle/HuddleContext.tsx @@ -22,6 +22,7 @@ type HuddleJoinInfo = { type VoiceInputMode = "push_to_talk" | "voice_activity"; const MIC_ANALYSER_UPDATE_INTERVAL_MS = 33; +const PIPELINE_HOTSTART_INTERVAL_MS = 15_000; const MIC_INITIAL_NOISE_FLOOR = 0.01; const MIC_VOICE_GATE_ON_RMS = 0.018; const MIC_VOICE_GATE_OFF_RMS = 0.012; @@ -522,7 +523,7 @@ export function HuddleProvider({ children }: { children: React.ReactNode }) { invoke("check_pipeline_hotstart").catch(() => { /* best-effort */ }); - }, 5_000); + }, PIPELINE_HOTSTART_INTERVAL_MS); return () => window.clearInterval(id); }, [ephemeralChannelId]); diff --git a/desktop/src/features/huddle/components/HuddleBar.tsx b/desktop/src/features/huddle/components/HuddleBar.tsx index b082e66c7b..35d660e475 100644 --- a/desktop/src/features/huddle/components/HuddleBar.tsx +++ b/desktop/src/features/huddle/components/HuddleBar.tsx @@ -59,6 +59,8 @@ type HuddleBarProps = { }; const HUDDLE_DRAWER_EXIT_MS = 260; +const HUDDLE_STATE_FALLBACK_INTERVAL_MS = 30_000; +const HUDDLE_MODEL_STATUS_INTERVAL_MS = 10_000; const HUDDLE_REACTION_NAME_MAX = 48; function isVisibleHuddleState(state: HuddleState | null) { @@ -212,7 +214,7 @@ export function HuddleBar({ } setState(nextState); }, []); - // Huddle state: event-driven + 10s fallback poll. + // Huddle state: event-driven + slow fallback poll. React.useEffect(() => { let cancelled = false; let unlisten: (() => void) | null = null; @@ -246,8 +248,12 @@ export function HuddleBar({ else unlisten = fn; }); - // Fallback: 10s poll in case events are missed - const id = window.setInterval(() => void fetchState(), 10_000); + // Fallback in case events are missed; keep it slow so normal huddle use is + // event-driven and does not keep a sync IPC command warm on the main thread. + const id = window.setInterval( + () => void fetchState(), + HUDDLE_STATE_FALLBACK_INTERVAL_MS, + ); return () => { cancelled = true; @@ -293,7 +299,10 @@ export function HuddleBar({ } void pollModels(); - const id = window.setInterval(() => void pollModels(), 3_000); + const id = window.setInterval( + () => void pollModels(), + HUDDLE_MODEL_STATUS_INTERVAL_MS, + ); return () => { cancelled = true; diff --git a/desktop/src/features/huddle/lib/useTtsSubscription.ts b/desktop/src/features/huddle/lib/useTtsSubscription.ts index bd09ce82c7..d534fc0166 100644 --- a/desktop/src/features/huddle/lib/useTtsSubscription.ts +++ b/desktop/src/features/huddle/lib/useTtsSubscription.ts @@ -3,6 +3,8 @@ import * as React from "react"; import { relayClient } from "@/shared/api/relayClient"; +const AGENT_PUBKEY_REFRESH_INTERVAL_MS = 30_000; + /** * Subscribe to agent TTS messages on the ephemeral huddle channel. * Pipes agent kind:9 messages to `speak_agent_message` on the Rust backend. @@ -51,7 +53,7 @@ export function useTtsSubscription( void loadAgentPubkeys(); const agentRefreshId = window.setInterval(() => { void loadAgentPubkeys(); - }, 10_000); + }, AGENT_PUBKEY_REFRESH_INTERVAL_MS); // ── Live-only subscription ─────────────────────────────────────────── // subscribeToChannelLive uses `since: now` — the relay never sends