Skip to content

small-user-avatars improvements - #10085

Merged
fregante merged 11 commits into
mainfrom
meh
Oct 20, 2026
Merged

fregante merged 11 commits into
mainfrom
meh

Conversation

@fregante

@fregante fregante commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Comment thread source/manifest.json Outdated
"homepage_url": "https://github.com/refined-github/refined-github",
"manifest_version": 3,
"minimum_chrome_version": "123",
"minimum_chrome_version": "125",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Due to repeated regex group names


export default function getUserAvatar(username: string, size: number): string | void {
const cleanName = username.replace('[bot]', '');
const cleanName = username.replace('[bot]', '').replace('app/', '');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

// Prefer reading username from URL if present.
// - [data-hovercard-url]: everywhere but the React PR lists (global and repo)
// - [aria-label="Filter by author github-user-here"]: in React PR lists (global and repo)
const attribute = element.getAttribute('data-hovercard-url') ?? element.getAttribute('aria-label');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd rather read the value from attributes because they're generally parseable with fewer surprises.

One exception here is the issue list https://github.com/eslint/eslint/issues?q=author%3Aapp%2Fdependabot, which doesn't include any attributes except href. So maybe I should parse author:app/dependabot from there

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

On more scenario that this might be fixing is where GitHub has started showing full names in the links, like on eslint's repo. I might just want to extract the username from textContent since that might have fewer variations and since it always exists.

// GitHub appends `[bot]` to bots in PR lists.
assertUsername(username?.replace(/\[bot\]$/, ''));

return username;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Perhaps this should standardize one of app/ vs [bot]

Comment thread source/features/small-user-avatars.tsx Outdated
import regexJoin from 'regex-join';

import features from '../feature-manager.js';
import getUserAvatarURL from '../github-helpers/get-user-avatar.js';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

getUserAvatarURL should probably be modified to return | undefined for unknown bots. It seems that it fails otherwise.

This comment was marked as resolved.

@fregante

Copy link
Copy Markdown
Member Author

Claude

This PR follows #10080, which restored small avatars on the new React PR lists. It makes small-user-avatars cope with GitHub's inconsistent bot names and stops it from breaking when no avatar can be found. The PR body gave no reason, so the following is inferred from the code and its comments.

Why: GitHub names bots two ways on different pages, app/dependabot and dependabot[bot]. Some lists only give a ?q=author:app/dependabot link, and Copilot has its own hovercard format. The old code assumed a plain user hovercard. For anything else it either threw or built an avatar URL that doesn't exist.

What it does:

  1. Username extraction is rewritten in small-user-avatars.tsx.
    • It matches three known attribute formats with regex-join: /users/x/hovercard, /copilot/hovercard?bot=x, and Filter by author x.
    • If none match, it falls back to the author: value in the link's ?q= href, then to the last child's text.
    • Each format has a test URL in a comment.
  2. stripBotMarkers() is a new helper in get-user-avatar.ts. It removes both the app/ prefix and the [bot] suffix, and replaces the old [bot]-only replace.
  3. Unknown bots get no avatar in getUserAvatar, which now returns undefined.
    • Before, it guessed an avatars.githubusercontent.com/<name> URL for them, which doesn't exist.
    • Bots found on the page or in the known-app list are unchanged.
    • Enterprise still uses /<name>.png.
  4. No avatar means skip. createAvatar and the repo, issue-row and mention paths now bail out quietly instead of using ! assertions, so there are no broken images or thrown errors.
  5. assertUsername now rejects empty or undefined names and narrows the type, so callers need no casts.
  6. Selectors are tightened. The author-filter selectors now require a or button, and the is(...) combinator is split into two plain selectors. The legacy .js-issue-row selector got a "drop in February 2027" TODO.

@fregante fregante added the bug label Oct 19, 2026
@fregante

Copy link
Copy Markdown
Member Author

Claude

Manual checks (logged in):

@fregante
fregante marked this pull request as ready for review October 20, 2026 10:07
@fregante

Copy link
Copy Markdown
Member Author

Yolo. All test URLs work and have no (related) console errors 🙏

@fregante
fregante enabled auto-merge (squash) October 20, 2026 10:07
@fregante
fregante merged commit 071370e into main Oct 20, 2026
13 checks passed
@fregante
fregante deleted the meh branch October 20, 2026 10:38
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.

2 participants