fix(windows): 收口录音会话失败态#66
Merged
appergb merged 1 commit intoApr 30, 2026
Merged
Conversation
Reviewer's GuideAdds explicit ASR credential gating before starting Windows recording sessions and records empty ASR transcripts as failed dictation history entries, preventing them from flowing through the normal success/polishing/insertion pipeline. Sequence diagram for Windows begin_session ASR credential gatingsequenceDiagram
actor User
participant WindowsApp
participant Coordinator
participant CredentialsVault
participant CapsuleEmitter
User->>WindowsApp: trigger_recording
WindowsApp->>Coordinator: begin_session
Coordinator->>CredentialsVault: get_active_asr
CredentialsVault-->>Coordinator: active_asr
alt active_asr == whisper
Coordinator->>CredentialsVault: get AsrApiKey
CredentialsVault-->>Coordinator: api_key
alt api_key is empty
Coordinator->>Coordinator: ensure_asr_credentials returns Err
Coordinator->>CapsuleEmitter: emit_capsule Error
Coordinator->>Coordinator: set SessionPhase Idle
Coordinator-->>WindowsApp: Err message
else api_key present
Coordinator->>Coordinator: ensure_asr_credentials returns Ok
Coordinator->>Coordinator: proceed to ensure_microphone_permission
end
else active_asr != whisper (Volcengine)
Coordinator->>Coordinator: read_volc_credentials
Coordinator-->>Coordinator: creds app_id, access_token
alt app_id or access_token empty
Coordinator->>Coordinator: ensure_asr_credentials returns Err
Coordinator->>CapsuleEmitter: emit_capsule Error
Coordinator->>Coordinator: set SessionPhase Idle
Coordinator-->>WindowsApp: Err message
else volc credentials present
Coordinator->>Coordinator: ensure_asr_credentials returns Ok
Coordinator->>Coordinator: proceed to ensure_microphone_permission
end
end
Sequence diagram for end_session empty transcript handlingsequenceDiagram
participant Coordinator
participant AsrProvider
participant HistoryStore
participant CapsuleEmitter
Coordinator->>AsrProvider: end_session collect_raw_transcript
AsrProvider-->>Coordinator: RawTranscript text, duration_ms
Coordinator->>Coordinator: check raw.text.trim().is_empty()
alt raw text is empty
Coordinator->>HistoryStore: append DictationSession
HistoryStore-->>Coordinator: append Result
Coordinator->>CapsuleEmitter: emit_capsule Error
Coordinator->>Coordinator: set SessionPhase Idle
Coordinator-->>AsrProvider: Err empty transcript
else raw text non empty
Coordinator->>CapsuleEmitter: emit_capsule Polishing
Coordinator->>Coordinator: polish_or_passthrough
end
Updated class diagram for coordinator ASR gating and dictation session failureclassDiagram
class Inner {
+Prefs prefs
+HistoryStore history
+State state
}
class Prefs {
+PrefsValue get()
}
class PrefsValue {
+PolishMode default_mode
}
class State {
+SessionPhase phase
}
class SessionPhase {
<<enumeration>>
Idle
Recording
Polishing
Inserting
Error
}
class DictationSession {
+String id
+String created_at
+String raw_transcript
+String final_text
+PolishMode mode
+String app_bundle_id
+String app_name
+InsertStatus insert_status
+String error_code
+u64 duration_ms
+u32 dictionary_entry_count
}
class InsertStatus {
<<enumeration>>
Pending
Succeeded
Failed
}
class HistoryStore {
+Result append(DictationSession session)
}
class RawTranscript {
+String text
+u64 duration_ms
}
class CredentialsVault {
+String get_active_asr()
+Result get(CredentialAccount account)
}
class CredentialAccount {
<<enumeration>>
AsrApiKey
}
class CoordinatorModule {
+Result begin_session(Inner inner)
+Result end_session(Inner inner)
+Result ensure_microphone_permission(Inner inner)
+Result ensure_asr_credentials()
+void emit_capsule(Inner inner, CapsuleState state, float progress, u64 elapsed, String message, String payload)
+Vec enabled_phrases(Inner inner)
}
class CapsuleState {
<<enumeration>>
Idle
Recording
Polishing
Inserting
Error
}
Inner --> Prefs
Inner --> HistoryStore
Inner --> State
HistoryStore --> DictationSession
DictationSession --> InsertStatus
CoordinatorModule --> Inner
CoordinatorModule --> RawTranscript
CoordinatorModule --> CredentialsVault
CredentialsVault --> CredentialAccount
CoordinatorModule --> CapsuleState
CoordinatorModule --> SessionPhase
CoordinatorModule --> InsertStatus
CoordinatorModule --> DictationSession
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
ensure_asr_credentials, treating any non-"whisper"value fromCredentialsVault::get_active_asr()as Volcengine could give misleading errors if a new ASR provider is configured; consider matching explicitly on known providers and returning a distinct error for unknown/unsupported values. - The "ASR returned empty transcript" error string is duplicated in
end_session; consider extracting this into a shared constant or error type so that the user-facing message and any future mapping to error codes stay consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `ensure_asr_credentials`, treating any non-`"whisper"` value from `CredentialsVault::get_active_asr()` as Volcengine could give misleading errors if a new ASR provider is configured; consider matching explicitly on known providers and returning a distinct error for unknown/unsupported values.
- The "ASR returned empty transcript" error string is duplicated in `end_session`; consider extracting this into a shared constant or error type so that the user-facing message and any future mapping to error codes stay consistent.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
da16537 to
08b6dd8
Compare
appergb
pushed a commit
that referenced
this pull request
Apr 30, 2026
包含本轮所有合并: - Codex 终审两条 HIGH (cancel race) 修复 (PR #79) - 6 个 Cooper-X-Oak/Codex bot PRs 自动合并 (#44 #49 #53 #68 #72 #73) - 2 个有冲突 PR 本地 rebase 后合并 (#66 cancel + 空转写并存 / #67 Windows docs) - README 破图修复 (PR #80) - workflow-scope 受限的 #48 + #75 由用户在 GitHub UI 直接合并 3 处版本字段同步:package.json + tauri.conf.json + Cargo.toml
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.
摘要
关联 fork 验证:Cooper-X-Oak#12。
本 PR 是从 fork/dev 已验证批次拆出的第五个最小 upstream 维护项:收口 Windows 录音会话失败态,避免缺 ASR 凭据或空转写继续走成功/插入链路。
fork/dev 先行验证
b9ee8b8。修复 / 新增 / 改进
insertStatus=failed、errorCode=emptyTranscript。兼容
测试计划
npm run buildopenless-all/app/scripts/windows-build-gnu.ps1git diff --checkSummary by Sourcery
Enforce ASR credential validation and empty-transcript handling in the Windows recording session lifecycle to prevent failed dictations from proceeding as successful sessions.
Bug Fixes: