Skip to content

perf(huddle): isolate level churn, tighten speech boundaries (#5825, #6397, #5671) - #304

Merged
cursor[bot] merged 1 commit into
mainfrom
devin/issue-275-huddle-perf-boundaries
Aug 23, 2026
Merged

cursor[bot] merged 1 commit into
mainfrom
devin/issue-275-huddle-perf-boundaries

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

Summary

Upstream sync of Huddle perf work: block#5825 (render churn), block#6397 (speech
boundaries), plus the one always-on piece of block#5671 that is portable to
Crew. No IA surface changes — channel-first IA untouched.

block#5825 — level churn no longer re-renders the app. Speaker levels arrive
~20 Hz and the local mic analyser ticks ~30 Hz; both lived in the single
HuddleContextValue, so every tick re-rendered every useHuddle() consumer
and its subtree. Split:

-const HuddleContext = React.createContext<HuddleContextValue | null>(null)  // lifecycle + micLevel + activeSpeakers + speakerLevels
+const HuddleContext       = createContext<HuddleContextValue>   // lifecycle/config, React.useMemo'd
+const HuddleLevelsContext = createContext<HuddleLevelsValue>    // micLevel, activeSpeakers, speakerLevels

micLevel/activeSpeakers/speakerLevels moved off HuddleContextValue into
useHuddleLevels(); the inline analyser effect moved verbatim into
useMicLevelAnalyser (same constants, same gate/attack behaviour). The three
meter consumers (HuddleBar, HuddleProfileControl, HuddleRoomHeader) read
the levels context and still see every tick.

block#6397 — speech boundaries. Endpointing was one threshold plus a silence
counter, so a single high frame opened a segment, a dipping vowel started the
countdown, and onsets/offsets got clipped. Boundary policy now lives in a pure
VadEndpoint state machine in huddle/stt.rs:

  • onset requires ONSET_CONFIRM_FRAMES consecutive frames above
    VAD_ONSET_THRESHOLD; confirmation prepends up to PRE_ROLL_FRAMES of
    buffered audio (bounded VecDeque) exactly once;
  • once open, a frame counts as speech until it drops below the lower
    VAD_OFFSET_THRESHOLD (hysteresis);
  • flush keeps only HANGOVER_FRAMES of the trailing silence, and reset()
    drops pre-roll/candidate audio, so nothing leaks into the next segment;
  • short segments now say why they were dropped instead of vanishing silently
    (SegmentDisposition::DropShort).

Unchanged by design: TTS suppression + cooldown, the 30 s OOM guard,
model-independence (Earshot 1.1.0), and SILENCE_FLUSH_FRAMES (300 ms).

block#5671 — divergence, deliberate. The upstream latency levers
(BUZZ_STT_SPECULATIVE, BUZZ_TTS_STREAMING, BUZZ_TTS_EMIT_FRAMES,
BUZZ_STT_THREADS, BUZZ_TTS_THREADS) are default-off env gates inside
TTS/STT internals this branch does not touch — porting them here would mean
importing upstream's whole TTS pipeline rewrite, which is out of this issue's
scope and would collide with the sibling sync PRs. What is portable is the
push-to-talk grouping fix: a held shortcut is an explicit "I am not done
talking", so a VAD pause no longer splits the hold even when the microphone is
also manually open (vad_flush_allowed). Previously
ptt_active.is_none() || manually_open allowed exactly that split.
BUZZ_STT_FLUSH_MS stays removed. docs/crew/HERMES.md documents the state so
nobody sets a variable that does nothing in Crew.

