Skip to content

fix(core): propagate ASR errors and fail session with partial text#33

Merged
missuo merged 3 commits into
missuo:mainfrom
erning:fix/asr-error-handling
Mar 30, 2026
Merged

fix(core): propagate ASR errors and fail session with partial text#33
missuo merged 3 commits into
missuo:mainfrom
erning:fix/asr-error-handling

Conversation

@erning

@erning erning commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

Why

When an ASR transport error (WebSocket disconnect, provider error) occurred
after interim or definite text had been accumulated, the session continued
to LLM correction and pasted truncated text into the user's app. Additionally,
wait_for_final() silently swallowed AsrEvent::Error and read errors via
a wildcard match arm.

What changed

  • wait_for_final() now returns Option<String> and explicitly handles
    AsrEvent::Error and Err, propagating the error message to the caller.
  • The main session loop checks asr_error before inspecting accumulated
    text — any ASR error now fails the session immediately, discarding
    potentially truncated text.
  • Added MockAsrProvider test infrastructure and 8 unit tests covering
    error propagation and session failure behavior.

Test plan

  • cargo test -p koe-core --lib — 8 new tests pass
  • cargo clippy clean
  • Manual: start recording, disconnect network mid-session — should
    show error, not paste partial text

erning added 3 commits March 30, 2026 10:54
Add MockAsrProvider and tests that document two bugs:
1. wait_for_final() swallows AsrEvent::Error and read errors
2. Main loop continues to LLM with truncated text after ASR error

Change wait_for_final return type to Option<String> to enable error
propagation (implementation still buggy — fixes in next commits).
Handle AsrEvent::Error and read errors explicitly instead of
swallowing them via wildcard/silent return. Errors after
finish_input() are now returned to the caller and stored in
asr_error for proper session failure handling.
Previously, an ASR error (transport failure, provider error) was only
surfaced when no text had been accumulated. If interim/definite text
existed before the error, the truncated text would still go through
LLM correction and get pasted into the user's app.

Now check asr_error before inspecting text — any ASR error fails the
session immediately, discarding potentially truncated text.
@missuo missuo merged commit 553fec8 into missuo:main Mar 30, 2026
@erning erning deleted the fix/asr-error-handling branch March 31, 2026 01:35
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