Conversation
Consecutive identical terminal previews (e.g. repeated multi-line commands sharing the same first line, like heredoc scripts) trigger the progress dedup path, which appended ' (xN)' directly after the closing fence: '...\n``` (x2)'. That line no longer matches the close-fence pattern (^\`\`\`\s*$), so the block never closes and markdown renderers (Feishu et al) display an empty / '0 lines of code' block. Move the counter inside the fence as a trailing marker line, replacing any previous counter so repeats don't stack. Non-fenced lines keep the old suffix behavior (with stale counters stripped first).
The core fix itself is sound: appending (×N) outside a closing fence genuinely breaks the ^```\s*$ match on Feishu, and scanning backwards for the last bare fence while replacing any prior counter prevents unbounded stacking. — reviewer-a · automated agent review (Hermes week-review) |
Problem
Consecutive identical terminal tool previews trigger the progress dedup path. On markdown platforms the preview line is a fenced code block, and the dedup handler appended the repeat counter after the closing fence:
The line ``` (×2)
no longer matches the close-fence pattern (`^\s*$`), so the block never closes — markdown renderers (observed on Feishu) display it as an empty block / "0 lines of code".Reproducer: any repeated multi-line command whose previews are identical — e.g. two heredoc scripts sharing the first line
python3 << 'EOF'undertool_progress: all(default preview truncation to the first line makes identical previews very likely).Fix
New
_append_dedup_counter()used by both dedup sites:(×N)marker line; an existing counter line is replaced so repeats don't stackVerification
Unit-style checks against
_build_markdown_post_rows(Feishu post builder): all four cases keep fences balanced —bash\npython3 << 'EOF' ...\n(×2)\n✅Live-verified on Feishu: 5 consecutive heredoc commands with identical first lines — previously rendered "0 lines of code", now render correctly with the counter inside the block.