feat: support URL icons in tool-icons.json#560
Open
kennyheard wants to merge 5 commits intolukilabs:mainfrom
Open
feat: support URL icons in tool-icons.json#560kennyheard wants to merge 5 commits intolukilabs:mainfrom
kennyheard wants to merge 5 commits intolukilabs:mainfrom
Conversation
URL icons are downloaded and cached locally on startup and when the config changes, matching how source and skill icons work. Orphaned icon files are cleaned up when tools are removed from the config.
…cons
When a tool's icon is a URL, check for the specific file downloadIcon
would produce ({toolId}.{ext} derived from URL, defaulting to .svg)
rather than using findToolIconFile which matches any extension. This
prevents stale bundled files (e.g. git.ico) from blocking the download
of the correct CDN version (git.svg).
e278484 to
398c017
Compare
loadIconFile and discoverIconFile now return ResolvedEntityIcon directly,
eliminating the intermediate { dataUrl, colorable, rawSvg } shape and the
manual reconstruction in useEntityIcon.
Tool icons in settings now render through EntityIcon (same as source/skill icons) instead of <img> tags. The server sends raw SVG content alongside the data URL, and the renderer resolves it via resolveRawSvgIcon.
…ering resolveRawSvgIcon now strips embedded <style> blocks and replaces all hardcoded fill colors with currentColor before rendering inline. This makes SVG icons (from CDNs like Simple Icons) inherit the text color instead of displaying their brand color. Icons with fill="none" (multi-color SVGs) are left untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tool icons in
tool-icons.jsoncurrently only support local filenames (e.g."icon": "git.ico"). This adds support for URL values (e.g."icon": "https://cdn.simpleicons.org/git/000/fff"), bringing tool icons in line with how source and skill icons already handle remote assets.When a tool's icon is a URL, it is downloaded and cached as a local file in the
tool-icons/directory, keyed by tool ID (e.g.git.svg). This means icons are fetched once and served locally from that point on — no repeated network requests during rendering.The download happens both at startup (via
ensureToolIcons) and live while the app is running (via a newConfigWatcherhandler fortool-icons.json). When a tool is removed from the config, its cached icon file is cleaned up automatically.As part of this change, the startup seeding logic was tightened so that only bundled icon files actually referenced by the config are copied — previously all bundled files were copied unconditionally.
Changes
cli-icon-resolver.ts: AddedfindToolIconFileto locate cached icon files by tool ID. UpdatedresolveToolIconto check for cached local copies when the icon is a URL.workspace.ts: Same resolution logic applied to the Settings > Appearance > Tool Icons handler so the UI correctly displays URL-based icons.storage.ts: ReworkedensureToolIconsto download URL icons on first run, seed only referenced bundled icons, and clean up orphaned files.watcher.ts: Added a file watcher fortool-icons.jsonthat downloads new URL icons and removes orphaned files when the config changes at runtime.Test plan
Note:
tool-icons.jsonis typically edited by the agent on the user's behalf, not manually.~/.craft-agent/tool-icons/