Repository navigation
Conversation
4bed5ac to
e440c51
Compare
59d5a74 to
c5c5ba8
Compare
e440c51 to
c8b1ba8
Compare
c5c5ba8 to
059672d
Compare
c8b1ba8 to
f1b54cb
Compare
059672d to
796fc9a
Compare
f1b54cb to
6093e0a
Compare
796fc9a to
33aa2d0
Compare
6093e0a to
91448eb
Compare
33aa2d0 to
de95f9d
Compare
91448eb to
61dea6d
Compare
0c09906 to
afce228
Compare
9e5eb2a to
77f45dc
Compare
afce228 to
3157f58
Compare
77f45dc to
8a969d0
Compare
3157f58 to
a64d875
Compare
8a969d0 to
39d5f46
Compare
f1ac3ec to
59c239f
Compare
1597ccb to
68aa255
Compare
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 20 minutes. View limit details
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 |
An icon theme maps the file, folder and folder-open slots plus exact file names and extensions to SVGs. Listing reads only the mapping. A theme's SVGs are read only when it is selected, once per distinct file, under per-icon, per-theme and icon-count caps, and are sent as text with index maps so the renderer sanitizes and registers each icon once. Catalog releases can declare icon-theme, and marketplaces stop hiding icon packs.
Appearance gains an Icon theme row while an enabled plugin offers one. The renderer parses each SVG with the browser's XML parser and keeps only allowlisted SVG elements and un-namespaced attributes; url() may name only a fragment in the same icon, so gradients, clip paths and masks work. Each icon becomes one blob URL and one CSS rule keyed by its index, so rows carry a small attribute instead of the image. Icons drawn only in currentColor render as masks that follow the text color. FileTypeIcon and the explorer's folders fall back to the built-in icons when the plugin is disabled, a path has no mapping, or an SVG is rejected. Uninstalling the plugin clears the setting.
Icon theme file names and extensions such as constructor no longer resolve to inherited Object.prototype members, and registered icon indexes must point at a real SVG.
59c239f to
6bc70e5
Compare
[Medium impact] The PR appears safe to merge, with no outstanding findings. SummaryThe PR adds plugin file and folder icon themes, with bounded loading, SVG sanitizing, and built-in fallbacks.
Reviews (3) · Last reviewed commit: "test(plugins): keep stroke-only icons wi..." · Reviewed by Greptile |
…full color, and drop old icons when a theme fails to load
| for (let node: Element | null = element; node; node = node.parentElement) { | ||
| if (declaredFill(node) !== null) { | ||
| return false | ||
| } | ||
| } | ||
| return true |
There was a problem hiding this comment.
Stroke-only icons lose text colors
hasDefaultFill treats every shape without a declared fill as visibly black. A valid stroke-only icon such as <path d="M2 8h12" stroke="currentColor"/> has no filled area, but now fails the monochrome check. registerIcons draws it as a background instead of a mask, so the stroke becomes black rather than following text and status colors. This can make it hard to see on dark backgrounds.
Exclude shapes that paint no fill from this check and add a stroke-only test.
There was a problem hiding this comment.
Leaving the check: a shape with no declared fill really is painted with SVG's default black fill, even an open path, so it must stay full color. Stroke-only icons declare fill="none" (usually on the root), which the check honors; added a test for that case.
There was a problem hiding this comment.
You’re right that the current check honors an inherited fill="none", and my original example should have accounted for that. One distinction remains: SVG’s default fill is black, and open subpaths are implicitly closed for filling, but the specific path M2 8h12 closes back along the same segment and encloses zero area. With stroke="currentColor" and no fill="none", the stroke is visible while the default fill contributes no pixels; hasDefaultFill still classifies it as full-color, so the stroke can render black instead of following the text color.
So the test confirms the fill="none" convention works, but its assertion that the one-segment path is visibly black-filled is too broad. I’d keep the check for shapes with actual filled area, while treating this degenerate stroke-only case separately (or requiring themes to declare fill="none").
|
Folded into #35470 (Plugin Alpha), which lands the rest of the plugin stack in one PR. |
ELI5
Plugins can now change the icons for files and folders. Pick an icon theme in Appearance; the file explorer and other file lists use it right away. Turn the plugin off and Orca's own icons come back.
What Changed
Before: file and folder icons were always Orca's built-in icons.
After:
FileTypeIcon: explorer, search, source control, quick open, diffs, tab drag preview and chat autocomplete. Folder and open-folder icons in the explorer change too.currentColorfollow the text color, so muted and status colors still apply.How it works:
src/shared/plugins/plugin-content-pack-contributions.ts,plugin-manifest.ts): a newiconThemescontribution family pointing at a mapping file of at most 64 KiB.src/shared/plugins/plugin-icon-theme-artifact.ts):file,folderandfolder-openslots, plus exact file names and extensions, to SVG files.<svgand has no DOCTYPE or entity declarations.src/main/plugins/plugin-icon-theme-registry.ts):src/main/ipc/plugins.ts,src/preload/api/*):plugins:listIconThemesandplugins:loadIconTheme. Results are re-validated in the renderer.src/renderer/src/lib/plugin-icon-svg.ts):<svg>root is rejected.foreignObject,<style>,<use>and anything else are removed with their content.hrefunder any prefix (xlink:,x:, …), event handlers andstyleare removed.url()may only name a fragment in the same icon (url(#grad)).currentColoris its single paint; any other color makes it render as a full-color image.src/renderer/src/store/plugin-icon-themes.ts,FileTypeIcon.tsx,lib/file-type-icons.ts,right-sidebar/FileExplorerRow.tsx):[data-plugin-icon="N"], as a background image or, for monochrome icons, a mask. Rows only carry that small attribute, not the image.FileTypeIconand the newFolderIconuse the icon index, or fall back to built-in icons. Lookup order: exact file name, then extension, then the theme's file icon.src/shared/plugin-theme-settings.ts):pluginIconThemeis checked on write in the main process, and uninstalling the plugin clears it.plugin-catalog-release.ts,plugin-marketplace.ts): catalog releases can declareicon-theme, and marketplaces stop hiding icon packs.Why
x:hrefand had to banurl()outright, which broke the gradients and clip paths real icon packs use. Parsing and allowlisting by namespace keeps those working and makes the rules hold regardless of spelling.FileTypeIconrefactor (refactor(renderer): one FileTypeIcon component for file icons #30695) made this one component change instead of fourteen.Linked Issue
None — this is part of the plugin platform rework (maintainer change).
Visual Proof
Screenshots from a hidden dev window (
ORCA_BACKGROUND_LAUNCH=1, isolated profile, mock keychain), captured over CDP after rebasing onto currentmain. The test theme uses multi-color icons: linear and radial gradients, a clip-path badge, a mask with a gradient set throughstyle, an Inkscape export withxlink:hrefand editor metadata, a single-colorcurrentColoricon, and a hostile SVG (script,onload,foreignObject,<use x:href>to an external URL, externalurl()instyle) that is reduced to its plain rectangle.TSbadge, masked braces, and the single-colornotes.txticon in the theme's text color:Testing
Unit tests:
plugin-icon-theme-artifact.test.ts).plugin-icon-theme-registry.test.ts).foreignObject,<style>,<use>, event handlers,xlink:href/x:hrefand externalurl(); rejection of non-SVG and malformed input (plugin-icon-svg.test.ts).FileTypeIcon.test.tsx).plugin-icon-themes.test.ts).pluginIconThemesanitizing and uninstall cleanup (plugin-theme-settings.test.ts).Local suites: plugin, shared, component, lib, store and app-shell suites pass. Typecheck (
tc:node,tc:web), oxlint,check:code-quality:changedand localization coverage are clean.End-to-end: the plugin e2e specs pass locally, run in the background.
Platforms: macOS locally. This draft skips most CI jobs; Linux and Windows aren't covered yet.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
pluginIconThemeis a new optional setting. Older clients ignore it and keep the built-in icons.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) — targeted suites,tc:node,tc:web, oxlint, the change-quality gate, localization coverage and plugin e2e pass locally; fullpnpm lintnot run