Skip to content

Detail code diff processing #3

Description

@kination

Overview

Improve the diff engine and write-permission flow for more accurate, readable code change previews.

Current State

diff.rs uses a basic LCS diff with ±3 line context windows. It works for small edits but has gaps:

  • No syntax-aware diffing (a renamed variable shows as full remove + add)
  • Context window is fixed at 3 lines regardless of change density
  • No line number display in the diff box
  • Multi-file responses with partial rewrites aren't handled well

Proposed Work

  • Add line numbers to the diff output (│ 42 + new line)
  • Make context window size configurable (default 3, expand when changes are dense)
  • Handle partial file rewrites: if the model returns only a function body, apply it as a targeted patch rather than replacing the whole file
  • Add a dry-run mode that prints the would-be diff without prompting
  • Improve parse_blocks to detect more filename hint patterns (e.g., # filename, /* path */, fenced info strings like ```rust src/main.rs)

Notes

  • compute_diff and with_context in diff.rs are the main targets
  • Keep the LCS core — just improve the rendering and partial-apply logic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions