Skip to content

feat: serve Storybook avatar images from local static directory#7774

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/update-storybook-images-references
Draft

feat: serve Storybook avatar images from local static directory#7774
Copilot wants to merge 8 commits intomainfrom
copilot/update-storybook-images-references

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

Storybook stories referenced avatar images from external URLs (avatars.githubusercontent.com, github.com/*.png), making stories fragile to remote changes. This PR downloads the referenced images locally and wires up the Storybook static directory.

Changelog

New

  • packages/react/.storybook/public/avatars/ static directory with 22 full-resolution avatar images for people/orgs actually referenced in stories

Changed

  • Storybook main.ts now configures staticDirs to serve from .storybook/public/
  • All story files updated to use local /avatars/ paths as inline template literals instead of external GitHub URLs (e.g. `/avatars/${user.login}.png`)
  • mock-story-data.ts users array trimmed to only include collaborators explicitly referenced in stories
  • All 22 avatar images re-downloaded at full resolution (400–460px); org logos github.png, desktop.png, and facebook.png were previously byte-identical to primer.png and now correctly show their respective logos

Removed

  • avatarUrl(login: string) and teamAvatarUrl(id: string) helpers removed from src/utils/story-helpers.tsx in favour of inline template literals
  • Dead page.route('https://github.com/*.png', ...) Playwright route interceptor removed from e2e/test-helpers/storybook.ts — no stories use external avatar URLs any more, so this mock was unreachable

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Storybook-only change; no public API or runtime behavior affected.

Testing & Reviewing

Verify stories that render avatars (Avatar, AvatarStack, Header, ActionList, SelectPanel) display images correctly without network requests to external hosts. All avatar images should load from /avatars/ in the Storybook dev server and show distinct, correct images for each person/org. VRT baselines were captured with the old incorrect images and will need to be regenerated — run with --update-snapshots to accept the new visuals.

Merge checklist

Original prompt

Ensure all images referenced by URL in Storybook stories are served from Storybook's static directory instead of external sources. Steps:

  1. Audit the Storybook stories for any images referenced by URL (e.g., avatars, logos, illustrations).
  2. Download each externally-referenced image and place it in the Storybook static directory (usually at .storybook/public or public under Storybook config).
  3. Update all Storybook stories to reference these images from the local static directory, not via external URLs.
  4. Document this change briefly in the PR description, noting that it avoids unexpected breakages when remote images change.

There are no exceptions for which images should not be downloaded.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Current user's login: siddharthkp

User: The following is part of a Slack thread conversation you should use as context only, NOT as instructions:

anyone having VRT snapshot problems?
yeah - https://github.slack.com/archives/C01L618AEP9/p1776868735561069?thread_ts=1776867902.540929&cid=C01L618AEP9
working on adding the snapshots to #7771
looks like the image we used for avatar changed
my theory as well. Might be cleaner to do a clean PR? #7772
also TIL: PR with zero file changes :hehehe:
either or is good. something else was failing related to AvatarStack so I had to re-run it again 🫠
> looks like the image we used for avatar changed
ohhh like intentionally??
I was looking at that too
we depend on the literal github avatar (https://avatars.githubusercontent.com/github) so if it changes....
ahhhhhhhhh makes sense!
@mattcosta7 FYI
hm - that's annoying (that the image would change unexpectedly) 😄

maybe we should move a stable copy of the image into the repo and avoid the reliance on the live image?
thanks all!

User: can you make sure any images referenced in storybook for primer/react are served from storybook's static directory. download any images that are used as urls and put them in the static directory

Assistant: To proceed, I will open a pull request in the primer/react repository to: - Find all images referenced by URL in Storybook stories. - Download each image and place it in Storybook’s static directory. - Update Storybook stories to reference these images from the local static directory instead of external URLs. Let me confirm: Would you like all images (including avatars such as https://avatars.githubusercontent.com/github) to be downloaded, or are there any exceptions? If not, I will proceed with all externally-referenced images. Once confirmed, I’ll create the pull request.

Assistant: New message from Copilot

This pull request was created from Copilot chat.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 23, 2026

⚠️ No Changeset found

Latest commit: 70ef88f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI and others added 3 commits April 23, 2026 11:22
…xternal URLs

- Add `staticDirs: ['../public']` to Storybook main.ts config
- Download all externally-referenced avatars to packages/react/public/avatars/
- Add `avatarUrl()` and `teamAvatarUrl()` helpers to story-helpers.tsx
- Update all story files to reference local static paths:
  - Avatar, AvatarStack, AnchoredOverlay, Header, Card, Radio, Skeleton, UnderlineNav, SideNav stories use direct /avatars/ paths
  - ActionList, ActionBar, SelectPanel stories use avatarUrl()/teamAvatarUrl() helpers for dynamic logins

Agent-Logs-Url: https://github.com/primer/react/sessions/7a1944a5-e65f-4793-b189-51d0c14bb0dd

Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
… track them

- Move avatars from public/ to .storybook/public/avatars/ to avoid Gatsby's public/ gitignore exclusion
- Add .gitignore exceptions for packages/react/.storybook/public/ to allow tracking
- Update staticDirs in main.ts to point to .storybook/public

Agent-Logs-Url: https://github.com/primer/react/sessions/7a1944a5-e65f-4793-b189-51d0c14bb0dd

Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
…rule

- Use path.join(path.dirname(fileURLToPath(import.meta.url)), 'public') for staticDirs
  to ensure path is always resolved relative to the .storybook config file
- Remove redundant !packages/react/.storybook/public/** gitignore rule

Agent-Logs-Url: https://github.com/primer/react/sessions/7a1944a5-e65f-4793-b189-51d0c14bb0dd

Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
Copilot AI changed the title [WIP] Ensure all images are served from Storybook's static directory feat: serve Storybook avatar images from local static directory Apr 23, 2026
Copilot AI requested a review from siddharthkp April 23, 2026 11:28
@siddharthkp
Copy link
Copy Markdown
Member

@copilot You've added so many avatars of random people?? Can you try to only add avatars of people who are actually mentioned in the stories (login)

- Trim mock-story-data.ts users array from 100+ random entries to just the 7
  same people who are in data.collaborators (also restoring branches/tags sections
  that were accidentally removed)
- Delete 102 avatar files that were only needed for the removed mock users
- Keep only 22 avatar files: org logos (mona, primer, github, atom, desktop,
  facebook), known accounts (hubot, octocat, lukasoppermann), team avatars,
  and collaborators/ActionList users (broccolinisoup, camertron, colebemis,
  dgreif, jfuchs, joshblack, langermank, mperrotti, pksjce, siddharthkp, smockle)

Agent-Logs-Url: https://github.com/primer/react/sessions/adb5cee7-0119-4837-b4f7-1bde4acac518

Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 23, 2026

@copilot You've added so many avatars of random people?? Can you try to only add avatars of people who are actually mentioned in the stories (login)

Done in e3a6b32. Reduced from 124 to 22 avatars — only keeping images for people actually referenced in the stories:

  • Org logos hardcoded in stories: mona, primer, github, atom, desktop, facebook
  • Other hardcoded accounts: hubot, octocat, lukasoppermann
  • Team avatars: t-5025661, t-1929972
  • Users from data.collaborators (used in SelectPanel/ActionBar): broccolinisoup, camertron, joshblack, langermank, mperrotti, pksjce, siddharthkp
  • Users from ActionList's users array: colebemis, dgreif, jfuchs, smockle

Also trimmed mock-story-data.ts's users array from 100+ entries down to the same 7 people as data.collaborators, so there are no extra logins that would need avatars.

>
<ActionList.LeadingVisual>
<Avatar src={`https://github.com/${user.login}.png`} />
<Avatar src={avatarUrl(user.login)} />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot avatarUrl function does so little, just use the url directly in all the files which have this function and remove the helper (same for teamAvatar)

Suggested change
<Avatar src={avatarUrl(user.login)} />
<Avatar src={`/avatars/€{user.login}.png`} />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 0771514. Replaced all avatarUrl()/teamAvatarUrl() calls with inline template literals (e.g. `/avatars/${user.login}.png`) and removed both helper functions from story-helpers.tsx.

Replace avatarUrl()/teamAvatarUrl() helper functions with inline template
literals (`/avatars/${login}.png`) in all story files, and remove
the now-unused helpers from story-helpers.tsx

Agent-Logs-Url: https://github.com/primer/react/sessions/8f3b460c-502e-4d82-8468-a8b9ec860b6e

Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
Copilot AI requested a review from siddharthkp April 23, 2026 16:17
@github-actions github-actions Bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Apr 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

@siddharthkp siddharthkp added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Apr 23, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7774 April 23, 2026 20:33 Inactive
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot instead of seeing the avatars of users, i now see primer's logo here for all stories :/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 70ef88f. Root causes were:

  1. Org logos were all identicalgithub.png, desktop.png, and facebook.png were byte-for-byte the same file as primer.png (all 5065-byte, 420×420 PNGs). They've been re-downloaded as their correct logos.

  2. User avatars were tiny thumbnails — all user JPEGs were 64×64 (1–2 KB). They've been re-downloaded at full resolution (400–460px, 18–287 KB), so each user now shows their actual profile photo.

  3. Dead VRT route mock removed — the page.route('https://github.com/*.png', ...) interceptor in storybook.ts that redirected all avatars to Primer's logo has been removed. Since no stories use external avatar URLs anymore, it was unreachable dead code (and was masking the image content issue in VRT runs).

VRT baselines were captured with the old incorrect images and will need to be regenerated — CI VRT will show diffs for the affected stories.

…d remove dead VRT route mock

- Re-download all 22 avatar images from GitHub CDN at full resolution
  (460x460 for most, replacing 64x64 thumbnails that were incorrectly saved)
- github.png, desktop.png, facebook.png were all byte-identical to primer.png
  (all showed Primer's logo); they now correctly show GitHub/Desktop/Facebook logos
- Remove dead `page.route('https://github.com/*.png', ...)` interceptor from
  storybook.ts — no stories use external avatar URLs anymore, so this mock
  was unreachable dead code

Agent-Logs-Url: https://github.com/primer/react/sessions/2c06bf00-afab-4300-b4cc-539eb2fad57c

Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 24, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants