fix(gui): 实时查看器/状态 Tab 的耗时解析支持 ms 单位
问题:实际 actions.log 写的是 `耗时=10.00ms`(毫秒),但 _parse_minimal
和 parse_action_duration 的正则只匹配 `s`,导致:
- 实时查看弹窗永远显示"暂无动作"
- 实时状态 Tab 同样空白
同时存在的副 bug:兜底正则在整行匹配,前缀里的 `192.168.5.2:5555` /
日志时间戳 `2026-05-21` 都可能被误识别成耗时。
修复:
- 解析窗口限定到 line.find("耗时") 之后的子串 (tail)
- 优先匹配 ms(顺序很重要:\s*s 会先吃掉 "10ms" 的 m)
- s 单位加 (?![a-zA-Z]) 负向后顾,避免匹配 "ms" / "second" 之类
- 同步修复 gui_app.py:3685 的 parse_action_duration(实时状态 Tab)
测试:
- _parse_minimal 加 4 个新测试覆盖 ms / 整数 ms / 优先级 / 前缀干扰
- 全量 1426 passed (+5)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9f330572cc
commit
fe97e82104
3 files changed
+78
-28
No files matched your search
@@ -96,3 +96,30 @@ class TestParseMinimal:
|
||||
def test_integer_duration(self):
|
||||
result = _parse_minimal("步骤A 耗时:5s")
|
||||
assert result == ("步骤A", "5s")
|
||||
|
||||
def test_ms_unit(self):
|
||||
"""实际 actions.log 写的是 `耗时=10.00ms`,必须支持 ms 单位。"""
|
||||
result = _parse_minimal(
|
||||
"2026-05-21 14:59:00,513 - [ACTION] test step 耗时=10.00ms"
|
||||
)
|
||||
assert result is not None
|
||||
action, dur = result
|
||||
assert dur == "10.00ms"
|
||||
assert "test step" in action
|
||||
|
||||
def test_ms_integer(self):
|
||||
result = _parse_minimal("OCR识别 耗时=100ms")
|
||||
assert result == ("OCR识别", "100ms")
|
||||
|
||||
def test_ms_takes_priority_over_s(self):
|
||||
"""`10ms` 不能被错误识别为 `10` + `s` 的前半部分。"""
|
||||
result = _parse_minimal("click 耗时=10ms")
|
||||
assert result == ("click", "10ms")
|
||||
|
||||
def test_number_before_耗时_not_picked_up(self):
|
||||
"""前缀里的 `5555` / `192.168...` 不能被当成耗时。"""
|
||||
result = _parse_minimal(
|
||||
"192.168.5.2:5555 [ACTION] click 耗时=10ms"
|
||||
)
|
||||
assert result is not None
|
||||
assert result[1] == "10ms"
|
||||
Reference in new issue
Block a user