Skip to content

fix(desktop): revert broken file icon origin fix + bundle all icon sources#3218

Merged
saddlepaddle merged 3 commits into
mainfrom
saddlepaddle/mirage-emoji
Apr 6, 2026
Merged

fix(desktop): revert broken file icon origin fix + bundle all icon sources#3218
saddlepaddle merged 3 commits into
mainfrom
saddlepaddle/mirage-emoji

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Apr 6, 2026

Summary

  • Reverts fix(desktop): resolve file icons from origin instead of href #3199 (resolve file icons from origin instead of href) which broke production — file:// URLs have a null origin, causing new URL() to throw. The original href-based resolution works correctly with hash routing.
  • Fixes the file icon generation script to collect icons from all manifest sources: languageIds (12 previously missing icons like angular, php, matlab, diff), rootFolder/rootFolderExpanded, and rootFolderNames/rootFolderNamesExpanded.
  • Expands the languageId-to-extension map (php, tex, matlab, diff) so these extensions resolve at runtime without VS Code's language detection.

Result: 1055 → 1067 SVGs bundled, 1148 → 1152 extension mappings.

Test plan

  • Run bun dev in apps/desktop and verify file icons render in the files sidebar
  • Check that .php, .tex, .m (matlab), .diff files show correct icons
  • Verify icons still work in packaged production build (file:// protocol)

Summary by cubic

Fixes file icon URL resolution in the desktop app by reverting to href, so icons load in file:// builds. Also bundles icons from all manifest sources and expands extension mappings (including .m and .patch) to cover missing icons.

  • Bug Fixes

    • Revert origin-based URL building; file:// has a null origin and broke new URL.
    • Use location.href (with trailing slash) as the base for icon URLs.
  • New Features

    • Collect icons from languageIds, rootFolder/rootFolderExpanded, and rootFolderNames/rootFolderNamesExpanded.
    • Add languageId-to-extension mappings for php, tex, matlab (.m), and diff (.patch).
    • Result: 1067 SVGs bundled (was 1055); 1152 extension mappings (was 1148).

Written for commit fd50607. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Expanded file icon coverage with new icons for root folders (both collapsed and expanded states) and additional programming languages (PHP, TeX, MATLAB, Diff)
    • Enhanced VS Code language identifiers integration for more comprehensive file type icon support

The generate script was only collecting icons from fileNames,
fileExtensions, folderNames, and folderNamesExpanded — missing
languageIds (12 icons), rootFolder defaults, and rootFolderNames.
Also expand languageId-to-extension mappings for php, tex, matlab,
and diff so they resolve without VS Code's language detection.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

These changes enhance the desktop application's icon handling system by expanding the file icon generation script to support VS Code languageIds mappings and additional folder icon categories, while updating the icon asset resolver's base URL derivation logic.

Changes

Cohort / File(s) Summary
Icon Generation Enhancements
apps/desktop/scripts/generate-file-icons.ts
Extended icon set references to include rootFolder and rootFolderExpanded defaults. Added support for VS Code languageIds mappings via new languageIdExtensionMap. Expanded folder icon coverage with rootFolderNames and rootFolderNamesExpanded references. Added new languageId→icon mappings for php, tex, matlab, and diff.
Icon Asset Resolver Update
apps/desktop/src/renderer/.../resolveFileIconAssetUrl.ts
Modified base URL derivation from globalThis.location?.origin to globalThis.location?.href with localhost fallback adjusted from "http://localhost" to "http://localhost/" for improved URL resolution.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰✨ The icons now dance with new grace,
Roots and languages find their place!
From origin to href we leap,
Where VS Code's secrets sleep,
Each mapping a carrot, each path runs true! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: reverting a broken fix and bundling additional icon sources.
Description check ✅ Passed The PR description is comprehensive, covering the revert rationale, icon bundling improvements, and explicit test plan with actionable verification steps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch saddlepaddle/mirage-emoji

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 and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 6, 2026

Greptile Summary

This PR contains two independent fixes for the desktop file-icon system:

  1. Reverts fix(desktop): resolve file icons from origin instead of href #3199 (resolve file icons from origin instead of href): file:// URLs expose location.origin as the literal string \"null\", which causes new URL(path, \"null\") to throw a TypeError. Switching back to location.href as the resolution base is the correct fix for Electron's hash-router environment.
  2. Expands icon bundling in generate-file-icons.ts: the script now collects icon references from languageIds, rootFolderNames/rootFolderNamesExpanded, and rootFolder/rootFolderExpanded — sources that were previously omitted — resulting in 12 additional SVGs. A languageIdExtensionMap is also added so that .php, .tex, .m, and .diff files resolve to icons without VS Code's language-detection layer.

Key changes:

  • resolveFileIconAssetUrl.ts: one-line revert; uses location.href instead of location.origin as the new URL() base
  • generate-file-icons.ts: four new icon-collection loops (languageIds, rootFolder*, rootFolderNames*); new languageIdExtensionMap for extension → icon fallbacks

One minor concern: languageIdExtensionMap values are used directly as SVG filenames rather than being resolved through manifest.languageIds. This conflates language IDs with icon names and could silently produce missing icons if material-icon-theme renames the underlying SVGs. See inline comment for a suggested fix."

Confidence Score: 4/5

Safe to merge — the revert fixes a real production crash, and the icon bundling improvements are additive with no regressions.

Score of 4 reflects a clean, well-motivated production fix with only one minor P2 robustness suggestion that does not affect correctness today.

generate-file-icons.ts warrants a quick look at the languageIdExtensionMap to confirm icon names match manifest.languageIds values.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/utils/resolveFileIconAssetUrl.ts Correctly reverts origin-based resolution to href-based; file:// URLs have null origin causing URL constructor to throw
apps/desktop/scripts/generate-file-icons.ts Expands icon collection to all manifest sources; languageIdExtensionMap uses hardcoded icon names instead of manifest.languageIds lookup (minor robustness concern)

Sequence Diagram

sequenceDiagram
    participant R as Renderer (file://)
    participant F as resolveFileIconAssetUrl
    participant U as new URL()
    participant FS as File System / SVG

    R->>F: resolveFileIconAssetUrl("typescript")
    F->>F: baseHref = location.href
    Note over F: e.g. file:///app/index.html#/dashboard
    F->>U: new URL("file-icons/typescript.svg", baseHref)
    U-->>F: file:///app/file-icons/typescript.svg
    F-->>R: "file:///app/file-icons/typescript.svg"
    R->>FS: img src file:///app/file-icons/typescript.svg
    FS-->>R: SVG bytes

    Note over R,FS: Previously broken path (PR #3199)
    R->>F: resolveFileIconAssetUrl("typescript")
    F->>F: location.origin = null string for file URLs
    F->>U: new URL("file-icons/typescript.svg", null)
    U-->>F: TypeError: Invalid URL
Loading

Comments Outside Diff (1)

  1. apps/desktop/scripts/generate-file-icons.ts, line 70-84 (link)

    P2 Hardcoded icon names bypass manifest.languageIds lookup

    The values in languageIdExtensionMap (e.g. "typescript", "php") are used directly as icon filenames. The comment above says these are language IDs, but they're treated as icon names — two different namespaces in material-icon-theme. If the upstream package ever renames an SVG (e.g. php.svgphp2.svg), the mapping silently becomes stale; the existsSync guard on line 97 will just skip the copy without any warning.

    A more resilient approach resolves the icon name through manifest.languageIds first:

    const languageIdExtensionMap: Record<string, string> = {
        ts: "typescript",
        js: "javascript",
        php: "php",
        tex: "tex",
        matlab: "matlab",
        diff: "diff",
    };
    
    for (const [ext, langId] of Object.entries(languageIdExtensionMap)) {
        if (!condensed.fileExtensions[ext]) {
            const iconName = manifest.languageIds?.[langId] ?? langId;
            condensed.fileExtensions[ext] = iconName;
            referencedIcons.add(iconName);
        }
    }

    This falls back to the hardcoded string when the language ID is absent from the manifest, preserving current behaviour while being more robust to upstream changes.

Reviews (1): Last reviewed commit: "fix(desktop): collect all icon sources i..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/desktop/scripts/generate-file-icons.ts`:
- Around line 70-77: The languageIdExtensionMap entry for MATLAB is incorrect:
replace the key "matlab" with the actual file extension "m" (i.e., update
languageIdExtensionMap so it contains m: "matlab" instead of matlab: "matlab")
so `.m` files map to the MATLAB icon; locate and edit the languageIdExtensionMap
constant to make this change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 33f1036f-8cfc-4868-ad73-f010b053a363

📥 Commits

Reviewing files that changed from the base of the PR and between 4a29342 and 88f14f5.

📒 Files selected for processing (2)
  • apps/desktop/scripts/generate-file-icons.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/utils/resolveFileIconAssetUrl.ts

Comment on lines +70 to 77
const languageIdExtensionMap: Record<string, string> = {
ts: "typescript",
js: "javascript",
php: "php",
tex: "tex",
matlab: "matlab",
diff: "diff",
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Bug: MATLAB extension mapping should be m, not matlab.

The PR objective states: "Verify that .m (matlab) files show correct icons." However, the current mapping matlab: "matlab" would match .matlab files, not .m files—MATLAB's actual file extension.

🐛 Proposed fix
 const languageIdExtensionMap: Record<string, string> = {
   ts: "typescript",
   js: "javascript",
   php: "php",
   tex: "tex",
-  matlab: "matlab",
+  m: "matlab",
   diff: "diff",
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/desktop/scripts/generate-file-icons.ts` around lines 70 - 77, The
languageIdExtensionMap entry for MATLAB is incorrect: replace the key "matlab"
with the actual file extension "m" (i.e., update languageIdExtensionMap so it
contains m: "matlab" instead of matlab: "matlab") so `.m` files map to the
MATLAB icon; locate and edit the languageIdExtensionMap constant to make this
change.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/scripts/generate-file-icons.ts">

<violation number="1" location="apps/desktop/scripts/generate-file-icons.ts:75">
P2: The map key is used as the file extension (`condensed.fileExtensions[ext]`), so `matlab: "matlab"` registers `.matlab` — not `.m`. MATLAB's actual file extension is `.m`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread apps/desktop/scripts/generate-file-icons.ts Outdated
Map `.m` (not `.matlab`) to the matlab icon since that's the actual
file extension. Also add `.patch` → diff (already covered by upstream).
@saddlepaddle saddlepaddle merged commit 700cd65 into main Apr 6, 2026
5 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

MocA-Love pushed a commit to MocA-Love/superset that referenced this pull request Apr 7, 2026
…urces (superset-sh#3218)

* Revert "fix(desktop): resolve file icons from origin instead of href (superset-sh#3199)"

This reverts commit 5578746.

* fix(desktop): collect all icon sources in file icon generation

The generate script was only collecting icons from fileNames,
fileExtensions, folderNames, and folderNamesExpanded — missing
languageIds (12 icons), rootFolder defaults, and rootFolderNames.
Also expand languageId-to-extension mappings for php, tex, matlab,
and diff so they resolve without VS Code's language detection.

* fix(desktop): correct languageId extension mappings for matlab/diff

Map `.m` (not `.matlab`) to the matlab icon since that's the actual
file extension. Also add `.patch` → diff (already covered by upstream).
MocA-Love added a commit to MocA-Love/superset that referenced this pull request Apr 7, 2026
cherry-pick済み:
- e728ebd feat(desktop): wire up missing hotkeys for v2 workspace (superset-sh#3190)
- 1eddeb3 feat(desktop): git changes sidebar with resource-oriented API (superset-sh#3177)
- 11ed4f8 V2 terminal env (superset-sh#3184)
- 0c52ecc feat(desktop): pane context menus + binary tree layout (superset-sh#3196)
- 5578746 fix(desktop): resolve file icons from origin instead of href (superset-sh#3199)
- 5a1e5d1 feat(panes): prefer sibling pane when closing active pane (superset-sh#3198)
- d670c4a V2 top bar: right sidebar toggle, org dropdown in sidebar, unified open-in button (superset-sh#3197)
- 2573fa2 fix(desktop): remove macOS background-to-tray quit interception (superset-sh#3205)
- 4a29342 feat: Superset CLI + CLI framework + Better Auth 1.5.6 (superset-sh#3194)
- 700cd65 fix(desktop): revert broken file icon origin fix + bundle all icon sources (superset-sh#3218)

フォーク独自対応:
- cleanupMainWindowResources()をexit pathに移動維持 (#3205対応)
- BROWSER_HARD_RELOAD/SEARCH_IN_FILESをv2 workspaceに配線
- BROWSER_RELOAD/HARD_RELOADのuseHotkey配線修正(リマップ対応)
- ansi_up依存維持
@Kitenite Kitenite deleted the saddlepaddle/mirage-emoji branch April 13, 2026 16:36
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