From 2fc1c3aef1e7934efeb1125210f4b97dbbb17414 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Wed, 03 Jun 2026 18:36:42 +0800
Subject: [PATCH] Fix engine status updates after model reload
---
02-P-NBL/round-5/qa-report.md | 2 +-
privatevoice.src/services/engine_service.go | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/02-P-NBL/round-5/qa-report.md b/02-P-NBL/round-5/qa-report.md
index 63e1403..431a1e8 100644
--- a/02-P-NBL/round-5/qa-report.md
+++ b/02-P-NBL/round-5/qa-report.md
@@ -128,7 +128,7 @@
## 7. 未完成项
- 物理断网后的 App 级 Qwen3-ASR 识别尚未执行。当前已验证引擎级本地识别不依赖远程服务,但未关闭真实网络做 App 全流程测试。
-- UI 可视 smoke 没有完整执行,因为菜单栏 App 未稳定暴露可自动抓取的设置窗口;已通过服务逻辑、配置重启和日志完成模型路径验证。
+- UI 可视 smoke 发现过一次模型卡片和底部 Engine 状态不同步:模型列表已切到 English/Moonshine,但底部仍显示 SenseVoice。原因是后端 `EngineService.SetStatus` 更新内部状态后没有主动发 `engine:status` 事件,前端可能显示旧硬件信息。本轮已修复:状态变化时主动向前端 emit。
## 8. 结论
diff --git a/privatevoice.src/services/engine_service.go b/privatevoice.src/services/engine_service.go
index d40c951..a5463a5 100755
--- a/privatevoice.src/services/engine_service.go
+++ b/privatevoice.src/services/engine_service.go
@@ -159,10 +159,18 @@
func (s *EngineService) SetStatus(status, hardwareInfo, lastError string) {
s.mu.Lock()
- defer s.mu.Unlock()
s.status = status
s.hardwareInfo = hardwareInfo
s.lastError = lastError
+ s.mu.Unlock()
+
+ if s.app != nil {
+ s.app.Event.Emit("engine:status", map[string]interface{}{
+ "status": status,
+ "hardwareInfo": hardwareInfo,
+ "error": lastError,
+ })
+ }
}
// DownloadModel downloads the ASR model with progress events.
--
Gitblit v1.9.3