`keyboard-navigation` - Mark current file as viewed with X by forivall · Pull Request #9087 · refined-github/refined-github · GitHub
Skip to content

keyboard-navigation - Mark current file as viewed with X#9087

Merged
fregante merged 8 commits into
refined-github:mainfrom
forivall:mark-viewed
Apr 4, 2026
Merged

keyboard-navigation - Mark current file as viewed with X#9087
fregante merged 8 commits into
refined-github:mainfrom
forivall:mark-viewed

Conversation

@forivall

@forivall forivall commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #5674

Improves the experience of j/k such that, when navigating through a file that has been collapsed / viewed, it will not expand / uncollapse the file. removed for this pr

Additionally, tracks the clicks and focus events while on a page with comments so that j/k will navigate from the last focused comment, rather than reverting to the first comment. This also affects the x keyboard shortcut, so that a user can click a file then press "x". (This change is separated into a single commit, so we can easily drop it from this PR)

Also added ctrlu/ctrld for faster navigation, which is especially useful once you have many files collapsed, as more files will fit on the screen. removed

Test URLs

#4030 (comment)
https://github.com/refined-github/refined-github/pull/8517/changes

Screenshot

ScreenShot.2026-03-13.at.12.30.10.PM.mp4

@fregante

Copy link
Copy Markdown
Member

@forivall forivall left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fregante Sure. This is ready for review then. The one other change i can make is to clean up the code in the scroll kludge.

Comment thread source/features/keyboard-navigation.tsx Outdated
Comment thread source/features/keyboard-navigation.tsx Outdated
Comment thread source/features/keyboard-navigation.tsx Outdated
@forivall forivall marked this pull request as ready for review March 13, 2026 20:36
@fregante fregante marked this pull request as draft March 14, 2026 00:01

@fregante fregante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm no, it's not ready for review since it contains both bugfixes and enhancements (some of which haven't been discussed yet)

I'd like to see a a PR that restores the feature first, it would likely be small. One thing to note is that this feature also covers comments in the Conversation tab, so we need to verify that any changes to the feature are compatible with it.

The ctrl shortcuts are unlikely to be accepted, especially but not only because those shortcuts are already used by some browsers.

Comment thread source/features/keyboard-navigation.tsx Outdated
@forivall forivall force-pushed the mark-viewed branch 2 times, most recently from eb756f6 to a073eab Compare March 15, 2026 18:28
@forivall

Copy link
Copy Markdown
Contributor Author

Ok, i've stripped out all of the nonessential code for the feature.

@forivall forivall marked this pull request as ready for review March 15, 2026 18:32
@forivall

forivall commented Mar 15, 2026

Copy link
Copy Markdown
Contributor Author

note that i've left in the click/focus tracking. i can remove that as well. edit and i've split that out into a separate commit so it can easily be dropped.

@fregante

fregante commented Mar 31, 2026

Copy link
Copy Markdown
Member

If you want to see #5674, please add support for x exclusively. That part of code is probably 5 lines and does not require behavior changes, which would have to be discussed separately.

It seems that @SunsetTechuila already restored the feature in #9019 so no further changes should be required at this time.

@github-actions

github-actions Bot commented Mar 31, 2026

Copy link
Copy Markdown

Please avoid force-pushing to this PR. It makes it harder for reviewers to track what changed since the last review.

Just push new commits on top of the branch instead — PRs are squashed on merge, so the commit history doesn't need to be clean.

@forivall forivall changed the title Keyboard shortcuts for pr review page: mark viewed, next/previous Keyboard shortcuts for pr review page: mark viewed Mar 31, 2026
@forivall

forivall commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

It's down to 10 lines now, which is close enough to your 5 line target. It took a bit of refactoring to the control flow, even after i pulled out the unnecessary tweaks. The 5 lines target also pushed me to improve the selector for the new PR view, as my original implementation was more complex than necessary (and github may have added some new classes to the checkbox since i originally implmentated it)

Sorry about the force pushes.

Comment thread source/features/keyboard-navigation.tsx Outdated

@fregante fregante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the updates! It already looks reasonable for the feature

Comment thread source/features/keyboard-navigation.tsx Outdated
Comment thread source/features/keyboard-navigation.tsx Outdated
@fregante fregante changed the title Keyboard shortcuts for pr review page: mark viewed keyboard-navigation - Mark current filed as viewed with X Apr 1, 2026
@fregante fregante changed the title keyboard-navigation - Mark current filed as viewed with X keyboard-navigation - Mark current file as viewed with X Apr 1, 2026
}

function init(signal: AbortSignal): void {
document.body.addEventListener('keypress', runShortcuts, {signal});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we use registerHotkey for this?

#5604

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably because it's not worth a refactor

@SunsetTechuila

Copy link
Copy Markdown
Contributor

Hm

image

@SunsetTechuila

Copy link
Copy Markdown
Contributor

None of the selection_* commands are even registered 🤷‍♂️

image

@fregante

fregante commented Apr 3, 2026

Copy link
Copy Markdown
Member

I think that's a user option, shortcuts can be disabled in your GitHub settings

@SunsetTechuila

SunsetTechuila commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

I have this enabled

image

@fregante

fregante commented Apr 3, 2026

Copy link
Copy Markdown
Member

@fregante fregante merged commit 178960e into refined-github:main Apr 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Add a keyboard shortcut to mark current PR file as viewed

3 participants