Skip to content

hunk diff doesn't show "unchanged files" after the last change #1154

Open

Description

@mocheng

What happened?

version 0.23.0

In Hunk UI, there is no "unrecognized lines" after the last change in one file.

Steps to reproduce

Suppose there is a file with some change. The git diff output:

diff --git a/tippe_top.py b/tippe_top.py
index d808307..117cca7 100644
--- a/tippe_top.py
+++ b/tippe_top.py
@@ -2,6 +2,7 @@ import time
 import mujoco
 import mujoco.viewer

+
 tippe_top = """
 <mujoco model="tippe top">
   <option integrator="RK4"/>
@@ -45,6 +46,7 @@ mujoco.mj_resetDataKeyframe(model, data, key_id)
 #mujoco.mj_resetDataKeyframe(model, data, 0)
 mujoco.mj_forward(model, data)

+
 with mujoco.viewer.launch_passive(model, data) as viewer:
     viewer.opt.flags[mujoco.mjtVisFlag.mjVIS_JOINT] = True
     cam_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_CAMERA, "closeup")
(END)

In hunk diff, the UI is like this:

Image

Expected behavior

I would be appreciated that it also enable expand "unrecognized lines" from the last changed line to end of file.

Version

0.23.0

Activity

  1. liziye627-design commented on Oct 24, 2026

    @liziye627-design
    Contributor

    I reproduced this on main (8da0984, Linux, bun). I used a 63-line file with two inserted blank lines (lines 4 and 49), which leaves 11 unchanged lines after the last hunk. hunk diff shows the leading ··· 1 unchanged line ··· row and the ··· 38 unchanged lines ··· row between hunks, but nothing after the last hunk. The output stops at line 51/53 with no ··· 11 unchanged lines ··· row. A plain one-line modification behaves the same way, so this isn't limited to the zero-count case.

    Cause, as far as I can tell: reviewTrailingGap (packages/hunk/src/core/review/expansion.ts) returns nothing when isPartial is true. Every git-diff-sourced file is partial (core/changeset/diffFile.ts sets isPartial: true), because a patch doesn't carry the file's total line count. The terminal rows (buildSplitRows/buildUnifiedRows), the browser view and note validation all share this rule, so none of them offer a trailing gap. docs/browser-review-seam-audit.md (A2) says the trailing-gap work is staged separately, so I didn't want to open a PR without asking first.

    Possible approach:

    • Once the full source has been loaded through sourceFetcher, record the file's line count in core.
    • Have reviewTrailingGap derive the trailing gap from that count instead of bailing on isPartial. Until the source is known, it would keep returning nothing.
    • Make it a single change in core, so the terminal, the browser and note validation (reviewGapAddress, resolveReviewExpandedLine) keep agreeing on gap addresses.
    • Add tests for both the split and unified rows and for note validation.

    Would you like a PR along these lines? Or is there a design you'd prefer, for example loading line counts eagerly or keeping this tied to the staged A2 work? I'm happy to follow whichever direction you pick.

    (Drafted with AI assistance.)

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions