Skip to content

feat(history): show author avatar in commit list#1339

Merged
arnestrickmann merged 1 commit intomainfrom
emdash/history-pr-9rb
Mar 6, 2026
Merged

feat(history): show author avatar in commit list#1339
arnestrickmann merged 1 commit intomainfrom
emdash/history-pr-9rb

Conversation

@arnestrickmann
Copy link
Contributor

Summary

  • Add GitHub avatar thumbnails next to commit author names in the commit history list
  • Extract authorEmail from git log output (%ae format) and pass it through the IPC layer
  • Resolve GitHub usernames from noreply email addresses to load correct avatars
  • Gracefully hide the avatar if the image fails to load

Changes

  • GitService.ts: Add authorEmail field to getLog() return type and include %ae in the git log format string
  • CommitList.tsx: Add AuthorAvatar component that loads GitHub profile images, with githubLoginFromEmail() helper to extract usernames from GitHub noreply addresses
  • electron-api.d.ts: Add authorEmail to the gitGetLog response type

@vercel
Copy link

vercel bot commented Mar 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Mar 6, 2026 9:20pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR adds GitHub avatar thumbnails to the commit history list by extracting authorEmail from git log output (%ae) and threading it through the IPC layer to the renderer, where a new AuthorAvatar component loads profile images from GitHub. The backend changes in GitService.ts and the type declaration update in electron-api.d.ts are clean and correct.

Key issue:

  • The getAvatarUrl function falls back to using the git author display name (e.g., "Jane Smith") as a GitHub username when the email is not a noreply address. This creates invalid URLs like https://github.com/Jane%20Smith.png?size=40 that always return 404, firing one spurious HTTP request per non-GitHub-authored commit every render. The fallback should return null to omit the avatar gracefully instead.

Confidence Score: 3/5

  • The fallback generates wasted HTTP requests for non-GitHub-authored commits, but application functionality is not compromised.
  • The spurious HTTP fallback is a real performance issue that should be fixed before shipping to avoid noisy network traffic, but it's not critical. Backend changes are clean and low-risk. The frontend issue is straightforward to fix with the suggested change.
  • src/renderer/components/diff-viewer/CommitList.tsx — specifically the getAvatarUrl fallback logic

Sequence Diagram

sequenceDiagram
    participant R as CommitList (Renderer)
    participant IPC as Electron IPC
    participant G as GitService (Main)
    participant GH as github.com

    R->>IPC: gitGetLog({ taskPath, maxCount })
    IPC->>G: getLog(taskPath, maxCount)
    G->>G: git log --pretty=format:%H%s%an%aI%D%ae%b
    G-->>IPC: { commits: [{ hash, author, authorEmail, ... }] }
    IPC-->>R: { success, commits, aheadCount }

    loop For each commit in list
        R->>R: githubLoginFromEmail(authorEmail)
        alt noreply email → login extracted
            R->>GH: GET /login.png?size=40
            GH-->>R: 200 avatar image
        else regular email → falls back to author name
            R->>GH: GET /DisplayName.png?size=40
            GH-->>R: 404 (always fails)
            R->>R: onError → setFailed(true) → hide avatar
        end
    end
Loading

Last reviewed commit: f86fedb

Comment on lines +62 to +67
function getAvatarUrl(author: string, authorEmail: string): string {
const login = githubLoginFromEmail(authorEmail);
if (login) return `https://github.com/${login}.png?size=40`;
// Fall back to trying the author name as a GitHub username
return `https://github.com/${author}.png?size=40`;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fallback constructs URLs from author display names, causing spurious HTTP 404 requests

When githubLoginFromEmail() returns null (the common case for non-GitHub email addresses), this function falls back to using the git author display name (e.g., "Jane Smith") as a GitHub username. This creates URLs like https://github.com/Jane%20Smith.png?size=40, which GitHub will always reject with a 404 response.

The result is one wasted HTTP request per non-noreply commit, every time the list renders. The fallback should return null to signal "no avatar available" instead of blindly constructing a URL:

Suggested change
function getAvatarUrl(author: string, authorEmail: string): string {
const login = githubLoginFromEmail(authorEmail);
if (login) return `https://github.com/${login}.png?size=40`;
// Fall back to trying the author name as a GitHub username
return `https://github.com/${author}.png?size=40`;
}
function getAvatarUrl(author: string, authorEmail: string): string | null {
const login = githubLoginFromEmail(authorEmail);
if (login) return `https://github.com/${login}.png?size=40`;
return null;
}
function AuthorAvatar({ author, authorEmail }: { author: string; authorEmail: string }) {
const [failed, setFailed] = useState(false);
const url = getAvatarUrl(author, authorEmail);
if (!url || failed) return null;
return (
<img
src={url}
alt=""
className="h-4 w-4 shrink-0 rounded-sm"
onError={(e: SyntheticEvent<HTMLImageElement>) => {
e.currentTarget.style.display = 'none';
setFailed(true);
}}
/>
);
}

@arnestrickmann arnestrickmann merged commit e643a2d into main Mar 6, 2026
5 checks passed
@arnestrickmann arnestrickmann deleted the emdash/history-pr-9rb branch March 10, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant