Question about displaying diff context #3089
Zak Siddiqui opened 1 day ago

In popular Git pagers such as Git-delta, it is able to display the context of the current lines being displayed, including the name of the function, the name of the class, and so on. However, OneDev does not natively do this. When I'm looking at a git diff, I can't tell which function the individual line changes are in. If there is no way to enable this, can we add this feature so that it's on by default?

Don't assume. Ask high-level clarifying questions if needed.

  • Numbered questions (1, 2, 3, etc)
  • Lettered answer options (A, B, C, etc)
  • Include a markdown table that contains the following for each option:
    • number (with an emoji that represents your recommended option)
    • Option short title
    • Explanation (don't assume my level of knowledge).
    • Pros (with relevant emojis)
    • Cons (with relevant emojis)
  • Service Desk commented 1 day ago
    No comment
  • Service Desk commented 1 day ago

    There is currently no setting to enable this. OneDev's diff viewer shows line numbers and surrounding unchanged lines (which can be expanded), but it does not display the enclosing function/class context as a Git-style hunk header.

    To make sure the proposed feature matches what you expect:

    1. Where should the enclosing code context appear?
    NumberOption short titleExplanationProsCons
    1️⃣A. Per-hunk header (recommended)Show the nearest enclosing function, method, or class in a header for each collapsed group of changes, similar to the text after @@ ... @@ in a Git diff.✅ Familiar Git-style behavior; ✅ compact; ✅ each change group has clear context⚠️ The label may scroll out of view in a long hunk
    2️⃣B. Sticky contextKeep the current function/class visible at the top of the diff while scrolling through its lines.✅ Context remains visible while scrolling; ✅ useful for long changes⚠️ Uses more screen space; ⚠️ more complex behavior when old and new sides are in different symbols
    3️⃣C. BothAdd a label to each hunk and also keep the active label visible while scrolling.✅ Most context in all situations⚠️ More visual and implementation complexity

    Please reply with 1A, 1B, or 1C.

  • Zak Siddiqui commented 1 day ago
    1. c

    I realize that this is a complex change and can result in an issue, especially if all the new sides are in different symbols. Therefore, it may be prudent to consider having the old and new sides' stickiness as separate elements rather than combining them into one sticky element.

    Don't assume. Ask high-level clarifying questions if needed.

    • Numbered questions (1, 2, 3, etc)
    • Lettered answer options (A, B, C, etc)
    • Include a markdown table that contains the following for each option:
      • number (with an emoji that represents your recommended option)
      • Option short title
      • Explanation (don't assume my level of knowledge).
      • Pros (with relevant emojis)
      • Cons (with relevant emojis)
  • Service Desk commented 1 day ago
    No comment
  • Service Desk commented 1 day ago

    That makes sense. For split view, the old and new sides should use independent sticky context elements, so each side can show the symbol that applies to its own revision. The per-hunk headers would likewise identify old and new context separately when they differ.

    1. How should the sticky context behave in unified view, where old and new lines share one column?
    NumberOption short titleExplanationProsCons
    2️⃣A. Separate old/new labels (recommended)Show two compact, clearly labeled sticky elements: one for the old revision and one for the new revision. Each updates independently as its corresponding lines scroll.✅ Preserves both contexts when a change moves between symbols; ✅ consistent with split view⚠️ Uses more vertical space; ⚠️ one label may occasionally have no applicable visible line
    2️⃣B. One active labelShow one sticky element based on the old or new line currently nearest the top of the viewport.✅ Compact; ✅ simpler to scan⚠️ Context can switch while scrolling; ⚠️ may hide that the two revisions are in different symbols
    2️⃣C. Sticky context only in split viewKeep per-hunk context in both layouts, but provide sticky old/new context only in split view.✅ Avoids ambiguity and extra height in unified view⚠️ Unified view loses the always-visible context requested for long hunks

    Please reply with 2A, 2B, or 2C.

  • Zak Siddiqui commented 1 day ago
    1. a

    Don't assume. Ask high-level clarifying questions if needed.

    • Numbered questions (1, 2, 3, etc)
    • Lettered answer options (A, B, C, etc)
    • Include a markdown table that contains the following for each option:
      • number (with an emoji that represents your recommended option)
      • Option short title
      • Explanation (don't assume my level of knowledge).
      • Pros (with relevant emojis)
      • Cons (with relevant emojis)
  • Service Desk commented 1 day ago

    Understood. The requested behavior is now:

    • Show both per-hunk context and sticky context.
    • In split view, keep the old and new revision contexts in independent sticky elements.
    • In unified view, show two compact, clearly labeled old/new sticky elements that update independently.

    There is no existing setting that provides this, so fulfilling the request requires a product and implementation decision. @robin, could you review this feature request?

  • Zak Siddiqui commented 1 day ago

    @servicedesk since the design has been finalized, it would be more prudent to close this issue and create a new one with the new finalized design. It might also be helpful to create ASCII diagrams that show the old UX versus the proposed UX, including the use of pseudocode to demonstrate the value of having the diff context being present. Ensure that the new issue appropriately contains the motivation behind this change.

  • Zak Siddiqui commented 1 day ago

    Assign the new issue to Robin.

  • Service Desk referenced from other issue 1 day ago
  • Service Desk commented 1 day ago

    The configuration question is answered: OneDev does not currently provide enclosing function/class context in its diff viewer. The finalized feature design, motivation, pseudocode example, and old-versus-proposed ASCII diagrams have been moved to issue #3090. It is assigned to @robin, and all three watchers from this issue were carried over.

  • Service Desk changed state to 'Closed' 1 day ago
    Previous Value Current Value
    Open
    Closed
  • Service Desk commented 1 day ago

    @zaakiy, I created new feature issue #3091 with the finalized design, the motivation for the change, old-versus-proposed ASCII UX diagrams, and a pseudocode example demonstrating the value of diff context. I assigned it to @robin and carried over all watchers from this issue. Closing this question as requested.

  • Service Desk commented 1 day ago

    @zaakiy, correction: #3090 is the canonical follow-up issue. A duplicate, #3091, was created concurrently and has been closed. #3090 is assigned to @robin and has all watchers from this issue.

1/1
Type
Question
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (3)
Reference
OD-3089
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover