fix(discovery): audit fixes for the realtime streaming flow - #36
Open
jhosepmyr wants to merge 3 commits into
Open
fix(discovery): audit fixes for the realtime streaming flow#36jhosepmyr wants to merge 3 commits into
jhosepmyr wants to merge 3 commits into
Conversation
… socket stopStreaming() closed the websocket and then discarded the PCM accumulator, dropping the sub-chunk tail (< 2048 samples, ~128ms) — often the end of the speaker's final sentence — so the last words could be missing from the transcript. Send the remaining samples before the close.
… enum The SessionEventType union carried a phantom SESSION_RESET the backend never emits and was missing SESSION_CREATED, which it does (project topic, DRAFT). applyRealtime also dropped any unrecognized type silently, so a backend that ships a new event first would look like a dead feature. Align the union with the backend enum and log a console warning for unhandled types.
…CIDE The discovery chat gated recording AND suggestion accept/dismiss on canManage = org OWNER only — so an org admin, or a member whose project role grants SESSION_RUN/SESSION_DECIDE, could neither record nor decide, and a read-only viewer clicking accept hit a spurious 403 toast. Drive canRecord from SESSION_RUN and canDecide from SESSION_DECIDE (owner/admin bypass via PermissionsStore.has()); the SESSION_READ route guard has already loaded the project permissions before the page renders.
jhosepmyr
force-pushed
the
bugfix/discovery-streaming-audit
branch
from
July 10, 2026 19:43
0577137 to
0015db2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes from a full end-to-end audit of the discovery realtime/streaming flow (backend + frontend) ahead of the live demo. Two defects surfaced, both frontend:
stopStreaming()closed the STT websocket and then discarded the PCM accumulator, losing the sub-chunk tail (< 2048 samples ≈ 128ms) — often the end of the speaker's final sentence. It now flushes the remaining samples before closing.SessionEventTypeunion carried a phantomSESSION_RESET(the backend never emits it) and was missingSESSION_CREATED(which it does emit on the project topic); andapplyRealtimesilently dropped any unrecognized message type, so a backend that ships a new event first looks like a dead feature. The union now mirrors the backend enum exactly and unknown types log a console warning.Audit context (no code defects found in these areas): backend message wire-types, suggestion generation cadence/grounding, duplicate thresholds (0.50 recall → LLM judge → 0.84 auto-dedup → 0.85 import gate), notify-after-commit ordering, RBAC gates on REST + STT websocket, and the recently merged watermark/audio-pause fix — all verified sound.
Feature module / area: discovery / core (audio)
Related issue / US: —
Type of Change
fix— bug fixtest— tests onlyChecklist
develop(notmain)feature/*,bugfix/*, orhotfix/*bun run lintpasses locally (ESLint + angular-eslint)bun run testpasses locally (Vitest) — 271 passed (+1 new)bun run buildpasses locally (no type errors, no budget exceeded)ChangeDetectionStrategy.OnPushand Angular signals — N/A (no new components)localStorage/sessionStorageaccess for JWT tokens (use the auth store)bypassSecurityTrust*calls without explicit review.envcontent committedCHANGELOG.mdupdated under[Unreleased]— omitted: two small internal fixes; can add if requiredHow to Test
[discovery] Unhandled realtime message type:warning appears instead of silence.bun run test— includes the new store spec for the unknown-type warning.Notes (optional)
Backend audit found no code defects to fix; the two known critical issues (wire-type discriminator race, suggestion-watermark clobbering live transcription) were already fixed on
develop(844fda3, 587344a). Demo-setup reminders: the presenting user needs a role withSESSION_RUN/SESSION_DECIDE(base READ floor only grants viewing), and LLM/embedding provider availability should be checked before going live (degradation is silent by design).