From cb0ac0778604e675931e0bd2078bfd3ea63cbe0c Mon Sep 17 00:00:00 2001 From: Woody Date: Wed, 6 May 2026 20:06:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20text=20accumulation=20=E2=80=94=20stashe?= =?UTF-8?q?s=20are=20sliding=20windows,=20merge=20via=20overlap=20detectio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DashScope stashes are ~7-char rolling windows, not cumulative. Each partial event replaces the previous. Completed events rarely sent. This caused text to jump/replace during streaming and disappear on pause. Backend: - Add _merge_stash() — finds overlapping suffix between successive stashes and appends only new characters, reconstructing full utterance from partials - format_transcription_event returns raw stash for read_events to merge - read_events maintains partial_buffer via _merge_stash, clears on completed - Guard against empty/whitespace-only stashes Frontend: - transcriptRef + onFinalTranscriptRef avoid stale closures in pause handler - stopStreaming fires onFinalTranscript(currentText) before clearing partial - Removed blind setPartialTranscript('') that erased text on pause Tests: 16/16 ws_protocol tests pass, frontend tests unchanged Plan: Updated phase2_implementation_plan.md to Complete with 11-bug log --- .plans/phase2_implementation_plan.md | 38 ++++++- backend/app/routers/ws_asr.py | 51 ++++++--- backend/app/test/test_phase2_ws_protocol.py | 68 ++++++++---- frontend/src/components/VideoPlayer.tsx | 1 + frontend/src/hooks/useVideoASR.ts | 114 ++++++++++++-------- 5 files changed, 190 insertions(+), 82 deletions(-) diff --git a/.plans/phase2_implementation_plan.md b/.plans/phase2_implementation_plan.md index 3ec3b70..339825e 100644 --- a/.plans/phase2_implementation_plan.md +++ b/.plans/phase2_implementation_plan.md @@ -1,8 +1,8 @@ # Phase 2: Video Upload + Video Audio ASR → RAG — Implementation Plan **Created:** 2026-05-06 -**Updated:** 2026-05-06 (video audio capture via createMediaElementSource; Full Transcript batch mode) -**Status:** Planning — Not Started +**Updated:** 2026-05-06 (all sub-phases complete; 11 bugs resolved) +**Status:** Complete **Depends on:** Phase 1 (Complete) --- @@ -311,7 +311,39 @@ frontend/src/pages/LTTPage.tsx, components/QueryInput.tsx, lib/api.ts, lib/queri --- -## 9. Reference Code (`.examples/`) +## 10. Bugs Resolved (11 Total) + +| # | Bug | Root Cause | Fix | +|---|-----|-----------|-----| +| 1 | Vite proxy missing | `/api` and `/ws` routes not proxied to backend port 8000 | Added proxy config in `vite.config.ts` | +| 2 | `crossOrigin` missing on `