refactor(live): simplify reorder client - #12
Merged
Conversation
…to client Quality pass on the reorder fix (no behavior change): - parse_event takes &Value; poll_event parses each message once instead of twice (logging + dispatch) - ReorderBuffer::is_blocked now means head-missing (pending non-empty AND next_emit absent), matching its doc - head-of-line timeout state + const moved from the audio pump into the client as check_reorder_timeout(now), removing the reorder_blocked / skip_reorder_head pass-through wrappers 189 lib + 6 integration tests green; clippy clean on the changed files.
There was a problem hiding this comment.
Pull request overview
Refactors the Live-mode streaming reorder path to centralize head-of-line timeout policy in the WebSocket client and reduce redundant JSON parsing, as a cleanup follow-up to the prior out-of-order reorder fix.
Changes:
- Parses each incoming WS event JSON once (reusing it for logging + dispatch).
- Moves reorder head-of-line timeout tracking from the Live audio pump into
RealtimeOpenAiCompatibleClient. - Tightens
ReorderBuffer::is_blockedsemantics/documentation to reflect true head-of-line blocking.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src-tauri/src/transcription/streaming/reorder.rs | Refines is_blocked() definition/doc to represent “pending + missing head” blocking. |
| src-tauri/src/transcription/streaming/realtime_openai_compatible.rs | Single-pass event JSON parsing; adds reorder HOL timeout state/method in the client; adapts parser signature and updates tests. |
| src-tauri/src/commands/live.rs | Removes reorder timeout logic from the pump loop and delegates timeout ticking to the client. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let value = parsed.context("parse event json")?; | ||
|
|
||
| match parse_event(&text)? { | ||
| match parse_event(&value)? { |
The skip-head timer (blocked_since) was only cleared when the buffer became unblocked or the timeout fired. When a completion advanced the head onto a *new* still-missing rank (e.g. rank 0 lands while rank 1 is still absent), the timer kept measuring from the earlier block, so the newly-exposed head could be skipped well before REORDER_HEAD_TIMEOUT — surfacing an utterance out of order. Route completions through ingest_completed(), which resets the timer when the head advances (detected via ReorderBuffer::head()). Keyed on head movement, not text release, so advancing past a silent (empty) rank re-arms it too. Adds a regression test. Addresses the GitHub Copilot review on PR #12.
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.
Summary
Follow-up cleanup to the Live out-of-order reorder fix that shipped in #11. Simplifies the reorder client: parse each completion once instead of re-parsing, and fold the reorder timeout handling into the client.
Touches
src-tauristreaming only —live.rs,realtime_openai_compatible.rs,reorder.rs(-53 / +64).Provenance
Originally committed as
96b9efbon the bilingual feature branch after PR #11's merge head, so it was not part of #11. Cherry-picked cleanly onto mergedmain; original authorship preserved.Test plan
cargo test— full suite green on top ofmain(189 lib + 6 streaming integration tests, 0 failed)