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 <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
This commit is contained in:
npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757
2026-07-08 10:18:48 -04:00
committed by npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d
parent 597c5d1eaa
commit 73d2218336
3 changed files with 18 additions and 6 deletions

View File

@@ -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]);

View File

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

View File

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