sindresorhus/refined-github

Support ability to mark lines as viewed #4636

evansjohnson posted onGitHub

Description

Request

I'm looking for a Github plugin that gives me the ability to mark lines of code as viewed in addition to files. When looking at a file with many LOC changed I'd like to reduce the clutter as I go instead of needing to grok a whole file before marking it viewed. Yes this may be indicative of a bigger root problem but it's not always reasonable to leave a "break this file up" comment

Does this belong in Refined Github

I read through the rules and believe it may be appropriate, though I could see this opening up to too many options to support how everyone would want it to work, and potentially have an expensive UI and heavy reliance on github selectors to maintain.

Proposed implementation/notes

To mark lines as viewed

  • listen to history changes and rely on github adding a suffix like L6-L28 to detect selection/avoid reimplementing a selection identifier.
    • Relying on github's use of L and R means this would support marking lines as viewed in a flexible way, either on a side of the diff or across both sides of the diff.
  • if lines are selected, add icon button next to "Switch to the split diff view" and "Show whitespace changes"
    • I'm thinking an eye with "Mark selected lines as viewed" in the hover text
    • also add hotkey, would need to check what's available
  • use local storage to store viewed status so that no 3rd party server is involved:
    • set to clear after 1 month to avoid bloat
    • at each file hash per pull request, store object with line identifiers as keys and empty objects as values
      • could add a isViewed: true key if empty object seems weird but could rely on existence of object
      • object gives ability to add behavior per code block in the future

UI for viewed lines

  • on pull request page check local storage to see if there is anything stored for the given pull request
  • for each file with viewed lines
    • for each line selector
      • for each left and right side:
        • only show first line with some indication it has been marked as viewed
        • buttons that appear on hover or focus to
          • Unmark block as viewed
          • Edit description of block which will show instead of the first line if a description exists
            • reason: I'd like to be able to summarize what's happening, first line may not always be appropriate for that
            • description would be stored in the line identifier object

From a look around the element tree on github it seems like it should be possible to target files and lines but would appreciate a flag if there's any part of this where you think I may run into issues.

Questions

  • How to unapply lines viewed when new commits are pushed?
    • put latest commit hash in local storage key
      • this would clear viewed lines even if they don't change with the addition of a new commit
    • any other suggestions?
  • Does Github Refined already have concepts for "line identifiers" and "code blocks" I should be aware of?

Thank you :)

If this sounds reasonable I'd like to take a crack at contributing this feature! I could put more effort into visual mocks for feedback if this generally gets some interest in moving forward.

I hadn't looked into Github productivity plugins before this but am happy I found this plugin - thanks for building it and making it open source!

Screenshot

No response

Example URL

https://github.com/sindresorhus/refined-github/pull/4635/files


Hi Even, thanks for the detailed request. As the length of this post suggests, this feature can't be part of Refined GitHub, as we favor small improvements over large and complex ones.

To address this feature specifically, the behavior you're describing appears to be relatively easily implementable (e.g. select the lines as if you were to review them, then click a button in the form that appears + just store the line numbers) but as you mentioned line numbers are only useful until a new commit comes in.

For that reason this feature would probably need to parse the actual diff — that's too complex for Refined GitHub.

posted by fregante over 3 years ago

Hey @fregante, thanks for the feedback - I totally agree with what you're saying.

If I could ask one quick question to leverage your experience with this project - do you have any recommendations on how to parse the diff/the best libraries available to use? If it's not relatively easy to implement I'll consider doing the per commit approach since really the goal would be to mark the file as viewed.

posted by evansjohnson over 3 years ago

I haven't looked at the diff libraries available, I think those exist and they're not the main difficulty, which for me would be:

  • finding out whether the viewed lines have moved
  • finding out whether the viewed lines have changed

But I think that's something a little math and a loop can solve. In practice you'll have to apply the patch to the viewed lines you have.

posted by fregante over 3 years ago

Fund this Issue

$0.00
Funded

Pull requests