Skip to content

Fix Sherpa local ASR state sync#522

Closed
weikeyi wants to merge 1 commit into
Open-Less:betafrom
weikeyi:fix/sherpa-local-asr-state-sync
Closed

Fix Sherpa local ASR state sync#522
weikeyi wants to merge 1 commit into
Open-Less:betafrom
weikeyi:fix/sherpa-local-asr-state-sync

Conversation

@weikeyi
Copy link
Copy Markdown
Contributor

@weikeyi weikeyi commented May 22, 2026

User description

摘要

  • 在设置变更和 Windows 启动时,将持久化的 active ASR provider 同步到后端运行时的 credentials vault,避免前端偏好与实际听写 provider 状态不一致。
  • 让 Sherpa ONNX catalog/download 状态与已解压的 release archive 资源保持一致,包括 Qwen3 tokenizer/ 目录校验和 downloadedBytes 统计。
  • 更新前端对 Sherpa ONNX provider 的识别:Overview / Settings 可正确显示 sherpa-onnx-local,并且 Sherpa 模型存在部分下载或已解压资源时允许删除。

验证

  • git diff --check
  • cargo check --manifest-path openless-all/app/src-tauri/Cargo.toml
  • npm run build
  • cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml sherpa --lib -- --nocapture
  • cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml persist_settings --lib -- --nocapture
  • cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml --lib ⚠️ 本地存在 2 个与本 PR 无关的既有失败:
    • asr::whisper::tests::transcribe_posts_single_request_without_chunk_limit
    • asr::whisper::tests::transcribe_splits_requests_when_chunk_limit_is_set

本 PR 未修改任何 Whisper 相关文件。


PR Type

Enhancement, Bug fix, Tests


Description

  • Sync active ASR provider to vault

    • on settings save
    • during Windows startup
  • Improve Sherpa archive validation

    • accept extracted tokenizer/ directories
    • track downloaded bytes from assets
  • Recognize sherpa-onnx-local in UI

    • hide it from cloud presets
    • allow delete after partial extraction
  • Refresh credentials on provider changes


Diagram Walkthrough

flowchart LR
  A["Settings save"] -- "sync provider" --> B["Coordinator"]
  C["Windows startup"] -- "sync provider" --> B
  B -- "update vault" --> D["Credentials vault"]
  E["Sherpa download"] -- "verify archive" --> F["Extracted assets"]
  F -- "compute cached bytes" --> G["Catalog state"]
  G -- "update UI" --> H["Local ASR pages"]
  H -- "show provider" --> I["Overview and Settings"]
Loading

File Walkthrough

Relevant files
Enhancement
8 files
sherpa.rs
Add directory-aware Sherpa path validation                             
+15/-1   
sherpa_runtime.rs
Use path validation in catalog snapshots                                 
+9/-2     
coordinator.rs
Add vault sync helpers for ASR                                                     
+10/-0   
lib.rs
Sync preferences at Windows startup                                           
+4/-0     
localAsr.ts
Update Sherpa API shapes and mocks                                             
+20/-18 
LocalAsr.tsx
Enable delete for extracted Sherpa models                               
+5/-2     
Overview.tsx
Refresh credentials for local ASR changes                               
+11/-2   
Settings.tsx
Add Sherpa provider to local presets                                         
+8/-4     
Bug fix
2 files
sherpa_download.rs
Verify downloads and count extracted bytes                             
+114/-24
commands.rs
Sync active ASR provider on persist                                           
+28/-1   

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Stale Sync

The vault sync now only runs when active_asr_provider changes, so saving other settings while the provider stays the same will not repair a drifted or cleared vault entry. In that case the UI preferences can remain saved while the runtime still uses the old provider until the next startup sync.

let active_asr_provider_changed = previous.active_asr_provider != prefs.active_asr_provider;
let active_asr_provider = prefs.active_asr_provider.clone();
coord.write_settings(prefs)?;
if active_asr_provider_changed {
    coord.sync_active_asr_provider(&active_asr_provider)?;
}

@weikeyi weikeyi closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant