Skip to content

refactor(live): simplify reorder client - #12

Merged
xarthurx merged 2 commits into
mainfrom
refactor/live-reorder-client
Jun 4, 2026
Merged

refactor(live): simplify reorder client#12
xarthurx merged 2 commits into
mainfrom
refactor/live-reorder-client

Conversation

@xarthurx

@xarthurx xarthurx commented Jun 4, 2026

Copy link
Copy Markdown
Owner

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-tauri streaming only — live.rs, realtime_openai_compatible.rs, reorder.rs (-53 / +64).

Provenance

Originally committed as 96b9efb on the bilingual feature branch after PR #11's merge head, so it was not part of #11. Cherry-picked cleanly onto merged main; original authorship preserved.

Test plan

  • cargo test — full suite green on top of main (189 lib + 6 streaming integration tests, 0 failed)
  • Manual Live-mode out-of-order spot check

…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.
Copilot AI review requested due to automatic review settings June 4, 2026 08:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_blocked semantics/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.
@xarthurx
xarthurx merged commit a3d8ddf into main Jun 4, 2026
1 check passed
@xarthurx
xarthurx deleted the refactor/live-reorder-client branch June 4, 2026 09:20
xarthurx added a commit that referenced this pull request Jun 4, 2026
PR #11 (feat/bilingual-language-mode): Auto / Single / Bilingual output-language mode. PR #12 (refactor/live-reorder-client): fix + simplify the Live reorder client so utterances type in spoken order.
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.

2 participants