Skip to content

feat: Add avatar stacks#37594

Open
bircni wants to merge 27 commits into
go-gitea:mainfrom
bircni:feature/display-co-author
Open

feat: Add avatar stacks#37594
bircni wants to merge 27 commits into
go-gitea:mainfrom
bircni:feature/display-co-author

Conversation

@bircni
Copy link
Copy Markdown
Member

@bircni bircni commented May 7, 2026

Parse Co-authored-by: trailers from commit messages and surface contributors as an avatar stack across the commit page, commits list, PR commits tab, latest-commit row, blame, graph, and dashboard feed.

  • Up to 10 visible 20px avatars, GitHub-style overlap (6px first stride, 4px between subsequent), +N chip for the rest.
  • Label: 1 → name; 2 → <a> and <b>; 3+ → <N> people opens a Tippy popup with all participants.
  • Names and avatars link to the repo's commits-by-author search; fall back to profile or mailto:.
  • Trailer parsing uses net/mail.ParseAddress, scans only the trailing paragraph, filters out the commit's own author/committer.
  • Drops the non-standard Co-committed-by: emission on squash merge and web edits.

Devtest: /devtest/coauthor-avatars.

Fixes #25521


@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 7, 2026
Comment thread models/user/user.go Outdated
@silverwind
Copy link
Copy Markdown
Member

silverwind commented May 7, 2026

  1. Would call it "Avatar Stack", it's a generic concept
  2. Should also do that for commit lists and PR timeline
  3. This is Add avatar stack for commit like github #25521

@bircni
Copy link
Copy Markdown
Member Author

bircni commented May 7, 2026

for commit list it is done see screenshot

@bircni bircni changed the title feat(repo): display co-authors on commit pages feat(repo): Add Avatar Stack to Commits May 7, 2026
@silverwind
Copy link
Copy Markdown
Member

Ok, ensure it also works on:

  • PR commit tab
  • frontpage feed commits
  • blame
  • any other place I may have forgotten

@silverwind
Copy link
Copy Markdown
Member

Basically any place that renders avatar + sha. Some places render 16px avatars, unify all to 20px

@bircni
Copy link
Copy Markdown
Member Author

bircni commented May 7, 2026

Basically any place that renders avatar + sha. Some places render 16px avatars, unify all to 20px

yes just saw It - kinda interesting how it is different on many places

@silverwind
Copy link
Copy Markdown
Member

Could probably extract a shared template for avatar+sha but doesn't have to be in this PR. Templates have a ton of duplication that should be reduced.

@bircni bircni marked this pull request as draft May 7, 2026 19:25
@bircni
Copy link
Copy Markdown
Member Author

bircni commented May 7, 2026

Could probably extract a shared template for avatar+sha but doesn't have to be in this PR. Templates have a ton of duplication that should be reduced.

maybe at the end if all fits we could decide if we do it here or somewhere else

@silverwind
Copy link
Copy Markdown
Member

silverwind commented May 7, 2026

Regarding naming, this how Github does it, would suggest to align:

2 users = <user> and <user> (already correct)
3+ users = <n> people

@bircni
Copy link
Copy Markdown
Member Author

bircni commented May 7, 2026

will continue tomorrow - too late for today
@silverwind if you want to have a look feel free to do so
Opus was happy in the last check

@silverwind
Copy link
Copy Markdown
Member

Yes I will test this later. I was already planning to implement this but you were faster 😆.

@bircni
Copy link
Copy Markdown
Member Author

bircni commented May 7, 2026

cleaning up a bit

bircni and others added 2 commits May 7, 2026 21:54
Extract and harden co-author trailer parsing, add reusable co-author avatar templates, and wire commit/repo views to render co-author metadata.
Show co-author avatar stacks on commit SHA surfaces including commits list rows, graph, blame, and dashboard feeds, with repository-level data propagation and tests.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@bircni bircni force-pushed the feature/display-co-author branch from 37438a1 to 10461b2 Compare May 7, 2026 19:54
@silverwind silverwind added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label May 7, 2026
Comment thread templates/repo/commit_coauthor_avatars.tmpl Outdated
Comment thread templates/repo/commit_coauthor_avatars.tmpl Outdated
Comment thread web_src/css/repo.css Outdated
Comment thread web_src/css/repo.css Outdated
Comment thread web_src/css/repo.css Outdated
Comment thread web_src/css/repo.css Outdated
bircni and others added 2 commits May 11, 2026 09:01
…d functions

Addresses review feedback: wxiaoguang requested a backend render function
(like RenderLabels) instead of templates; silverwind requested template
consolidation. Moving logic to Go satisfies both — two templates are deleted
and replaced by RenderUtils.CoAuthorAvatarStack / CoAuthorAvatars. Also
removes vertical-align (no-op in flexbox), redundant z-index:0, and
hardcoded font-size:10px from co-author CSS rules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bircni bircni requested a review from silverwind May 11, 2026 07:06
@bircni
Copy link
Copy Markdown
Member Author

bircni commented May 12, 2026

@silverwind can you have a look?

Comment thread modules/templates/util_render.go
Comment thread modules/templates/util_render.go Outdated
@wxiaoguang wxiaoguang marked this pull request as draft May 13, 2026 09:14
silverwind and others added 4 commits May 14, 2026 05:01
…thor

