Skip to content

feat(plugins): file and folder icon themes - #30720

Closed
nwparker wants to merge 6 commits into
mainfrom
nwparker/plugins-v2-5-icon-themes
Closed

nwparker wants to merge 6 commits into
mainfrom
nwparker/plugins-v2-5-icon-themes

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​519 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​507
Prod 28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​773 $\color{#cf222e}{\Huge{\mathbf{−}}}$​34 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​739

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:

  • Appearance gains an Icon theme row while an enabled plugin offers one.
  • Choosing a theme changes file icons in every list that uses FileTypeIcon: explorer, search, source control, quick open, diffs, tab drag preview and chat autocomplete. Folder and open-folder icons in the explorer change too.
  • Icons can use gradients, clip paths and masks. Icons drawn only in currentColor follow the text color, so muted and status colors still apply.
  • Paths the theme doesn't map, icons that fail sanitizing, and the whole UI once the plugin is disabled, fall back to built-in icons.

How it works:

  • Manifest (src/shared/plugins/plugin-content-pack-contributions.ts, plugin-manifest.ts): a new iconThemes contribution family pointing at a mapping file of at most 64 KiB.
  • Icon theme files (src/shared/plugins/plugin-icon-theme-artifact.ts):
    • A file maps the file, folder and folder-open slots, plus exact file names and extensions, to SVG files.
    • Names and extensions are matched case-insensitively. A theme can have at most 512 mappings and 512 distinct SVG files.
    • The main process only checks that each file plausibly starts with <svg and has no DOCTYPE or entity declarations.
  • Loading (src/main/plugins/plugin-icon-theme-registry.ts):
    • Listing themes reads only their mapping files.
    • A theme's SVGs are read only when it is selected, once per distinct file, capped at 64 KiB per icon and 4 MB per theme.
    • They are sent as a list of SVG texts plus name/extension/slot → index maps, so a file used by many mappings crosses IPC once.
  • IPC (src/main/ipc/plugins.ts, src/preload/api/*): plugins:listIconThemes and plugins:loadIconTheme. Results are re-validated in the renderer.
  • Sanitizing (src/renderer/src/lib/plugin-icon-svg.ts):
    • Each SVG is parsed with the browser's XML parser; anything that isn't a well-formed document with an SVG-namespace <svg> root is rejected.
    • Only allowlisted SVG elements (shapes, groups, gradients, clip paths, masks) are kept, checked by namespace; scripts, foreignObject, <style>, <use> and anything else are removed with their content.
    • Only allowlisted attributes without a namespace are kept, so href under any prefix (xlink:, x:, …), event handlers and style are removed. url() may only name a fragment in the same icon (url(#grad)).
    • An icon is monochrome only if currentColor is its single paint; any other color makes it render as a full-color image.
  • Renderer (src/renderer/src/store/plugin-icon-themes.ts, FileTypeIcon.tsx, lib/file-type-icons.ts, right-sidebar/FileExplorerRow.tsx):
    • Each sanitized icon is registered once: one blob URL and one CSS rule keyed by [data-plugin-icon="N"], as a background image or, for monochrome icons, a mask. Rows only carry that small attribute, not the image.
    • Switching or turning off the theme removes the stylesheet and revokes the URLs.
    • FileTypeIcon and the new FolderIcon use the icon index, or fall back to built-in icons. Lookup order: exact file name, then extension, then the theme's file icon.
  • Settings (src/shared/plugin-theme-settings.ts): pluginIconTheme is checked on write in the main process, and uninstalling the plugin clears it.
  • Catalog (plugin-catalog-release.ts, plugin-marketplace.ts): catalog releases can declare icon-theme, and marketplaces stop hiding icon packs.

Why

  • Load SVGs only when selected. Sending every icon theme's images to the renderer on each plugin change could reach megabytes for themes nobody uses. Listing stays cheap and loading is bounded.
  • Images, not inline SVG. An SVG drawn as a CSS image never runs script, so the sanitizer is defense in depth, not the boundary. Masks keep single-color icons in step with Orca's text colors.
  • A real XML parser, not patterns. Pattern matching missed namespace prefixes like x:href and had to ban url() 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.
  • Register each icon once. Inlining a data URL on every row repeated up to ~87 KB per explorer, tab and search row. A shared stylesheet keyed by icon index costs one rule per icon.
  • One component. The FileTypeIcon refactor (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 current main. The test theme uses multi-color icons: linear and radial gradients, a clip-path badge, a mask with a gradient set through style, an Inkscape export with xlink:href and editor metadata, a single-color currentColor icon, and a hostile SVG (script, onload, foreignObject, <use x:href> to an external URL, external url() in style) that is reduced to its plain rectangle.

  • Before, the explorer with built-in icons: i1-explorer-built-in.png
  • The Icon theme row with "Gradients" chosen through the real menu: i2-settings-icon-row.png
  • The explorer with plugin icons, under a plugin app theme: i3-explorer-gradients.png
  • Zoomed: gradients, the clipped TS badge, masked braces, and the single-color notes.txt icon in the theme's text color: i4-explorer-gradients-zoom.png
  • After the plugin is disabled, built-in icons are back and the stylesheet is gone: i5-explorer-plugin-disabled.png

Testing

  • Unit tests:

    • Mapping parsing, limits and the SVG plausibility check (plugin-icon-theme-artifact.test.ts).
    • Cheap listing, loading only when selected, one copy per distinct file, and byte caps (plugin-icon-theme-registry.test.ts).
    • Sanitizing a multi-color icon with gradients, clip paths, inline styles and editor metadata; monochrome detection; removal of scripts, foreignObject, <style>, <use>, event handlers, xlink:href/x:href and external url(); rejection of non-SVG and malformed input (plugin-icon-svg.test.ts).
    • File name, extension and file-icon precedence by shared icon index, and fallback (FileTypeIcon.test.tsx).
    • Selection registers one CSS rule per usable icon, skips rejected ones, and disabling the plugin removes them (plugin-icon-themes.test.ts).
    • pluginIconTheme sanitizing 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:changed and 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security:
    • Icons render as CSS images or masks only, never inline SVG.
    • SVGs are parsed and allowlisted by element and attribute namespace in the renderer, and byte size, file count and mapping count are capped in main.
  • Compatibility: pluginIconTheme is a new optional setting. Older clients ignore it and keep the built-in icons.
  • SSH: icon choice uses only file names and extensions, so remote files are themed the same way.
  • Not in this PR: editor tab icons and chat file pills still use built-in icons, because they pass the icon component to another component. Sidebar and agent icon slots are deferred.
  • Depends on: the themes PR (PR3).

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — targeted suites, tc:node, tc:web, oxlint, the change-quality gate, localization coverage and plugin e2e pass locally; full pnpm lint not run

@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch from 4bed5ac to e440c51 Compare October 19, 2026 21:41
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch from 59d5a74 to c5c5ba8 Compare October 19, 2026 21:43
@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch from e440c51 to c8b1ba8 Compare October 21, 2026 06:31
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch from c5c5ba8 to 059672d Compare October 21, 2026 06:32
@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch from c8b1ba8 to f1b54cb Compare October 21, 2026 12:22
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch from 059672d to 796fc9a Compare October 21, 2026 12:23
@nwparker
nwparker marked this pull request as ready for review October 21, 2026 12:24
@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch from f1b54cb to 6093e0a Compare October 21, 2026 20:09
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch from 796fc9a to 33aa2d0 Compare October 21, 2026 20:09
@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch from 6093e0a to 91448eb Compare October 24, 2026 11:43
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch from 33aa2d0 to de95f9d Compare October 24, 2026 11:43
@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch from 91448eb to 61dea6d Compare October 25, 2026 05:23
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch 2 times, most recently from 0c09906 to afce228 Compare October 26, 2026 12:04
@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch 2 times, most recently from 9e5eb2a to 77f45dc Compare October 26, 2026 12:32
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch from afce228 to 3157f58 Compare October 26, 2026 12:32
@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch from 77f45dc to 8a969d0 Compare October 28, 2026 04:57
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch from 3157f58 to a64d875 Compare October 28, 2026 04:57
@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch from 8a969d0 to 39d5f46 Compare October 28, 2026 05:30
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch 2 times, most recently from f1ac3ec to 59c239f Compare October 28, 2026 10:53
@nwparker
nwparker force-pushed the nwparker/plugins-v2-4-themes branch 2 times, most recently from 1597ccb to 68aa255 Compare October 28, 2026 21:30
@nwparker
nwparker changed the base branch from nwparker/plugins-v2-4-themes to main October 28, 2026 22:13
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0f2842d1-79cc-4e48-aba4-a0e0a8854f7f
Commits

Reviewing files that changed from the base of the PR and between 5d3af83 and 89b2e2f.

Files selected for processing: 41
  • src/main/ipc/plugins.ts
  • src/main/plugins/plugin-artifact-validation.ts
  • src/main/plugins/plugin-content-pack-registry.ts
  • src/main/plugins/plugin-icon-theme-registry.test.ts
  • src/main/plugins/plugin-icon-theme-registry.ts
  • src/main/plugins/plugin-marketplace-fetch.test.ts
  • src/main/plugins/plugin-marketplace-service.test.ts
  • src/preload/api/plugin-host-api.ts
  • src/preload/api/plugins-bridge.ts
  • src/renderer/src/app-shell/use-document-appearance.ts
  • src/renderer/src/components/FileTypeIcon.test.tsx
  • src/renderer/src/components/FileTypeIcon.tsx
  • src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
  • src/renderer/src/components/settings/AppearanceInterfaceSection.tsx
  • src/renderer/src/components/settings/PluginMarketplaceBrowser.test.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/file-type-icons.test.ts
  • src/renderer/src/lib/file-type-icons.ts
  • src/renderer/src/lib/plugin-icon-svg.test.ts
  • src/renderer/src/lib/plugin-icon-svg.ts
  • src/renderer/src/store/plugin-icon-themes.test.ts
  • src/renderer/src/store/plugin-icon-themes.ts
  • src/shared/default-global-settings.ts
  • src/shared/plugin-appearance-settings-types.ts
  • src/shared/plugin-theme-settings.test.ts
  • src/shared/plugin-theme-settings.ts
  • src/shared/plugins/plugin-catalog-release.test.ts
  • src/shared/plugins/plugin-catalog-release.ts
  • src/shared/plugins/plugin-content-pack-contributions.test.ts
  • src/shared/plugins/plugin-content-pack-contributions.ts
  • src/shared/plugins/plugin-icon-theme-artifact.test.ts
  • src/shared/plugins/plugin-icon-theme-artifact.ts
  • src/shared/plugins/plugin-manifest-contribution-validation.ts
  • src/shared/plugins/plugin-manifest.ts
  • src/shared/plugins/plugin-marketplace.test.ts
  • src/shared/plugins/plugin-marketplace.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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.
@nwparker
nwparker force-pushed the nwparker/plugins-v2-5-icon-themes branch from 59c239f to 6bc70e5 Compare October 28, 2026 22:14
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no outstanding findings.

Summary

The PR adds plugin file and folder icon themes, with bounded loading, SVG sanitizing, and built-in fallbacks.

  • Plugins can define bounded file and folder icon themes.
  • Appearance remembers which available plugin icon theme is active.
  • File lists and explorer folders use the selected theme's icons.
  • Plugin marketplaces now show icon theme packs.

Reviews (3) · Last reviewed commit: "test(plugins): keep stroke-only icons wi..." · Reviewed by Greptile

Comment thread src/renderer/src/lib/file-type-icons.ts Resolved
Comment thread src/renderer/src/lib/plugin-icon-svg.ts Resolved
…full color, and drop old icons when a theme fails to load
Comment on lines +102 to +107
for (let node: Element | null = element; node; node = node.parentElement) {
if (declaredFill(node) !== null) {
return false
}
}
return true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").

@nwparker nwparker mentioned this pull request Oct 28, 2026
7 of 9 tasks
@nwparker

Copy link
Copy Markdown
Contributor Author

Folded into #35470 (Plugin Alpha), which lands the rest of the plugin stack in one PR.

@nwparker nwparker closed this Oct 28, 2026
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.

1 participant