10BC0 `comments-time-machine-links` - Restore feature on issues by SunsetTechuila · Pull Request #8712 · refined-github/refined-github · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@SunsetTechuila
Copy link
Member
@SunsetTechuila SunsetTechuila commented Oct 19, 2025

fixes #8698

Test URLs

#8698

Screenshot

image

@SunsetTechuila SunsetTechuila marked this pull request as draft October 19, 2025 14:21
@fregante fregante added the bug label Nov 1, 2025
@SunsetTechuila SunsetTechuila marked this pull request as ready for review November 2, 2025 13:01
@SunsetTechuila
Copy link
Member Author
SunsetTechuila commented Nov 2, 2025

partially _fixes #8698

should I open a separate PR that adapts the feature for the react dropdowns?

@fregante
Copy link
Member
fregante commented Nov 2, 2025

Why is it a partial fix? What does it take to fix it? It would be great to just fix it in a single PR if possible

@SunsetTechuila
Copy link
Member Author
SunsetTechuila commented Nov 3, 2025

Why is it a partial fix?

This fixes a bug where the rgh-link-date parameter wasn't appended to links from the issue body. However, it doesn't fix the absence of the "View repo at this time" menu item in react context menus

It would be great to just fix it in a single PR if possible

Ok

@SunsetTechuila
Copy link
Member Author

let me know if you have any ideas for how I can integrate my code into the existing one

@SunsetTechuila SunsetTechuila changed the title comments-time-machine-links: Fix on partially prerendered pages comments-time-machine-links: Fix on new issue pages Nov 3, 2025
@fregante fregante changed the title comments-time-machine-links: Fix on new issue pages comments-time-machine-links - Restore feature on issues Nov 4, 2025
Copy link
Member
@fregante fregante left a comment

Choose a reason for hiding this comment

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

Looks good. Any improvements can be a followup PR. I'll release a new RGH version today. There's one small issue that I'm looking into

@fregante fregante merged commit abe9c2e into refined-github:main Nov 4, 2025
29 checks passed
@fregante
Copy link
Member
fregante commented Nov 4, 2025

There's one small issue that I'm looking into

When I hovered over it, this link did not have the URL parameter, then I refreshed the page and it appeared. My guess is that GitHub updated the contents of the comment but did not remove our "rgh-seen" class. You can confirm this by opening #8698 and waiting a few minutes.

Screenshot 5

This is basically the risk we run into when we observe the wrong element. The observer can track seen elements and re-run when they're regenerated, but if we're looking at the wrong element then we can't see what changed elsewhere.

This just explains the theory, in practice sometimes we have no choice and/or React still updates the contents/textnodes without removing our rgh-seen class.

@SunsetTechuila
Copy link
Member Author
SunsetTechuila commented Nov 9, 2025

My guess is that GitHub updated the contents of the comment but did not remove our "rgh-seen" class.

No, it's just that .markdown-body has been re-rendered

@fregante
Copy link
Member
fregante commented Nov 9, 2025

updated the contents of the comment but did not remove our "rgh-seen" class.

No, it's just that .markdown-body has been re-rendered

It's the same thing. "re-rendering markdown-body` is the same as "update the (DOM) contents of the comment"

@SunsetTechuila
Copy link
Member Author
SunsetTechuila commented Nov 9, 2025

React still updates the contents/textnodes without removing our rgh-seen class.

This doesn't happen. New elements are created, and observers work as expected. You can check and see that the caller id changes when the comment body re-renders

@fregante
Copy link
Member

the caller id changes

Caller IDs don't change, they're static across browser reloads and are connected to a specific observe call. If it "changes", then it's because a different selector matched it, completely different observe call or different feature.

This doesn't happen

I've been working on Refined GitHub for 8 years and I wrote the observer, I know what's happening.

observe(
`:is(${commentSelector}) relative-time[datetime]`
, relativeTime => {
const comment = relativeTime.closest(`:is(${commentSelector})`)!;
addInlineLinks(comment, relativeTime.attributes.datetime.value);
},
{signal},
);

This observer tracks the relative-time element and then traverses the DOM until it finds the links. If relative-time remains unchanged but the contents change, no rgh-link-date parameter is added; Refined GitHub cannot see the changes of elements that are not being observed.

The rgh-seen class you see on each link is not added by comments-time-machine-links. The links are observed by other features.

Verifying this is pretty simple:

  1. disable all features (there's a toggle)
  2. enable only comments-time-machine-links
  3. look at this inline line: https://github.com/refined-github/refined-github/blob/main/source/features/comments-time-machine-links.tsx

You will see the rgh-seen class on relative-time but not on the link.

So, again:

GitHub updated the contents of the comment but did not remove our "rgh-seen" class

but if we're looking at the wrong element then we can't see what changed elsewhere

The fix is to change that observer to select the individual links in the comments rather than the relative-time element that sits outside the updatable area.

@SunsetTechuila
Copy link
Member Author

Alright, thank you for the detailed explanation

const timestamp = $('relative-time', comment).attributes.datetime.value;
addInlineLinks(comment, timestamp);
}, {signal});
delegate(`:is(${commentSelector}) button[data-component="IconButton"]:has(> .octicon-kebab-horizontal)`, 'click', addDropdownLinkReact, {signal});
Copy link
Member Author

Choose a reason for hiding this comment

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

they added test id comment-header-hamburger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

comments-time-machine-links: Cannot read properties of undefined (reading 'value')

2 participants

0