Skip to content

fix(repo-icon): fall back to a lucide icon when an image icon fails to load - #12867

Merged
Jinwoo-H merged 2 commits into
stablyai:mainfrom
erishforG:fix/repo-icon-image-load-fallback
Aug 6, 2026
Merged

Jinwoo-H merged 2 commits into
stablyai:mainfrom
erishforG:fix/repo-icon-image-load-fallback

Conversation

@erishforG

Copy link
Copy Markdown
Contributor

Summary

On a self-hosted GitHub Enterprise instance in private mode, every repo in the sidebar renders an empty icon slot. Orca stores the GHE org avatar URL as the repo icon, that URL requires a logged-in web session, and the image branch of RepoIconGlyph had no onError handling — so a failed load rendered as blank space.

This makes the image branch fall back the same way the other branches already do: on load failure it falls through to the lucide Folder icon.

The failed src is tracked in state, so switching a repo to a different icon still renders that new icon instead of staying on the fallback.

Fixes #11211

Screenshots

No new UI was added — the change only makes an already-defined fallback reachable.

Before — every sidebar project shows an empty icon slot on private-mode GHE (screenshot from #11211):

Repo icons render blank on private-mode GitHub Enterprise

After — those slots render the same lucide Folder icon that a repo with no repoIcon already gets.

I don't have a private-mode GHES instance set up for a clean "after" capture, so the behavior is covered by unit tests instead: firing error on the <img> removes it and renders the lucide svg in its place. The issue reporter offered to test a patch against their GHE setup, which would confirm it end to end.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions

Added src/renderer/src/components/repo/repo-icon.test.tsx with four cases: fallback on load failure, retry when the icon changes to a different src, loadable images still render, and the emoji/lucide branches unchanged.

Verified the tests actually catch the regression — with the component change reverted, 2 of the 4 fail; with it, all 4 pass.

Also ran the lint-staged steps directly on both files (oxlint, oxlint --config config/oxlint-react-doctor.json, oxfmt --write); all clean, and oxfmt reported no changes.

Pre-existing failures in the full suite, unrelated to this change — reproduced on a clean checkout with this change stashed:

  • config/scripts/check-root-directory-entries.test.mjs (3 tests) — .github/scripts/check-root-directory-entries.sh uses declare -A, which macOS's default bash 3.2 doesn't support, so it exits 2 locally. Fine on CI's bash 5.x. See Notes.
  • src/relay/agent-exec-handler.test.ts (2 tests) — spawn env/arg expectations. Also flaky: 6 failures on one run, 5 on the next.

Environment note: local runs used node 26.3.0 while engines asks for node 24.

AI Review Report

Reviewed with Claude Code. Checks and outcomes:

  • Cross-platform (macOS/Linux/Windows) — pure React state. No metaKey, keyboard shortcut, shortcut label, file path, or shell behavior is touched, so there is nothing platform-dependent to guard.
  • SSH/remote/local — renderer-local rendering only. No RPC params, stream frames, or host-published content change, so docs/reference/remote-wire-compatibility.md doesn't apply. Behavior is identical against local repos, remote servers, and SSH worktrees.
  • Folder workspaces — unchanged. A workspace with no repoIcon still falls through to Folder, which is exactly the state a failed image now reaches.
  • Agents / integrations / git providers — provider-neutral. The fallback applies to every RepoIconImageSource (github, favicon, upload, file), not just GHE, and no GitHub-specific branch was added.
  • Performance — one string held in state and a single re-render on failure. Not in a hot path, no new network or filesystem work, no resource to clean up.
  • UI quality — no new color values, font sizes, or shadow tiers; reuses the existing lucide Folder that the other branches already fall back to, per docs/STYLEGUIDE.md. Light/dark mode is unaffected since the fallback inherits the same color prop path as the lucide branch.
  • Hooks correctness — useState is placed above every conditional return so hook order stays stable across renders.

Flagged and accepted as a trade-off: the failed-src state is per component instance rather than a shared cache, so an unreachable avatar is requested once per mounted instance. A global opt-out and skipping unloadable avatars at import time (suggestions 2 and 3 in #11211) would address that; both are left out to keep this PR to a single topic.

Also flagged during review: an earlier draft of the code comment implied that any icon change retries. It doesn't — returning to a previously failed src stays on the fallback. The comment was corrected to match.

Security Audit

  • Input handling — repoIcon.src is already validated by sanitizeRepoIcon in src/shared/repo-icon.ts (https-only, owner-avatar path pattern, no credentials, length caps). This change adds no new input path and no new parsing.
  • Data exposure — onError records the URL in local component state only. Nothing is logged, transmitted, or persisted, so an internal GHES hostname does not leave the renderer.
  • Command execution / path handling / auth / secrets / IPC — none touched.
  • Dependencies — no additions or version changes.

No follow-up needed.

Notes

Reported and root-caused by @daemin-hwang in #11211; this implements suggestion 1 from that issue.

Separate follow-up worth flagging: pnpm test can't pass on macOS with the system bash, because .github/scripts/check-root-directory-entries.sh relies on declare -A (bash 4+) and macOS ships bash 3.2. Since CONTRIBUTING asks contributors to run pnpm test before opening a PR and macOS is a supported platform, that script looks worth fixing on its own — happy to send a follow-up PR if you'd like.

…o load

Private-mode GitHub Enterprise avatars need a logged-in web session, so the
stored avatar URL fails to load and the image branch rendered blank space.
The lucide and missing-icon paths already fall back to Folder; the image
branch had no equivalent.

Track the failed src in state so a repo switched to a different icon still
renders that icon instead of staying on the fallback.

Fixes stablyai#11211

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b7a43b56-9633-48d2-a2d5-5039edf438aa

📥 Commits

Reviewing files that changed from the base of the PR and between 6b8c76e and 2a1423c.

📒 Files selected for processing (1)
  • src/renderer/src/components/repo/repo-icon.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/repo/repo-icon.test.tsx

📝 Walkthrough

Walkthrough

RepoIconGlyph now tracks failed image sources and renders the existing fallback icon after an image load error. A new image source allows the image to render again. Tests cover image fallback, source-change retry, successful image rendering, and emoji and lucide icon rendering.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: falling back to a lucide icon when a repository image fails to load.
Description check ✅ Passed The description covers the required sections, testing, AI review, security audit, platform considerations, and follow-up notes.
Linked Issues check ✅ Passed The PR implements the directly linked issue's primary objective by adding an image-load fallback to the existing Folder icon.
Out of Scope Changes check ✅ Passed The component change and regression tests are limited to repository icon fallback behavior described in the linked issue.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
src/renderer/src/components/repo/repo-icon.test.tsx (1)

13-25: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the specific icon outputs.

The fallback test only checks that an <svg> exists after the image error. The unchanged-icon test has the same gap. Both tests pass if the component returns the wrong icon. Assert Folder after the error and Database for the lucide input.

Also applies to: 54-62


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 363c1b76-d73d-4560-b7ff-e7eb608fde3d

📥 Commits

Reviewing files that changed from the base of the PR and between 790ade5 and 6b8c76e.

📒 Files selected for processing (2)
  • src/renderer/src/components/repo/repo-icon.test.tsx
  • src/renderer/src/components/repo/repo-icon.tsx

The fallback and unchanged-icon tests only checked that an svg rendered, so
they passed even if the wrong icon came back. Assert the lucide class name,
and cover an unknown lucide name falling back to Folder.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@erishforG

Copy link
Copy Markdown
Contributor Author

Thanks — good catch on the assertions. Fixed in 2a1423c.

The fallback and unchanged-icon tests only asserted that an <svg> rendered, so they would have passed with the wrong icon. They now assert the lucide class name (lucide-folder after a load error, lucide-database for the lucide input), and I added a case for an unknown lucide name falling back to Folder, since getRepoLucideIcon has a ?? Folder path that wasn't covered.

Verified the suite still catches the regression it's meant to: with the component change reverted, 2 of the 5 tests fail; with it, all 5 pass.

On the Docstring Coverage warning — I've left that as is. This repo's AGENTS.md asks for concise, non-obvious comments only ("BE CONCISE. 1 LINE if possible", "explain the obvious" listed under DO NOT), and neither the component nor the test file has exported functions that would carry a docstring under that style. Adding them to reach 80% would work against the documented convention, so I don't think it applies here. Happy to revisit if a maintainer prefers otherwise.

@Jinwoo-H Jinwoo-H left a comment

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.

Thanks for the thorough writeup — the root cause and the reproduction were both spot on.

Reviewed and validated locally:

  • Rebased onto current main (the branch was 2 commits behind); clean, no conflicts.
  • pnpm typecheck, oxlint, and the react-doctor config are all clean. 18 tests pass across the repo-icon files. Reverting repo-icon.tsx alone makes 2 of the new tests fail, so they do bite.
  • Verified in a dev build: pointed the loaded avatars at an unreachable host and confirmed all four <img> elements are replaced by the lucide Folder svg at identical 14×14 geometry, so the fallback doesn't shift sidebar layout. Restoring the real URLs brings the avatars back.

On direction — the fallback is the correct fix at this layer regardless of anything else. A renderer <img> runs in the default Electron session and can't carry a PAT or a GHE session cookie, so an unloadable image has nowhere else to go. It also isn't GHE-specific: the same blank slot hits source: 'favicon' icons (they point at www.google.com/s2/favicons, which is blocked on plenty of enterprise networks), any avatar while offline, and renamed or deleted orgs.

Agreed on keeping suggestions 2 and 3 out of this PR. Suggestion 3 in particular is worth doing separately — fetching the avatar once in the main process and inlining it as a data: URI would make icons work offline and stop the failing URL being re-requested on every mount, and on a private-mode instance it would simply store no icon instead of a broken one. That's a main-process change plus a migration for already-stored URLs, so it belongs on its own.

Keeping the per-instance failed-src state as you wrote it: a shared cache would cut requests but would also stop a transient failure (VPN not up at launch) from self-healing on the next mount. The trade you picked is the right one.

Re the declare -A / bash 3.2 issue in check-root-directory-entries.sh — yes please, a follow-up PR for that would be welcome.

@Jinwoo-H
Jinwoo-H merged commit ac961d6 into stablyai:main Aug 6, 2026
43 checks passed
@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…o load (stablyai#12867)

* fix(repo-icon): fall back to a lucide icon when an image icon fails to load

Private-mode GitHub Enterprise avatars need a logged-in web session, so the
stored avatar URL fails to load and the image branch rendered blank space.
The lucide and missing-icon paths already fall back to Folder; the image
branch had no equivalent.

Track the failed src in state so a repo switched to a different icon still
renders that icon instead of staying on the fallback.

Fixes stablyai#11211

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(repo-icon): assert the specific fallback icon instead of any svg

The fallback and unchanged-icon tests only checked that an svg rendered, so
they passed even if the wrong icon came back. Assert the lucide class name,
and cover an unknown lucide name falling back to Folder.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

[Bug]: Repo icons render blank on GitHub Enterprise — image icons have no onError fallback and no global opt-out

3 participants