Skip to content

Port lf-diff to the @pierre/diffs 1.7 renderer API #7430

Done

Description

@leaf-agent

@pierre/diffs 1.7.1 changes the API lf-diff renders through, so #7427 holds the package at 1.6.1. Dependabot will keep proposing 1.7.x, and the next group PR will fail the same way until lf-diff moves to the new API.

What 1.7.1 changes for Leaf:

  • Renderer output. DiffHunksRenderer.asyncRender no longer returns unifiedContentAST. Its HunksRenderResult holds row specs instead (columns.unified, a RowSpec[], plus preNode). renderFile in packages/diff/widgets/lf-diff.js passes highlighted.unifiedContentAST to renderHTML, so every diff fails with Cannot read properties of undefined (reading 'type'). The package exports no helper that turns the rows into the HAST lf-diff reads, and the data-line, separator and no-newline markup that renderedLines and the anchors depend on comes out of that step.
  • Parse options. parsePatchFiles(data, cacheKeyPrefix, throwOnError) becomes parsePatchFiles(data, { throwOnError }). ParseDiffOptions now extends the options of @pierre/patches, which have no comparator. Pierre still defaults to jsdiff and passes comparator through to it at runtime. replacementFile uses comparator: () => false so that a file-type change with identical text (the same-type-text row of test_a_diff_shows_native_file_metadata_without_empty_disclosures) still draws as a replacement.
  • Build seam. The word-diff code moved from utils/renderDiffWithHighlighter.js to utils/computeLineDiffRanges.js. The "Pierre changed-word distance" adaptation in build/vendor.mjs has to move there, returning NO_RANGES.

Checks that cover the port: test_a_diff_marks_changed_words_only_where_the_line_mostly_stayed, test_a_diff_shows_native_file_metadata_without_empty_disclosures and test_the_widget_reads_the_diff_patch_table in tests/browser/test_render_anchors.py.

Activity

  1. leaf-agent commented on Nov 27, 2026

    @leaf-agent
    CollaboratorAuthor

    #7432 ports lf-diff to 1.7.1 and bumps the pin. One correction to the issue: 1.7.1 doesn't need a new helper. Each row spec in columns.unified already carries the row's content element, and rendering those gives the same data-line, separator and no-newline markup 1.6.1's unifiedContentAST did. The only difference is contenteditable="false" on deletion, separator and no-newline rows. That attribute would have stopped a touch swipe begun on a diff row from moving an lf-deck card, so the PR also fixes that guard, with a test.

    The three checks the issue names fail with reading 'type' on 1.7.1 without the port and pass with it. Review and CI on the PR are still pending; landing goes through the usual bot path.

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