Skip to content

fix(desktop): 界面检查的结果没送到程序时重新发送,悬浮窗的检查不再漏进日志 - #250

Merged
sunerpy merged 1 commit into
mainfrom
fix/ui-guard-report-resend
Nov 10, 2026
Merged

sunerpy merged 1 commit into
mainfrom
fix/ui-guard-report-resend

Conversation

@sunerpy

@sunerpy sunerpy commented Nov 10, 2026

Copy link
Copy Markdown
Owner

问题

托管 macOS(Apple 芯片)上,菜单栏冒烟测试的悬浮窗界面检查失败过两次(CI 42546063667、42772486837):Voltip 的日志里始终没有悬浮窗那一行 the window runs the interface the program carries window="overlay"。第二次失败时悬浮窗照常显示了被拒绝的修改,说明同一个文档的其他调用(事件监听、状态)都送到了程序,只有界面检查的报告没有。

原因在 ui_guard.js:检查结果只发一次,程序拒收或一直没有回应时直接丢掉,也不留记录。页面的事件监听被拒时会重试(docs/dictation.md §33.2),这份报告没有。

改动

  • apps/desktop/src-tauri/src/ui_guard.js:报告发到程序收下为止。被拒收的隔 250 ms 再发,间隔加倍到最长 5 s(和事件监听的重试相同);5 秒没有回应的立刻再发;最多发 8 次,8 次都没送到时控制台说明一句。每次发送带着这个文档的标识。
  • apps/desktop/src-tauri/src/ui_guard.rs:晚到的回应和之后的那次发送可能都到,程序按文档标识每个文档只记一行(记得最近 64 个文档)。
  • docs/dictation.md §33.4、§33.6 和 docs/acceptance.md 对应更新。

用户看不到变化:检查本身不变,日志里每个窗口仍是一行。

测试

按仓库规定先写测试、在原代码上确认失败,再改代码:

  • apps/desktop/src/ui-guard.test.ts 新增 5 个(被拒收后再发、没有回应时再发、收到后不再发(包括晚到的回应)、一直被拒收时最多 8 次、每个文档的标识不同),实现之前 5 个都失败。
  • ui_guard.rs 的 regression_a_document_whose_report_came_twice_is_logged_once:同一文档的报告到了两次,实现之前记了两行。另加 the_program_remembers_the_latest_documents_it_logged。
  • 本地 make verify 通过(见下)。

这个失败大约 3% 的运行出现一次(之前 70 次左右的运行里 2 次),一两次 CI 证明不了修好,只能看之后 main 上的运行。合并前在分支上手动跑一次 CI,让两台 Mac 都跑菜单栏冒烟测试。

托管 macOS 上悬浮窗的界面检查结果两次没有进日志(CI 42546063667、42772486837),
同一文档的其他调用都送到了:悬浮窗照常显示了被拒的修改。ui_guard.js 原先只发一次报告,
被拒收或没有回应都不再发;页面的事件监听被拒时会重试(§33.2),报告没有。

- ui_guard.js:报告发到程序收下为止。被拒收的隔 250 ms 再发、间隔加倍到最长 5 s,
  5 秒没有回应的立刻再发,最多 8 次;每次发送带着文档的标识。
- ui_guard.rs:晚到的回应和之后的发送都到了时,每个文档只记一行(记得最近 64 个文档)。
- 测试先写、在原代码上失败:ui-guard.test.ts 新增 5 个,ui_guard.rs 的
  regression_a_document_whose_report_came_twice_is_logged_once。
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #250      +/-   ##
==========================================
+ Coverage   93.56%   93.58%   +0.02%     
==========================================
  Files         489      489              
  Lines       85860    85908      +48     
  Branches     4909     4909              
==========================================
+ Hits        80338    80401      +63     
+ Misses       4853     4838      -15     
  Partials      669      669              
Flag Coverage Δ
rust 93.83% <100.00%> (+0.02%) ⬆️
web 92.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
apps/desktop/src-tauri/src/ui_guard.rs 94.09% <100.00%> (+1.50%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sunerpy
sunerpy merged commit 23253e2 into main Nov 10, 2026
31 checks passed
@sunerpy
sunerpy deleted the fix/ui-guard-report-resend branch November 10, 2026 19:02
@github-actions github-actions Bot mentioned this pull request Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant