Repository navigation
fix(repo-icon): fall back to a lucide icon when an image icon fails to load - #12867
Conversation
…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]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/repo/repo-icon.test.tsx (1)
13-25: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert 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. AssertFolderafter the error andDatabasefor 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
📒 Files selected for processing (2)
src/renderer/src/components/repo/repo-icon.test.tsxsrc/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]>
|
Thanks — good catch on the assertions. Fixed in 2a1423c. The fallback and unchanged-icon tests only asserted that an 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 |
Jinwoo-H
left a comment
There was a problem hiding this comment.
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. Revertingrepo-icon.tsxalone 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 lucideFoldersvg 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.
|
thanks for reporting. looking into it |
|
thanks for reporting. looking into it |
…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]>
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
RepoIconGlyphhad noonErrorhandling — 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
Foldericon.The failed
srcis 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):
After — those slots render the same lucide
Foldericon that a repo with norepoIconalready 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
erroron the<img>removes it and renders the lucidesvgin its place. The issue reporter offered to test a patch against their GHE setup, which would confirm it end to end.Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAdded
src/renderer/src/components/repo/repo-icon.test.tsxwith four cases: fallback on load failure, retry when the icon changes to a differentsrc, 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-stagedsteps directly on both files (oxlint,oxlint --config config/oxlint-react-doctor.json,oxfmt --write); all clean, andoxfmtreported 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.shusesdeclare -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
enginesasks for node 24.AI Review Report
Reviewed with Claude Code. Checks and outcomes:
metaKey, keyboard shortcut, shortcut label, file path, or shell behavior is touched, so there is nothing platform-dependent to guard.docs/reference/remote-wire-compatibility.mddoesn't apply. Behavior is identical against local repos, remote servers, and SSH worktrees.repoIconstill falls through toFolder, which is exactly the state a failed image now reaches.RepoIconImageSource(github,favicon,upload,file), not just GHE, and no GitHub-specific branch was added.Folderthat the other branches already fall back to, perdocs/STYLEGUIDE.md. Light/dark mode is unaffected since the fallback inherits the samecolorprop path as the lucide branch.useStateis placed above every conditional return so hook order stays stable across renders.Flagged and accepted as a trade-off: the failed-
srcstate 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
srcstays on the fallback. The comment was corrected to match.Security Audit
repoIcon.srcis already validated bysanitizeRepoIconinsrc/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.onErrorrecords the URL in local component state only. Nothing is logged, transmitted, or persisted, so an internal GHES hostname does not leave the renderer.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 testcan't pass on macOS with the system bash, because.github/scripts/check-root-directory-entries.shrelies ondeclare -A(bash 4+) and macOS ships bash 3.2. Since CONTRIBUTING asks contributors to runpnpm testbefore 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.