Skip to content

Make collapsed diffs more visually distinct #7338

Closed

Description

@dimo414

Description

By default GitHub hides "large" diffs behind a "Load diff" link, nominally because the files are likely generated (such as lock files) or simply big enough to flood the page, however in my experience the thresholds / heuristics it uses to determine a diff should be collapsed are too permissive and fairly often hides relevant content, even hiding the "meat" of a PR (e.g. a particular class/module and its associated test files) and only displaying the secondary refactorings that aren't nearly as important as the hidden diffs.

Obviously there are some diffs that make sense to hide, even if GH's thresholds could be tuned, but what is particularly problematic is the "Load diff" UI is very nondescript. Scrolling through a large PR it's easy to miss, and ctrl-f-ing becomes useless when there are hidden diffs.

Some thoughts on potential improvements Refined could provide:

  • Change the color / formatting of the hidden-diff block to make it stand out more
  • Change the plain blue "Load diff" text to a larger and more visually obvious button element, possibly with a separate "Load all diffs" button alongside (see below)
  • Add an indication that there are hidden diffs at the top of the page, similar to the "0 / n files viewed" element
  • Change the UI of hidden-diff files in the sidebar, e.g. greying them out and/or adding a "load" / "load all" button in the sidebar
  • Detect when the user attempts to ctrl+f while there are hidden diffs on the page and display a warning

I came across #825 while searching the repo and it's useful, however it's hard to discover this feature (it'd be much nicer to add a "Load All Diffs" button to the page, and there isn't a tooltip or other UX to help users realize alt-clicking will do something) and b) it doesn't address the initial issue of realizing there are hidden diffs in the first place.

Example URLs

Not the best examples, since the PRs aren't otherwise very large, but you can at least see the behavior:

Activity

  1. added
    small
    and removed on Jun 5, 2024
  2. fregante commented on Jun 5, 2024

    @fregante
    Member

    This has been an issue for the longest time and the solution is simple:

    • add some CSS to make the file taller

    This might be a bit annoying for generated files like package-lock.json but it's otherwise obvious that large diffs take a large space on screen, even if hidden

  3. abhishek-yadav-ravsab commented on Sep 4, 2025

    @abhishek-yadav-ravsab
  4. simonepri commented on May 6, 2026

    @simonepri

    I'd like to contribute on this.

    Do you think it would make sense to move the generated files at the end of the file list (instead of hiding them, possibly with some visual separation)?
    On top of that, wdyt about just expanding all non-generated content? (maybe with some detection for pathological cases). I guess this last one is more controversial and is probably not need if we merge #9347 (i.e. people can just click the expand all button).

  5. fregante commented on May 6, 2026

    @fregante
    Member

    Do you think it would make sense to move the generated files at the end of the file list (instead of hiding them, possibly with some visual separation)?

    It's too messy to sort files in the DOM because GitHub will load only files that are visible in the viewport.

    wdyt about just expanding all non-generated content?

    I think GitHub's current logic already makes sense, it hides:

    • files that are generated, as defined by gitattributes + their defaults
    • files that are too big, like package-lock

    Neither one should be auto-expanded, also because it triggers an HTTP request and a delayed scroll, which is already pretty bad natively.

    So the only fix for this issue would be a 1-line CSS rule in refined-github.css as previously described:

    • add some CSS to make the file taller
  6. simonepri commented on May 6, 2026

    @simonepri

    add some CSS to make the file taller

    I'm not sure I understood your idea here, you mean to make the part that says "Load Diff" taller for large, non-generated files?

  7. fregante commented on May 6, 2026

    @fregante
    Member

    Yes, this was described in the initial issue:

    the "Load diff" UI is very nondescript. Scrolling through a large PR it's easy to miss,

    Change the color / formatting of the hidden-diff block to make it stand out more

  8. fregante commented on Jun 2, 2026

    @fregante
    Member
    • Change the color / formatting of the hidden-diff block to make it stand out more

    Done:

    • possibly with a separate "Load all diffs" button alongside (see below)

    We have toggle-everything-with-alt, but most likely it won't work due to deferred loading.

    • Detect when the user attempts to ctrl+f while there are hidden diffs on the page and display a warning
    • Add an indication that there are hidden diffs at the top of the page
    • Change the UI of hidden-diff files in the sidebar

    I think this is covered by the cmd-f warning, which nowadays would be on all the time since GitHub only renders files in/near the viewport. So effectively most files will be "hidden" at any given time.

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

    acceptedenhancementsmall

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions