fix(remote): 听写完成后 emit remote:result,手机端才能看到识别结果 (#691)#692
Conversation
remote_server 的 WS handler 订阅了 "remote:result" 并转发给手机、H5 也准备好显示,
但全仓没有任何一处 emit 该事件——手机端结果区永远空。
在 finalize(history.append 之后)按已有 app.emit("vocab:updated", ...) 同模式
emit 最终文字 polished 到 "remote:result"(非空才发)。无手机连接时无人转发 = 无害空操作。
|
@claude 请审核:补上从未 emit 的 remote:result,手机端才能看到识别结果。重点看 (1) emit 时机放在 history.append 之后是否合适、polished 是否就是最终落字文本;(2) String payload 与 remote_server 侧 from_str:: 是否对得上;(3) 是否应只在远程会话时 emit(本 PR 选择总是 emit,理由:无手机连接时无人转发、且连着手机通常就是在用远程输入)。 |
|
Claude finished @appergb's task in 2m 4s —— View job 代码审核:
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR 合并冲突提示(听写模块)本 PR 与 #682、#688、#666 均修改了 openless-all/app/src-tauri/src/coordinator/dictation.rs。 实测结论:
建议: 若 #666 也会合,请在合并前与 #666 作者协调顺序——要么先合本 PR 三件套再 rebase #666,要么先合 #666 再 rebase 本 PR。 (维护者批量 merge 时可参考此顺序。) |
User description
关联 issue
Closes #691
问题
remote_server/mod.rs的 WS handler 订阅了"remote:result"并把{type:"result", text}转发给手机、H5 也准备好显示,但全仓没有任何一处emit("remote:result", ...)→ 手机端结果区永远空(状态会动,结果文本不出)。改动(单一职责)
在听写 finalize(
coordinator/dictation.rs,history.append_with_retention之后)emit 最终文字polished到"remote:result",与同函数里已有的app.emit("vocab:updated", ...)完全同模式(inner.app.lock().clone()取 AppHandle)。非空才发;无手机连接时无人转发 = 无害空操作。payload 是
String→ tauri 序列化为带引号 JSON 字符串,正是 remote_server 那侧serde_json::from_str::<String>期望的格式。本地编译通过(emit 是副作用,无单测);需手机真机验证:远程输入一次,手机结果区出现最终文字。
注:审计另发现「任意 WS 关闭无条件
cancel_remote_dictation(双手机/重连时取消他人听写)」属另一独立 bug,单独跟进,不在本 PR。PR Type
Bug fix
Description
在听写 finalize 时 emit "remote:result" 事件
修复手机端永远看不到识别结果的 bug
非空文本才发送,无手机连接时无害
Diagram Walkthrough
File Walkthrough
dictation.rs
添加 remote:result 事件发射openless-all/app/src-tauri/src/coordinator/dictation.rs
end_session的history.append_with_retention之后添加事件发射polished非空时,通过inner.app.lock().clone()获取AppHandle并 emitvocab:updated的发射模式一致