* origin/main:
  [skip ci] Updated translations via Crowdin
  fix: snap build (main branch) (go-gitea#37685)
  chore: introduce HTMLBuilder (go-gitea#37688)
  chore: clean up "contrib" dir (go-gitea#37690)
  feat(api): add sort and order query parameters to job list endpoints (go-gitea#37672)
  fix: Sort action run jobs by JobID and Name with matrix examples (go-gitea#37046)
  fix: catch and fix more lint problems (go-gitea#37674)
  docs(agents): update AGENTS.md (go-gitea#37684)
  fix(actions): run `TransferLogs` on `UpdateLog{Rows:[], NoMore:true}` (go-gitea#37631)
Address review on 977f311 and clean up several leftover rough edges:

- Use util.NormalizeStringEOL and container.Set in the trailer parser
- Switch util_render to htmlutil.HTMLBuilder
- Move avatar/avatar-stack CSS to its own avatar.css
- Drop the inline `--n` CSS-var trick and the 11 explicit z-index rules:
  emit children reversed and use flex-direction: row-reverse so the author
  lands leftmost AND last-painted (on top)
- Drop dead additionalClasses param from AvatarStack; let .author-wrapper
  gap carry inter-item spacing
- Collapse coAuthorsParsed+coAuthors cache pair into *[]*Signature
- Extract git.CoAuthoredByTrailer, reuse in merge_squash, pull, temp_repo
- Cache RepoLink/RefTypeNameSubURL on RenderUtils once instead of reading
  ctx.Data per call
- Restore matched-user avatars on dashboard feed via PushCommit.AuthorUser
  (was a regression of the original AvatarStack switch)
- Guard empty-href case in participantRowHTML; align authorNameLinkHTML
  email precedence with authorHref

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
…feature/display-co-author

* bircni/feature/display-co-author:
@silverwind
Copy link
Copy Markdown
Member

all addressed in d6c2e4e.

@silverwind silverwind marked this pull request as ready for review May 14, 2026 03:45
GetWithContextCache only stores on success, so unmatched author emails
re-queried the DB on every PushCommit render across a feed. Drop the
helper and use the ephemeral cache directly so the nil result is cached
for the rest of the request.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.

Comment thread modules/templates/util_render.go
Comment thread modules/templates/util_render.go Outdated
- RenderUtils is constructed before the repo middleware runs, so caching
  RepoLink/RefTypeNameSubURL in the constructor snapshotted empty values
  and commitAuthorSearchURL never produced a search link on repo pages.
  Read them lazily from ctx.Data inside the helper.
- AvatarStack short-circuited the single-author case to a bare <img>,
  regressing click-through on call sites that use it directly
  (commits_list_small, blame, dashboard feeds). Drop the short-circuit
  so the avatar is always wrapped via appendAvatarStackChild.
- Narrow integration selector to a.muted now that .author-wrapper holds
  both the avatar link and the name link.
- Drop a redundant u = nil reset in PushCommit.AuthorUser: GetUserByEmail
  already returns (nil, err) on every error path.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@lunny
Copy link
Copy Markdown
Member

lunny commented May 15, 2026

Looks not good in dark mode
image

@wxiaoguang

This comment was marked as resolved.

@silverwind
Copy link
Copy Markdown
Member

silverwind commented May 15, 2026

Looks not good in dark mode image

The only enhancement that I see is to make background transparent. Will check later.

Oh and there's also something that could be seen as bug: With 10+ authors, the expension hover effect clips off the avatars. Visible in devtest.

@bircni
Copy link
Copy Markdown
Member Author

bircni commented May 16, 2026

thanks for the help @silverwind lgtm!

silverwind and others added 2 commits May 17, 2026 07:49
- 1px masking border (was 2px); drop forced circular `border-radius: 50%`
  so avatars keep their natural shape
- on hover, transition border-color and background-color of `.avatar`
  to transparent since stacked avatars no longer overlap when spread
- chip uses `var(--border-radius)`, hidden idle via `opacity: 0`,
  fades in on `.avatar-stack:hover`
- move overflow/ellipsis from `.author-wrapper` onto its name children
  so the hover-spread is no longer clipped with 10+ authors
- vary devtest scenarios so the author avatar isn't always u0/first

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
`Co-authored-by: <jane@example.com>` is a valid trailer that
`mail.ParseAddress` accepts with `Name == ""`, which downstream renders
an empty `<a class="muted" href="mailto:...">` with no visible text.
Use the address as the display name when no name is given.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member

silverwind commented May 17, 2026

All addressed, border is now 1px. Non-hovered avatars have border+bg to make them distinguishable.

image

`opacity: 0` left the chip's 20px flex slot in the layout, widening
the collapsed stack by ~4px. Collapse width, margin and border in the
unhovered state and transition them alongside opacity so the chip
materializes on hover without affecting baseline layout.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
Comment thread services/repository/gitgraph/graph_models.go Outdated
Comment thread modules/templates/util_render.go Outdated
}

// CoAuthorAvatars renders the avatar stack plus a label: `name` / `a and b` / `N people` (opens popup).
func (ut *RenderUtils) CoAuthorAvatars(authorUser *user_model.User, authorSig *git.Signature, coAuthors []*user_model.CoAuthorUser) template.HTML {
Copy link
Copy Markdown
Contributor

@wxiaoguang wxiaoguang May 19, 2026

Choose a reason for hiding this comment

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

After reading the related code, I think the CoAuthorAvatars func should accept a single "PushCommit" argument (let the caller backend code prepare the struct), but not receiving the dynamic variables from template.

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.

fixed

Comment thread modules/repository/commits.go Outdated
AuthorName string
CommitterEmail string
CommitterName string
CoAuthors []*git.Signature `json:",omitempty"`
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.

Where is the PushCommit marshalled as JSON?

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.

fixed

bircni and others added 2 commits May 20, 2026 18:56
Introduces user_model.CoAuthorAvatarData and helper methods on
UserCommit and gitgraph.Commit so templates pass a single
backend-prepared value instead of three loose fields. Also drops
the unused json tag from PushCommit.CoAuthors.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 1 This PR needs approval from one additional maintainer to be merged. type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add avatar stack for commit like github

6 participants