fix(next-macos-native): stabilize reformat smoke acceptance waits

Extend format busy timeout and poll for undo/history before asserting text reformat in smoke; note occasional smoke rerun in verification.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
RememBerBerandCursor committed 2026-09-16 15:18:28 +08:00
1 parent 8d2d7fb6ef
commit ee738d0d83
2 files changed
+14 -2

No files matched your search

@@ -15,6 +15,7 @@ import MooToolNextCore
}
try pressFormat(window)
try await finish(draft, window)
try await waitForTextFormat(draft: draft, editor: editor, store: store, window: window)
guard draft.error == nil, draft.input.contains("\n"), editor.undoManager?.canUndo == true,
store.history.first(where: { $0.toolID == "reformat" })?.draft.output == draft.input else {
throw ToolError("格式化验收:文本结果、撤销或历史不一致:\(draft.error ?? "")")
@@ -43,12 +44,23 @@ import MooToolNextCore
guard try store.repository.load().drafts["reformat"]?.reformat == draft.reformat else { throw ToolError("格式化验收:文件工作区未持久化。") }
}
private static func finish(_ draft: ToolDraft, _ window: NSWindow) async throws {
for _ in 0..<50 {
for _ in 0..<100 {
try await Task.sleep(for: .milliseconds(100))
if !draft.busy { try await settle(window); return }
}
throw ToolError("格式化验收:格式化操作未结束。")
}
private static func waitForTextFormat(draft: ToolDraft, editor: NSTextView, store: AppStore, window: NSWindow) async throws {
for _ in 0..<40 {
if draft.error == nil, draft.input.contains("\n"), editor.undoManager?.canUndo == true,
store.history.first(where: { $0.toolID == "reformat" })?.draft.output == draft.input {
return
}
try await Task.sleep(for: .milliseconds(100))
try await settle(window)
}
}
private static func settle(_ window: NSWindow) async throws {
window.contentView?.layoutSubtreeIfNeeded(); window.displayIfNeeded()
try await Task.sleep(for: .milliseconds(400))
+1 -1
View File
@@ -7,7 +7,7 @@
| 命令 | 结果 | 说明 |
| --- | --- | --- |
| `./scripts/check-core.sh` | 59 组,0 失败 | 含 SQLite 导入(HTTP/Host/翻译/收藏/历史/草稿/`t_quick_note`/`t_json_beauty`) |
| `./scripts/smoke.sh` | 通过 | 附件、随手记、JSON、文档库选区/滚动、86 张截图、重启持久化 |
| `./scripts/smoke.sh` | 通过(偶发需复跑) | 附件、随手记、JSON、格式化、文档库选区/滚动、86 张截图、重启持久化;与 SwiftPM 并发时格式化验收可能需等待更久 |
最近一次 smoke 全绿:**2026-09-16** — 关闭主窗口 `closeBehavior` 合入后复跑通过(约 8.4 min);同日 `t_quick_note` / `t_json_beauty`、托盘与 `t_func_content` 亦全绿。