Repository navigation
Fix stale GitHub repo avatars after owner changes - #6507
Conversation
📝 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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/renderer/src/components/settings/repository-icon-github.ts (1)
104-109: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd the
clearMissingIconrationale inline.This guard carries the PR’s “passive refresh must not clear an existing GitHub avatar” rule, but that policy is only implicit here. A short
Why:comment would make the opt-in clear behavior much easier to preserve.As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Suggested comment
if ( + // Why: passive refresh preserves the current GitHub avatar when live + // identity cannot be resolved; explicit reset opts into clearing it. (resolution.repoIcon || options.clearMissingIcon) && !sameRepoIcon(repo.repoIcon, resolution.repoIcon) ) {Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6db9e2ea-a0ac-4b8d-b47b-92103bcc409f
📒 Files selected for processing (4)
src/renderer/src/components/settings/RepositoryIconPicker.github-avatar-refresh.test.tsxsrc/renderer/src/components/settings/RepositoryIconPicker.tsxsrc/renderer/src/components/settings/repository-icon-github.test.tssrc/renderer/src/components/settings/repository-icon-github.ts
| const upstream = | ||
| repo.upstream !== undefined | ||
| !options.forceLive && repo.upstream !== undefined | ||
| ? repo.upstream | ||
| : await resolveRepositoryUpstreamLive(runtimeTarget, repo).catch(() => null) | ||
| if (upstream) { | ||
| return githubAvatarIcon(upstream) | ||
| } | ||
| const slug = | ||
| runtimeTarget.kind === 'environment' | ||
| ? await callRuntimeRpc<{ owner: string; repo: string } | null>( | ||
| runtimeTarget, | ||
| 'github.repoSlug', | ||
| { repo: repo.id }, | ||
| { timeoutMs: 30_000 } | ||
| ) | ||
| : await window.api.gh.repoSlug({ repoPath: repo.path, repoId: repo.id }) | ||
| return slug ? githubAvatarIcon(slug) : null | ||
| return { repoIcon: githubAvatarIcon(upstream), upstream } | ||
| } | ||
| const slug = await resolveRepositorySlugLive(runtimeTarget, repo) | ||
| return { repoIcon: slug ? githubAvatarIcon(slug) : null, upstream: null } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Don't collapse upstream lookup errors into null.
Line 51 swallows every resolveRepositoryUpstreamLive() failure and then Lines 55-56 fall back to repoSlug. If repoSlug succeeds, buildRepositoryGitHubAvatarUpdate() can persist upstream: null, which rewrites a still-forked repo as “not a fork” after a transient RPC/IPC failure. Let the error abort the refresh (or preserve the existing upstream) and only slug-fallback on an actual null upstream result.
Proposed fix
export async function resolveRepositoryGitHubAvatar(
runtimeTarget: RuntimeTarget,
repo: Repo,
options: ResolveRepositoryGitHubAvatarOptions = {}
): Promise<RepositoryGitHubAvatarResolution> {
const upstream =
!options.forceLive && repo.upstream !== undefined
? repo.upstream
- : await resolveRepositoryUpstreamLive(runtimeTarget, repo).catch(() => null)
+ : await resolveRepositoryUpstreamLive(runtimeTarget, repo)
if (upstream) {
return { repoIcon: githubAvatarIcon(upstream), upstream }
}
const slug = await resolveRepositorySlugLive(runtimeTarget, repo)
return { repoIcon: slug ? githubAvatarIcon(slug) : null, upstream: null }
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const upstream = | |
| repo.upstream !== undefined | |
| !options.forceLive && repo.upstream !== undefined | |
| ? repo.upstream | |
| : await resolveRepositoryUpstreamLive(runtimeTarget, repo).catch(() => null) | |
| if (upstream) { | |
| return githubAvatarIcon(upstream) | |
| } | |
| const slug = | |
| runtimeTarget.kind === 'environment' | |
| ? await callRuntimeRpc<{ owner: string; repo: string } | null>( | |
| runtimeTarget, | |
| 'github.repoSlug', | |
| { repo: repo.id }, | |
| { timeoutMs: 30_000 } | |
| ) | |
| : await window.api.gh.repoSlug({ repoPath: repo.path, repoId: repo.id }) | |
| return slug ? githubAvatarIcon(slug) : null | |
| return { repoIcon: githubAvatarIcon(upstream), upstream } | |
| } | |
| const slug = await resolveRepositorySlugLive(runtimeTarget, repo) | |
| return { repoIcon: slug ? githubAvatarIcon(slug) : null, upstream: null } | |
| export async function resolveRepositoryGitHubAvatar( | |
| runtimeTarget: RuntimeTarget, | |
| repo: Repo, | |
| options: ResolveRepositoryGitHubAvatarOptions = {} | |
| ): Promise<RepositoryGitHubAvatarResolution> { | |
| const upstream = | |
| !options.forceLive && repo.upstream !== undefined | |
| ? repo.upstream | |
| : await resolveRepositoryUpstreamLive(runtimeTarget, repo) | |
| if (upstream) { | |
| return { repoIcon: githubAvatarIcon(upstream), upstream } | |
| } | |
| const slug = await resolveRepositorySlugLive(runtimeTarget, repo) | |
| return { repoIcon: slug ? githubAvatarIcon(slug) : null, upstream: null } | |
| } |
| // @ts-expect-error test window mock | ||
| globalThis.window = { api: { gh: apiMocks } } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Preserve happy-dom’s real window object.
Lines 30-31 replace globalThis.window with a plain object, which strips the real happy-dom window of document, timers, constructors, and other DOM state. That makes this test run against a broken browser global and can hide future regressions. Patch window.api instead of replacing window.
Proposed fix
-// `@ts-expect-error` test window mock
-globalThis.window = { api: { gh: apiMocks } }
+Object.defineProperty(window, 'api', {
+ value: { gh: apiMocks },
+ configurable: true
+})📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // @ts-expect-error test window mock | |
| globalThis.window = { api: { gh: apiMocks } } | |
| Object.defineProperty(window, 'api', { | |
| value: { gh: apiMocks }, | |
| configurable: true | |
| }) |
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
|
Maintainer takeover — validated, extended, and verified this PR end-to-end. Security screen: clean. No new IPC/deps/postinstall/network hosts. Avatar URLs are host-pinned ( Reproduced first on One real regression found and fixed before merge: the original forced-live path could clobber a fork's parent identity with the fork's own origin owner when the live upstream lookup returned Verification: Thanks @ParkerRex — the lazy-refresh design and the explicit cost/benefit write-up were exactly right; that made the takeover fast. |
|
Merged (squash) — this passed the full quality bar. Thanks again @ParkerRex: your lazy-refresh design and the explicit cost/benefit reasoning were spot on, and the only thing needed on top was hardening the fork-identity path against transient offline lookups (plus tests for it). Appreciate the clean, well-scoped contribution. |
|
Thank you, @ParkerRex. Avatars getting stuck on the previous owner after a repo transfer is a subtle one to notice, and the lazy self-heal on settings-open is a nice cost/benefit call rather than sweeping on every launch. Thanks for the thoughtful fix — merged! |
|
Thanks Parker! 🙏 Stale avatars after a repo transfer is a small thing that just looks wrong every time you glance at the sidebar. Nice pragmatic lazy-refresh call. Appreciate you polishing the rough edge. 🐋 |
…fix garbled comments (#7322) Quality pass on renderer/shared PRs merged 2026-07-03: - WorktreeTitleInlineRename: skip the truncation measure + ResizeObserver in `wrapTitle` mode, where wrapped titles never truncate — it could only churn unused state (#7307). - editor slice: reuse the `removeEditorStateForReplacedPreview` helper this PR added instead of a hand-rolled copy of the same six-field eviction (drops ~50 lines) (#6476). - useFileExplorerTree: extract `readWorktreeDirectory` so the connectionId/settings assembly for `readRuntimeDirectory` lives in one place, not three (#6321). - comment-markdown-github-attachment-media: extract a shared `AttachmentFallbackLink` for the image/video error-fallback link (#6759). - repository-icon-github: fold the two near-identical live resolvers into one parameterized `resolveRepositoryIdentityLive`; trim a 3-line comment to 2 (#6507). - resource-usage-open-slices: delete the `shouldReadPopoverSlices` identity wrapper and inline `open` at the four call sites (#7275). - BrowserPane: drop the pointerEvents assignment already applied inside `ensureBrowserPageWebview` for the reused-webview path (#6958). - github slice: fix two garbled "…a commit main confirmed…" comments (#7277). - runtime-file-client: trim the binary-file fallback comment to its whys (#6606). - composer-branch-selection: drop the inline comment that restated the JSDoc (#6748). - TabBarQuickCommandsButton: correct the stale "+ Command" comment (button shows no +). No behavior change (the editor-helper reuse is behavior-equivalent, only more conservative on an edge case); typecheck, oxlint, react-doctor, oxfmt, and touched unit suites all pass.
* Fix stale GitHub repo avatars after owner changes * Simplify avatar-refresh effect deps (repo covers its fields) Co-authored-by: Orca <[email protected]> * Preserve known fork identity when live upstream lookup is inconclusive Co-authored-by: Orca <[email protected]> * Remove dead avatar-icon wrapper; drop no-op update fallbacks Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Neil <[email protected]> Co-authored-by: Orca <[email protected]>
…fix garbled comments (stablyai#7322) Quality pass on renderer/shared PRs merged 2026-07-03: - WorktreeTitleInlineRename: skip the truncation measure + ResizeObserver in `wrapTitle` mode, where wrapped titles never truncate — it could only churn unused state (stablyai#7307). - editor slice: reuse the `removeEditorStateForReplacedPreview` helper this PR added instead of a hand-rolled copy of the same six-field eviction (drops ~50 lines) (stablyai#6476). - useFileExplorerTree: extract `readWorktreeDirectory` so the connectionId/settings assembly for `readRuntimeDirectory` lives in one place, not three (stablyai#6321). - comment-markdown-github-attachment-media: extract a shared `AttachmentFallbackLink` for the image/video error-fallback link (stablyai#6759). - repository-icon-github: fold the two near-identical live resolvers into one parameterized `resolveRepositoryIdentityLive`; trim a 3-line comment to 2 (stablyai#6507). - resource-usage-open-slices: delete the `shouldReadPopoverSlices` identity wrapper and inline `open` at the four call sites (stablyai#7275). - BrowserPane: drop the pointerEvents assignment already applied inside `ensureBrowserPageWebview` for the reused-webview path (stablyai#6958). - github slice: fix two garbled "…a commit main confirmed…" comments (stablyai#7277). - runtime-file-client: trim the binary-file fallback comment to its whys (stablyai#6606). - composer-branch-selection: drop the inline comment that restated the JSDoc (stablyai#6748). - TabBarQuickCommandsButton: correct the stale "+ Command" comment (button shows no +). No behavior change (the editor-helper reuse is behavior-equivalent, only more conservative on an edge case); typecheck, oxlint, react-doctor, oxfmt, and touched unit suites all pass.
Description
When a GitHub repo's owner changes (org → personal or vice-versa, i.e. a transfer), the stored repo avatar went stale forever. Once
repo.upstreamwas backfilled, the settings backfill effect returned early on every subsequent open, and even the manual "Use GitHub avatar" button preferred the cachedupstream— so nothing ever re-resolved the live owner.This change refreshes GitHub-avatar identity lazily when a repo's icon settings open (and on explicit Reset / Use-GitHub-Avatar), by forcing a live resolve that ignores the stale persisted metadata.
buildRepositoryGitHubAvatarUpdatecomputes a minimal diff so nothing is written when the identity is unchanged.Maintainer changes on top of the original PR:
Repo.upstreamis tri-state:undefined= fork status unprobed,null= confirmed not-a-fork,{owner,repo}= fork parent. The original forced-live path, when the live upstream lookup returnednull, fell through to the origin slug. For a fork opened while offline/unauthed (where resolving the parent needs a networkgh repo view), thatnullis ambiguous and would clobber the stored fork parent with the fork's own origin owner — flipping the avatar and, worse, writing a stickynullthat permanently disables fork default-branch auto-sync (the backfill retry gate skips anything not=== undefined). Fixed at the resolution layer: a known fork identity is preserved when the live upstream lookup is inconclusive; the origin-slug refresh only applies to non-fork repos (which always storenull). Locked with unit + component regression tests.resolveRepositoryGitHubAvatarIcon) and two no-op?? {...}update fallbacks; simplified the effect dependency array.Evidence
mainfirst: a unit test against the pre-fix resolver shows the cachedupstreamreturns the stale owner's avatar and never consults the live origin (repoSlug/repoUpstreamnot called).pnpm vitest run(repo config) — 6/6 pass acrossrepository-icon-github.test.tsandRepositoryIconPicker.github-avatar-refresh.test.tsx(non-fork transfer refresh, fork-preservation, passive no-clobber, default-usage).oxlint(+ react-doctor) clean on all four touched files.pnpm run typecheck— exit 0.ELI5
Your project's little picture comes from whoever owns the repo on GitHub. If the repo moves to a new owner, the picture used to get stuck on the old owner forever. Now, when you open that project's icon settings, Orca quietly asks GitHub who owns it today and updates the picture. And if your project is a fork, we're careful: if GitHub can't be reached at that moment, we keep the parent's picture instead of guessing wrong and breaking fork syncing.
Trade-offs
.git/configchanges behind Orca's back. Deliberate — a startup/background sweep would pay network/ghcost on every launch for every repo to fix a rare transfer.ghconcurrency limiter — no polling, no per-render churn.Original author notes (@ParkerRex)
Hey it's Parker - super random edge case I ran into. If you change repo location from Org -> Personal or vice-versa, the image goes stale.
This keeps the fix lazy instead of checking every repo on startup. Orca only refreshes the GitHub avatar identity when the repo icon settings are opened for a repo already using the GitHub avatar, or when the user explicitly hits Reset / GitHub Avatar.
Decision/tradeoff: rejected a startup-wide refresh (every launch would inspect repo remotes; remote/SSH repos add network round trips; forks spend gh/API budget) and a background sweep (touches unrelated repos, adds scheduling/cache-invalidation complexity) in favor of the lazy settings refresh (zero repo-list/startup cost, only runs for repos already using a GitHub avatar, reuses existing
gh.repoUpstream/gh.repoSlugcalls).