fix(windows): 粘贴前校验原目标窗口已恢复#121
Conversation
There was a problem hiding this comment.
Sorry @Cooper-X-Oak, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c177634a0c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| std::thread::sleep(Duration::from_millis(60)); | ||
|
|
||
| let foreground = unsafe { GetForegroundWindow() }; | ||
| if foreground != hwnd { |
There was a problem hiding this comment.
Wait for target activation before aborting paste
After SetForegroundWindow, the code sleeps a fixed 60ms and then does a single GetForegroundWindow check; if it still differs, insertion is downgraded to CopiedFallback. On Windows, foreground activation across input queues can complete asynchronously, so this can produce false negatives under load or with slow target UIs (the target becomes foreground shortly after the check), causing missed auto-paste even when restore would have succeeded. This regression was introduced by the new guard path and can reduce insertion reliability for real users.
Useful? React with 👍 / 👎.
Closes #96
修复要点
Windows 插入链路此前已经会在录音开始时记录原前台窗口,并在插入前尝试恢复。但恢复结果没有被验证:如果
SetForegroundWindow失败,后续仍可能继续盲发Ctrl+V,文本就有机会粘到当前错误窗口。本 PR 把 Windows 插入改成“先证明目标可接收,再发送粘贴”:
Ctrl+V。copiedFallback,避免误粘到错误窗口。pasteSent语义:它仍表示“快捷键已发送”,不夸大成已证明控件接收。copiedFallback作为通过条件,并要求目标窗口回读包含最新finalText。Windows low-level keyboard hook/hotkey listener installed日志文案。-ManualSpeech模式,允许真人对真实麦克风说话,避免系统 TTS 无法进入麦克风时误判 real-ASR smoke。测试计划
npm run buildcargo +stable-x86_64-pc-windows-gnu check --lib --manifest-path openless-all\app\src-tauri\Cargo.toml --target x86_64-pc-windows-gnunpm run tauri build -- --target x86_64-pc-windows-gnu --no-bundleopenless-all/app/scripts/windows-real-asr-insertion-smoke.ps1git diff --checkwindows-real-asr-insertion-smoke.ps1 -Target notepad -ManualSpeech -DebugHotkeyEvents:真实麦克风完整通过。证据:history raw=剩下一个火山引擎的 secret 是没有用,是吗?,insertStatus=pasteSent,notepad readback length=25。windows-real-asr-insertion-smoke.ps1 -Target browser -ManualSpeech -ManualSpeechSeconds 15 -DebugHotkeyEvents:真实麦克风完整通过。证据:history raw=在许多 Microsoft 的时候会随时登记一个个信息。,insertStatus=pasteSent,browser readback length=30。备注
本 PR 已在 Windows 本机用真实麦克风完成 notepad 与 browser 两类目标回写验证。测试过程中曾遇到浏览器首次启动弹窗导致临时窗口句柄失效,guard 正确降级为
copiedFallback,没有盲贴到错误窗口;关闭弹窗并重跑后 browser smoke 通过。