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
- could add a
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
- for each left and right side:
- for each line selector
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?
- put latest commit hash in local storage key
- 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