Skip to content

Fix Sherpa local ASR state sync#523

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

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

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 状态展示与删除可用性:Overview 会在 ASR/LLM provider 变化时刷新 credentials 状态,Sherpa 模型存在部分下载或已解压资源时允许删除。
  • 已基于最新 beta 解决设置页重构冲突:旧 Settings.tsx 不再进入本 PR,新版 settings/ProvidersSection.tsx 中已包含 sherpa-onnx-local 的本地 provider 识别逻辑。

验证

  • git diff --check upstream/beta...HEAD
  • 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

PR Type

Bug fix, Enhancement, Tests


Description

  • Sync active ASR provider on save/startup

  • Validate Sherpa extracted directories and bytes

  • Verify archives before extraction completes

  • Refresh overview credentials after provider changes


Diagram Walkthrough

flowchart LR
  P["User preferences"] -->|persist active ASR provider| C["Coordinator"]
  C -->|sync provider| V["Credentials vault"]
  D["Sherpa download manager"] -->|validate archive and extract| S["Local model files"]
  S -->|cached bytes and validity| U["Local ASR UI"]
  P -->|provider changes| O["Overview credentials refresh"]
Loading

File Walkthrough

Relevant files
Bug fix
6 files
sherpa.rs
Validate tokenizer directories and track bytes                     
+15/-1   
sherpa_download.rs
Verify extracted archives before completion                           
+114/-24
sherpa_runtime.rs
Use path-aware cache and byte snapshots                                   
+9/-2     
commands.rs
Sync active ASR provider during persistence                           
+28/-1   
lib.rs
Sync preferences on Windows startup                                           
+4/-0     
LocalAsr.tsx
Allow deleting partially downloaded models                             
+5/-2     
Enhancement
3 files
coordinator.rs
Add active ASR provider sync helpers                                         
+10/-0   
localAsr.ts
Update Sherpa catalog and command payloads                             
+20/-18 
Overview.tsx
Refresh credentials after provider changes                             
+11/-2   

@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

Persist Order

write_settings happens before sync_active_asr_provider, so if the vault update fails the new active_asr_provider is already persisted in preferences while the backend still uses the old one. That leaves the app in the inconsistent state this PR is trying to prevent until the next successful sync or restart.

coord.write_settings(prefs)?;
if active_asr_provider_changed {
    coord.sync_active_asr_provider(&active_asr_provider)?;
}

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