Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7a7b6fb
`dim-viewed-files` - Dim viewed files in the PR file tree
xremix Oct 5, 2026
4dde146
`dim-viewed-files` - Dim folders whose files are all viewed
xremix Oct 5, 2026
b17715a
Attached screenshot
xremix Oct 5, 2026
dc98122
add screenshot to features meta data
xremix Oct 5, 2026
068982a
Apply suggestion from @xremix
xremix Oct 5, 2026
d91a927
undo changes
xremix Oct 5, 2026
4f698ff
Merge branch 'feat/dim-viewed-files' of https://github.com/xremix/ref…
xremix Oct 5, 2026
25fd5a3
fix build
xremix Oct 5, 2026
06684c3
simplify code
xremix Oct 5, 2026
58eb1f2
improve performance
xremix Oct 5, 2026
3604d1b
move folder implementation to an CSS approach
xremix Oct 5, 2026
1b640c6
Update dim-viewed-files.test.ts
xremix Oct 5, 2026
832f431
improve performance of loading viewed files
xremix Oct 6, 2026
5cab09e
fix formatting and linting
xremix Oct 6, 2026
e5fc52e
Discard changes to test/dim-viewed-files.test.ts
fregante Oct 6, 2026
be97e34
Scope viewed file tree selector
xremix Oct 10, 2026
479e5bf
Move feature to bottom of imports
xremix Oct 10, 2026
a3847ba
Remove redundant dimming cleanup
xremix Oct 10, 2026
88d356b
Run tree update through observer
xremix Oct 10, 2026
7139a0a
Reuse debounce-fn for viewed file tree updates
xremix Oct 10, 2026
2997fa3
Drop legacy viewed-file support
xremix Oct 10, 2026
4c38456
Fix folder dimming in the new PR view
xremix Oct 10, 2026
f4cda77
Use CSS nesting for scoped folder selectors
xremix Oct 10, 2026
0327da6
Simplify viewed-file dimming for the new PR view
xremix Oct 10, 2026
787acea
Observe viewed buttons only after their state loads
xremix Oct 10, 2026
6b24211
Check viewed state directly in the tree link loop
xremix Oct 10, 2026
ec0e5a2
Remove redundant viewed-state callback wrapper
xremix Oct 10, 2026
5147ccc
Use an array for new-view observer selectors
xremix Oct 10, 2026
b3ac41d
move feature in readme to bottom
xremix Oct 10, 2026
7ac37a8
Simplify folder selector
xremix Oct 10, 2026
ee2407c
Merge remote-tracking branch 'origin/main' into pr/10172
fregante Oct 15, 2026
b40ea2e
Fix viewed button selector in dim-viewed-files
xremix Oct 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build/__snapshots__/features-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@
"css": true,
"screenshot": "https://user-images.githubusercontent.com/1402241/220607557-f8ea0863-f05b-48c8-a447-1fec42af0afd.gif"
},
{
"id": "dim-viewed-files",
"description": "Dims viewed files and folders containing only viewed files in the PR file tree, keeping unreviewed files easy to find.",
"css": true,
"screenshot": "https://private-user-images.githubusercontent.com/9824294/665923384-1b7a5682-ec3d-4ca4-8608-71ad3b6a2228.png"
},
{
"id": "download-folder-button",
"description": "Adds a button to download entire folders, via https://download-directory.github.io.",
Expand Down
1 change: 1 addition & 0 deletions build/__snapshots__/imported-features.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"default-branch-button",
"delete-branch",
"dim-bots",
"dim-viewed-files",
"download-folder-button",
"easy-toggle-commit-messages",
"easy-toggle-files",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ https://github.com/refined-github/refined-github/wiki/Contributing#metadata-guid
- [](# "clean-checks-list") Prioritizes failing and pending checks in the merge checks list, and untruncates long check names.
- [](# "mobile-tabs-pr") Makes the PR tabs smaller so they fit in the screen without scrolling.
- [](# "linkify-pr-review-state") [Linkifies the PR review state labels ("Draft", "Changes requested", etc) in PR lists to filter by that state.](https://github.com/user-attachments/assets/9c59ba75-d2f2-41d4-a214-24d123f78428)
- [](# "dim-viewed-files") [Dims viewed files and folders containing only viewed files in the PR file tree, keeping unreviewed files easy to find.](https://private-user-images.githubusercontent.com/9824294/665923384-1b7a5682-ec3d-4ca4-8608-71ad3b6a2228.png)

<!--
Refer to style guide in the wiki. Keep this message between sections.
Expand Down
18 changes: 18 additions & 0 deletions source/features/dim-viewed-files.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Files: rows marked as viewed by the JS */
.rgh-dim-viewed-files:not(:hover, :focus-within) {
opacity: 50%;
}

/* Folders: dim only the folder's own row (not its subtree, to avoid compounding opacity) when it contains viewed files and no unviewed ones */
ul[aria-label='File Tree'] {
[role='treeitem'][aria-expanded] {
&:has(.rgh-dim-viewed-files):not(
:has(
Comment thread
fregante marked this conversation as resolved.
[role='treeitem']:not([aria-expanded], .rgh-dim-viewed-files)
)
)
> div:not(:hover, :focus-within) {
opacity: 50%;
}
}
}
51 changes: 51 additions & 0 deletions source/features/dim-viewed-files.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import './dim-viewed-files.css';

import debounce from 'debounce-fn';
import delegate from 'delegate-it';
import * as pageDetect from 'github-url-detection';
import {$$optional, closestElement, elementExists} from 'select-dom';

import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';

const viewedToggleSelector =
':is(button[class*="MarkAsViewedButton"], [class*="diff-file-header"] button[aria-pressed])';
const treeLinkSelector = 'ul[aria-label="File Tree"] a[href*="#"]';
const dimmedClass = 'rgh-dim-viewed-files';

const updateTree = debounce((): void => {
for (const link of $$optional(treeLinkSelector)) {
const row = closestElement('[role="treeitem"]', link);
const viewed = elementExists(
`#${CSS.escape(link.hash.slice(1))} ${viewedToggleSelector}[aria-pressed="true"]`,
);
row.classList.toggle(dimmedClass, viewed);
}
}, {wait: 100});

export function init(signal: AbortSignal): void {
observe(
[
treeLinkSelector,
// The pressed selector also catches viewed state loaded after the button renders.
`${viewedToggleSelector}[aria-pressed="true"]`,
],
updateTree,
{signal},
);
delegate(viewedToggleSelector, 'click', updateTree, {signal});
}

void features.add(import.meta.url, {
include: [pageDetect.isPRFiles],
exclude: [pageDetect.isPRFile404, pageDetect.isPRCommit],
init,
});

/*

Test URLs

https://github.com/refined-github/sandbox/pull/55/files

*/
1 change: 1 addition & 0 deletions source/refined-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,5 @@ import './features/delete-branch.js';
import './features/pr-from-branch.js';
import './features/mark-locked.js';
import './features/subscribe-releases.js';
import './features/dim-viewed-files.js';
import './features/absolute-time.js';
Loading