fix(review): 批注去重 + 删除残留调试截图
- annotator.annotate:同一 handle 只批注一次(修复 created 无去重的既有 gap, 同 handle 出现两次不再产生重复引线) - 删除 test_screenshot.png(已删除脚本 test_autoagent.py 的残留产物)
This commit is contained in:
1 parent
f7fa8f14d9
commit
81d8c3d2ca
3 files changed
+8
-7
No files matched your search
@@ -36,11 +36,13 @@ def annotate(ctx, issues, *, dry_run=False, log=print):
|
||||
"""按问题列表回写批注,返回 (created, highlighted) 两个 handle 列表。"""
|
||||
created = []
|
||||
highlighted = []
|
||||
seen = set() # 同一 handle 只处理一次,避免重复批注
|
||||
|
||||
for issue in issues:
|
||||
handle = issue.get("handle")
|
||||
if not handle:
|
||||
if not handle or handle in seen:
|
||||
continue
|
||||
seen.add(handle)
|
||||
|
||||
text = f"[{issue.get('severity', '?')}] {issue.get('message', '')}"
|
||||
|
||||
@@ -81,8 +83,6 @@ def annotate(ctx, issues, *, dry_run=False, log=print):
|
||||
continue
|
||||
|
||||
# 引线建好后再高亮原实体(失败不影响已创建的批注)
|
||||
if handle in highlighted:
|
||||
continue
|
||||
try:
|
||||
ctx.tools.call("highlight_entities", {"handle": handle, "color": 1})
|
||||
highlighted.append(handle)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 243 KiB |
@@ -120,8 +120,8 @@ def test_annotate_handles_multiple_created_entities():
|
||||
assert created == ["N1", "N2"]
|
||||
|
||||
|
||||
def test_annotate_created_not_deduped_known_gap():
|
||||
"""已知瑕疵:同一 handle 出现两次会创建两条批注(created 无去重,仅 highlighted 去重)。"""
|
||||
def test_annotate_dedupes_repeated_handle():
|
||||
"""同一 handle 出现两次只批注一次(created 与 highlighted 均去重)。"""
|
||||
ctx = make_ctx(client=build_client())
|
||||
created, highlighted = annotate(
|
||||
ctx,
|
||||
@@ -131,8 +131,9 @@ def test_annotate_created_not_deduped_known_gap():
|
||||
],
|
||||
log=lambda *a: None,
|
||||
)
|
||||
assert created == ["NEW1", "NEW1"] # 重复批注(期望去重)
|
||||
assert highlighted == ["A"] # 高亮已去重
|
||||
assert created == ["NEW1"]
|
||||
assert highlighted == ["A"]
|
||||
assert len(ctx.client.called("add_leader_annotation")) == 1
|
||||
|
||||
|
||||
def test_annotate_propagates_protocol_error_on_detail():
|
||||
|
||||
Reference in new issue
Block a user