Skip to content

feat: add official fileIcons API and Icon pack setting - #2887

Open
bajrangCoder wants to merge 8 commits into
mainfrom
file-icons-api
Open

feat: add official fileIcons API and Icon pack setting#2887
bajrangCoder wants to merge 8 commits into
mainfrom
file-icons-api

Conversation

@bajrangCoder

@bajrangCoder bajrangCoder commented Sep 12, 2026

Copy link
Copy Markdown
Member

Summary

Adds an official plugin API for file and folder icon packs, plus a user setting to choose the active pack.

Plugins register packs with acode.require("fileIcons"). The loader binds that API to the loading plugin and supplies ownership automatically. Acode owns matching, loading, fallback, and rendering. Users pick the pack in Settings → App settings → Icon pack. Builtin stays the default and remains available while a plugin pack is loading.

This replaces the earlier draft/internal icon helpers with a stable public surface: register, icon, and onChange. Pack selection, catalog queries, and DOM refresh stay internal.

User-facing

  • New Icon pack setting under App settings (interface).
  • Builtin pack is always present.
  • A previously selected plugin pack is restored automatically when that plugin registers again after startup.
  • File and folder icons update in the explorer, recents, search results, and other file lists.

Plugin API

Capture acode.require("fileIcons") synchronously in the plugin main script, and keep that API for later async work. Do not call require("fileIcons") for the first time after an await. The same bound API is also available as options.fileIcons in setPluginInit. Omit pluginId; if supplied, it must match the loading plugin.

const fileIcons = acode.require("fileIcons");

acode.setPluginInit(plugin.id, (baseUrl) => {
  registration = fileIcons.register({
    id: plugin.id,
    name: "My Icons",
    icons: `${baseUrl}icons/`,
    fileNames: { "package.json": "nodejs" },
    fileExtensions: { js: "javascript", ts: "typescript" },
    folderNames: { src: "folder-src" },
    folderNamesExpanded: { src: "folder-src-open" },
    folder: "folder",
    folderExpanded: "folder-open",
  });
});

acode.setPluginUnmount(plugin.id, () => registration.dispose());
  • register(pack) publishes or atomically replaces a pack. It does not select it.
  • icon(resource) returns a CSS class string for a file or folder.
  • onChange(listener) notifies when the active pack or assets change, for plugins that draw their own file lists.

Example plugin: acode-icon-plugin-example

@github-actions github-actions Bot added the translations Anything related to Translations Whether a Issue or PR label Sep 12, 2026
@greptile-apps

greptile-apps Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the earlier localization, recycled-row, ownership, and listener-lifecycle findings are all fully addressed.

Findings

  1. P1 Localization catalogs are unsynchronized

Summary

  • Registers, validates, loads, selects, and disposes plugin-owned icon packs with builtin fallback.
  • Exposes scoped register, icon, and onChange APIs through plugin loading.
  • Updates explorer, recents, search, references, dialogs, and settings UI to render refreshable file icons.
  • Synchronizes the new settings strings across locale catalogs and generated language declarations.
  • Fixes recycled file-tree rows and cleans plugin listeners before unload notifications.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Plugin[Plugin main script] --> Loader[Plugin loader]
    Loader --> BoundAPI[Plugin-bound fileIcons API]
    BoundAPI --> Registry[File icon registry]
    Registry --> Packs[Validated icon packs and assets]
    Settings[Icon pack setting] --> Registry
    Registry --> Active[Active pack or builtin fallback]
    Active --> UI[Explorer and file-list UI]
    Registry --> Change[Scoped change notifications]
    Change --> UI
    Unload[Plugin unload or failed initialization] --> Cleanup[Remove listeners and owned packs]
    Cleanup --> Registry
Loading

Reviews (3) · Last reviewed commit: "fix: listeners leak"

Comment thread src/lang/en-us.json
Comment thread src/components/fileTree/index.js
Comment thread src/lib/fileIcons.ts
@bajrangCoder

This comment was marked as outdated.

Comment thread src/lib/fileIcons.ts Outdated
@bajrangCoder

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

translations Anything related to Translations Whether a Issue or PR

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant