Skip to content

fix(repo-icon): detect Tauri, WebP, and SVG icons#7942

Open
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/7902-repo-icon-detection
Open

fix(repo-icon): detect Tauri, WebP, and SVG icons#7942
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/7902-repo-icon-detection

Conversation

@bbingz

@bbingz bbingz commented Jul 9, 2026

Copy link
Copy Markdown

Summary

Fixes #7902: repository icon auto-detect was limited to a short list of PNG-only paths aimed at JS web apps. Tauri apps (src-tauri/icons/icon.png), CLI tools (public/icon.webp), and SVG assets were missed and fell back to the GitHub owner avatar.

Changes

  • Expand conventional file stems: Tauri src-tauri/icons/icon, public/icon, app-icon, root icon, etc.
  • For each stem, try .png.webp.svg
  • Detect format via magic / SVG head markers (not extension alone)
  • Allow data:image/png|webp|svg+xml;base64,… in sanitizeRepoIcon (SVG only as <img> data URL, never inline HTML)

Not in this PR

  • README image scraping
  • Deep brand-kit path walks
  • .icns / .ico (need conversion for web display)

Test plan

  • repo-icon-autodetect tests: Tauri path, WebP, SVG
  • sanitizeRepoIcon accepts webp/svg; still rejects gif/javascript
  • persistence / store sanitization tests updated
  • Manual: add a Tauri repo with src-tauri/icons/icon.png → sidebar shows app icon
  • Manual: repo with only public/icon.webp → uses that icon

Fixes #7902

Expand conventional icon path candidates (including src-tauri/icons and
public/icon) and accept PNG, WebP, and SVG by magic/format checks so
auto-detect no longer falls back to the GitHub avatar for common CLI and
Tauri layouts. SVG is only stored as a data URL for <img> rendering.

Fixes stablyai#7902
@coderabbitai

coderabbitai Bot commented Jul 9, 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

Run ID: de0c4663-3b6d-4236-b2db-7a7896c8e573

📥 Commits

Reviewing files that changed from the base of the PR and between 8adfef4 and 66057a8.

📒 Files selected for processing (6)
  • src/main/persistence.test.ts
  • src/main/repo-icon-autodetect.test.ts
  • src/main/repo-icon-autodetect.ts
  • src/renderer/src/store/slices/repos-update-serialization.test.ts
  • src/shared/repo-icon.test.ts
  • src/shared/repo-icon.ts

📝 Walkthrough

Walkthrough

This PR expands repo icon support from PNG-only to PNG, WebP, and SVG formats. The shared isSupportedImageSrc validation regex was widened to accept these three formats for upload/file sources. The main-process icon autodetection module was refactored: candidate filename generation now composes stems with multiple extensions, byte-based format detection was added for WebP and SVG, and PNG-specific readers/detectors were replaced with generalized image-based equivalents. Tests across persistence, serialization, and shared sanitization were updated accordingly, with GIF used as the representative unsupported format, and new autodetection tests cover PNG/WebP/SVG discovery across conventional directories.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has Summary and Test plan, but it omits required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections, including screenshots or 'No visual change', an AI review report, a security audit, and notes.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed It clearly names the repo-icon fix and the added support for Tauri, WebP, and SVG icons.
Linked Issues check ✅ Passed The PR addresses the linked issue by expanding icon candidates and adding PNG, WebP, and SVG detection for Tauri and common project layouts.
Out of Scope Changes check ✅ Passed All code changes stay within repo-icon detection, sanitization, and related tests; nothing unrelated was introduced.

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.

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.

Repo icon auto-detection misses Tauri apps, CLI tools, and non-PNG (svg/webp) icons

2 participants