stt.rs crossed the 1000-line ratchet, so its tests moved to a sibling
stt_tests.rs (the repo's existing *_tests.rs pattern) instead of raising
any baseline.

Related issue

Fixes #275. Part of the Buzz 0.5.18 sync stack (#285); guardrails per #278.
Upstream refs: block#5825, block#5671, block#6397. No duplicate
Crew PR found.

Testing

TDD, RED before GREEN:

Gate Result
pnpm --filter buzz check pass
pnpm --filter buzz typecheck pass
pnpm --filter buzz test pass (5530/5531, 1 pre-existing skip)
just check-compile pass
cargo clippy (tauri lib + tests) clean
just test-unit 2 pre-existing failures in buzz-cli (command-inventory snapshots) and buzz-db (embedded migration snapshot) — crates this diff does not touch
  • RED: frontend useHuddleLevels is not a function; Rust unresolved
    VadEndpoint/SegmentDisposition/threshold imports, then unresolved
    vad_flush_allowed.
  • GREEN: huddleLevelsContext.test.mjs 2/2; cargo test --lib huddle::stt
    11/11 (onset confirmation, pre-roll once, hysteresis, hangover-only flush, no
    cross-segment leakage, visible short-segment drop, held-PTT grouping).
  • Quantitative (fix(huddle): stop 20 Hz speaker-level churn from re-rendering the whole app block/buzz#5825): the same harness mounted against both revisions,
    20 speaker-level events = 1 s of huddle audio, counting useHuddle()
    consumer re-renders: before 20 → after 0; level meters still re-render on
    all 20 ticks.

No visual change — full-window E2E captures (sidebar + list + channel panel)
before and after are identical:

before

after

DONE

Issue #275 is implemented end to end; nothing is left half-written on the branch.

Gates (all run locally, full logs attached below):

Gate Result
pnpm --filter buzz check pass
pnpm --filter buzz typecheck pass
pnpm --filter buzz test pass
just check-compile pass
cargo clippy (tauri lib + tests) clean
just test-unit 2 pre-existing failures in buzz-cli and buzz-db snapshot tests — crates this diff does not touch

Evidence on the session box (/home/ubuntu/evidence-275/): red-frontend-huddle-levels.log,
green-frontend-huddle-levels.log, red-rust-vad-tests.log,
red-rust-vad-flush-allowed.log, green-rust-vad-tests.log,
render-churn-before.log (20 renders), render-churn-after.log (0 renders),
gate-check.log, gate-typecheck.log, gate-frontend-test.log,
gate-test-unit.log, gate-check-compile.log, ci-smoke-branch-local.log,
ci-smoke-base-main-local.log, and full-window captures
screens/before-huddle-perf.png / screens/after-huddle-perf.png (embedded above).
E2E drive evidence and the CI parity analysis are in the two PR comments.

CI seen (not fixed, per the guardrails): Desktop Fast, Desktop Rust,
CI Policy, Desktop Release Candidate, macOS ARM Package green. Desktop Smoke E2E and Desktop E2E Integration failed, and reproduce identically on the base
commit 9bffb8ca in a clean worktree (8 failed / 4 passed / 4 skipped on both, same
test titles) — pre-existing on main, details in the "CI note" comment. Later runs
may also show as cancelled: the parent session is serialising CI on purpose.

IN PROGRESS

Nothing. The branch is committed (git commit -s), pushed, and the parent's merge of
main (mobile PR #305) is already in at 20b59dee; GitHub reports no conflicts.

TODO / NEXT

  • Merge is owned by the parent session — this PR is intentionally left unmerged.
  • Two behaviours were not verified visually and are the first thing to check if a
    huddle regression appears: HuddleRoomHeader renders only in the huddle companion
    window, which the E2E mock bridge does not open as a separate surface; and the
    huddle-bar mute state could not be asserted because micConnected is false under
    the mock (no error was thrown in either case).
  • VAD constants (VAD_ONSET_THRESHOLD 0.6 / VAD_OFFSET_THRESHOLD 0.35,
    ONSET_CONFIRM_FRAMES 3, PRE_ROLL_FRAMES 8, HANGOVER_FRAMES 6) are tuned
    against the tests, not against recorded speech — worth a listening pass on real
    audio before release, especially for soft onsets.
  • Conflicts expected only if a sibling sync PR also edits desktop/src-tauri/src/huddle/stt.rs
    or desktop/src/features/huddle/HuddleContext.tsx; note that stt.rs tests were
    moved to a sibling stt_tests.rs to stay under the file-size ratchet, so a
    conflicting branch that still has tests inline will need that move applied.
  • just test-unit stays red until the unrelated buzz-cli / buzz-db snapshots are
    regenerated by their owners.

Link to Devin session: https://app.devin.ai/sessions/d62a99b203d14687bd3b0501230eb68b
Requested by: @oscarlehuu

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Author

E2E verification — huddle context split (#275)

Drove the real desktop frontend through the Playwright E2E mock bridge (headed Chromium, seeded active huddle with two participants), capturing console error/warning/pageerror for the whole session.

Levels context is still live after the split

Emitting a speaker level through the bridge moves --buzz-huddle-speaker-opacity on the participant avatar 0 → 0.945 → 0, i.e. useHuddleLevels() consumers still receive high-frequency updates from the new provider:

Speaker ring driven by useHuddleLevels

Golden path unchanged (sidebar, channels, thread panel, search, settings)

Thread panel
Search
Settings

Huddle surfaces render and lifecycle still works

Headphones control in the channel header starts a huddle; Leave unmounts the huddle bar and removes the ephemeral channel; the huddle channel view renders.

Headphones control
Huddle restarted

Console: no useHuddleLevels must be used within a HuddleProvider, no context-null errors, no page errors, no React warnings. The only entries are pre-existing mock-bridge fixture noise (Unsupported mocked Tauri command: is_shared_identity, Event not found: mock-feed-mention, [TAURI] Couldn't find callback id …) — this PR touches no bridge/mock files.

Not covered: HuddleRoomHeader is companion-window-only and isn't reachable via the mock bridge; the mute toggle's visual state can't be asserted because micConnected is false under the mock. Rust huddle::stt re-confirmed via cargo test --lib huddle::stt (11/11).

@devin-ai-integration

Copy link
Copy Markdown
Author

CI note: desktop E2E failures are pre-existing on main, not from this PR

Desktop Fast, Desktop Rust, CI Policy, Desktop Release Candidate and macOS ARM Package are green. The Desktop Smoke E2E / Desktop E2E Integration failures reproduce identically on the base commit this branch was cut from (9bffb8ca, i.e. main at branch time), in a clean worktree, with no huddle files changed:

run result
branch 68fa5f89 (project-commit-detail + overscroll-boundary + message-feedback-snapshots, smoke) 8 failed / 4 passed / 4 skipped
base 9bffb8ca (same three specs, same command) 8 failed / 4 passed / 4 skipped — same 8 test titles

Failing specs (project-commit-detail, message-feedback-snapshots, messaging, mission-inbox, needs-restart-screenshots, onboarding-agent-defaults, overscroll-boundary, persistent-agent-audience, edit-agent, entity-link-recipient-cards, inbox-reactions, profile, parity-ancestor-island) exercise projects, inbox, onboarding and agent-profile surfaces. This PR touches only desktop/src/features/huddle/**, desktop/src-tauri/src/huddle/stt*.rs and docs/crew/HERMES.md; the integration profile.spec.ts failures assert agent instruction permissions ("Who can send instructions" → expected Anyone, got Only npub1mock… (owner)), which is the surface changed by #271 landing on main just before this branch.

Per the fork guardrails I have not touched any CI configuration.

@devin-ai-integration

Copy link
Copy Markdown
Author

DONE

Issue #275 is implemented end to end; nothing is left half-written on the branch.

Gates (all run locally, full logs attached below):

Gate Result
pnpm --filter buzz check pass
pnpm --filter buzz typecheck pass
pnpm --filter buzz test pass
just check-compile pass
cargo clippy (tauri lib + tests) clean
just test-unit 2 pre-existing failures in buzz-cli and buzz-db snapshot tests — crates this diff does not touch

Evidence on the session box (/home/ubuntu/evidence-275/): red-frontend-huddle-levels.log,
green-frontend-huddle-levels.log, red-rust-vad-tests.log,
red-rust-vad-flush-allowed.log, green-rust-vad-tests.log,
render-churn-before.log (20 renders), render-churn-after.log (0 renders),
gate-check.log, gate-typecheck.log, gate-frontend-test.log,
gate-test-unit.log, gate-check-compile.log, ci-smoke-branch-local.log,
ci-smoke-base-main-local.log, and full-window captures
screens/before-huddle-perf.png / screens/after-huddle-perf.png (embedded above).
E2E drive evidence and the CI parity analysis are in the two PR comments.

CI seen (not fixed, per the guardrails): Desktop Fast, Desktop Rust,
CI Policy, Desktop Release Candidate, macOS ARM Package green. Desktop Smoke E2E and Desktop E2E Integration failed, and reproduce identically on the base
commit 9bffb8ca in a clean worktree (8 failed / 4 passed / 4 skipped on both, same
test titles) — pre-existing on main, details in the "CI note" comment. Later runs
may also show as cancelled: the parent session is serialising CI on purpose.

IN PROGRESS

Nothing. The branch is committed (git commit -s), pushed, and the parent's merge of
main (mobile PR #305) is already in at 20b59dee; GitHub reports no conflicts.

TODO / NEXT

  • Merge is owned by the parent session — this PR is intentionally left unmerged.
  • Two behaviours were not verified visually and are the first thing to check if a
    huddle regression appears: HuddleRoomHeader renders only in the huddle companion
    window, which the E2E mock bridge does not open as a separate surface; and the
    huddle-bar mute state could not be asserted because micConnected is false under
    the mock (no error was thrown in either case).
  • VAD constants (VAD_ONSET_THRESHOLD 0.6 / VAD_OFFSET_THRESHOLD 0.35,
    ONSET_CONFIRM_FRAMES 3, PRE_ROLL_FRAMES 8, HANGOVER_FRAMES 6) are tuned
    against the tests, not against recorded speech — worth a listening pass on real
    audio before release, especially for soft onsets.
  • Conflicts expected only if a sibling sync PR also edits desktop/src-tauri/src/huddle/stt.rs
    or desktop/src/features/huddle/HuddleContext.tsx; note that stt.rs tests were
    moved to a sibling stt_tests.rs to stay under the file-size ratchet, so a
    conflicting branch that still has tests inline will need that move applied.
  • just test-unit stays red until the unrelated buzz-cli / buzz-db snapshots are
    regenerated by their owners.

Upstream sync of block#5825 and block#6397 plus the always-on part of block#5671.

block#5825 — 20 Hz speaker levels and the ~30 Hz mic analyser lived in the same
context value as huddle lifecycle state, so every tick re-rendered every
`useHuddle()` consumer (and their subtrees) across the whole app. Levels now
live in a separate `HuddleLevelsContext` (`useHuddleLevels()`), the mic
analyser moves to `useMicLevelAnalyser`, and the lifecycle value is memoized.
Meters still see every tick; ordinary consumers see none (20 -> 0 re-renders
per second of huddle audio).

block#6397 — endpointing was a single threshold plus a silence counter, so a
one-frame blip opened a segment, a dipping vowel started the countdown, and
word onsets/offsets were clipped. Speech boundaries now live in a pure
`VadEndpoint`: onset needs consecutive above-threshold frames, confirmation
prepends bounded pre-roll, offset uses a lower threshold (hysteresis), flush
keeps only a hangover tail, and reset drops buffered audio so nothing leaks
between segments. Short segments now log why they were dropped.

block#5671 — only the push-to-talk grouping fix is portable here: a held shortcut
no longer silence-flushes mid-hold when the mic is also manually open
(`vad_flush_allowed`). The env-gated STT/TTS levers live in TTS internals this
branch does not touch; documented as such in docs/crew/HERMES.md, and
BUZZ_STT_FLUSH_MS stays removed.

Fixes #275

Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@cursor
cursor Bot force-pushed the devin/issue-275-huddle-perf-boundaries branch from 20b59de to 87af09f Compare August 23, 2026 01:42
@cursor
cursor Bot merged commit 6998094 into main Aug 23, 2026
8 of 14 checks passed
@cursor
cursor Bot deleted the devin/issue-275-huddle-perf-boundaries branch August 23, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

upstream(sync): Huddle perf — CPU churn, TTS latency, speech boundaries (#5825, #5671, #6397)

1 participant