Skip to content

Work diff canvas treats removed '-- ' and added '++ ' lines as file headers #274

Closed

Description

@NopeCharon

Expected and actual behavior / 实际现象与期望

The Work attempt diff canvas (parse_unified_diff in server/unified_diff.py, called from WorkLedgerCoordinator for attempt diffs) should render every removed and added line of the attempt.

When a removed source line starts with -- (SQL, Lua and Haskell comments, Markdown -- signatures) or an added line starts with ++ , Git prefixes them to --- ... / +++ .... The parser checks for file-header markers before looking at hunk content, so these lines are treated as file headers inside a hunk:

  • the file is renamed in the canvas to the line content (e.g. path: "counter", oldPath: "legacy index");
  • the line is dropped from the hunk, and the file and total additions / deletions counts are understated;
  • the context line numbers after it no longer correspond to the hunk.

Steps to reproduce / 复现步骤

from server.unified_diff import parse_unified_diff

parse_unified_diff("""diff --git a/schema.sql b/schema.sql
--- a/schema.sql
+++ b/schema.sql
@@ -1,3 +1,3 @@
 CREATE TABLE t (id INT);
--- legacy index
+++ counter
 SELECT 1;
""")

Actual: one file with path == "counter", oldPath == "legacy index", additions == 0, deletions == 0, and only the two context lines in the hunk.

Expected: path == "schema.sql", one remove line (-- legacy index) and one add line (++ counter).

This is the exact output of git diff after replacing a line -- legacy index with ++ counter in a tracked file.

Relevant environment / 使用环境

Platform-independent; current main (65cea5f). Affects any Work attempt whose diff removes a line starting with -- or adds one starting with ++ .

Sanitized evidence / 错误信息或截图(请先脱敏)

Hunk headers already declare how many old/new lines follow (@@ -1,3 +1,3 @@), and the parser reads those counts into oldCount / newCount. Inside a hunk, --- / +++ can only be file headers once those counts have been consumed.

Related issues or fixes / 相关问题或修复

None found.

Activity

  1. Lucas1479 commented on Oct 31, 2026

    @Lucas1479
    Member

    Resolved by #275, squash-merged as fdd672ec. All 15 checks across 5 workflows passed on the updated head 0290f68a64d3cc9162075e1e6958cc10c4f8985c, including the complete Windows audit, source/packaged application smoke, and catalog publication/recovery flow. The merged Git tree is identical to the tested head, and this issue has closed automatically.

    The initial CI blocker was the pyasn1 0.6.4 dependency inherited from main. It was repaired separately in #277 by updating only that lockfile entry to 0.6.5. All 18 checks across 8 workflows passed before #277 was merged as 4c541f0d. No audit exception or CI requirement was weakened.

    The parser and test blobs in #275 remained byte-identical to the reviewed version after the base update. Independent review found no blocking correctness or regression issues: the initial 28 targeted tests passed; the new regression failed on the base implementation and passed with the fix; real Git diffs covering 35 files at four context sizes and 112 file/line truncation combinations passed. The composition with the repaired dependency additionally passed 30 targeted tests. Thank you for the clear reproduction and focused fix.


    已由 #275 修复,并 squash 合并为 fdd672ec。更新后的提交 0290f68a64d3cc9162075e1e6958cc10c4f8985c 的 5 个工作流、15 项检查全部通过,包括完整的 Windows 审计、源码/打包应用 smoke,以及目录发布/恢复流程。已确认合并后的 Git 树与通过 CI 的提交完全一致,此 issue 也已自动关闭。

    最初的 CI 阻塞来自 main 已有的 pyasn1 0.6.4 依赖,已通过独立的 #277 修复,仅将锁文件中的该包更新到 0.6.5。#277 的 8 个工作流、18 项检查全部通过后,已合并为 4c541f0d。未放宽任何依赖审计豁免或 CI 要求。

    更新基线后,#275 的解析器和测试文件仍与已审查版本逐字节相同。独立审查未发现阻塞合并的正确性或回归问题:最初的 28 个针对性测试通过;新增回归测试在基线上失败、修复后通过;35 个文件、4 种上下文范围的真实 Git diff 和 112 组文件数/行数截断组合均通过。与已修复依赖组合后的 30 个针对性测试也通过。感谢提供清晰的复现和范围集中的修复。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions