fix(desktop): ship assets/ so the packaged window icon resolves - #3451
Conversation
`files` in the builder config carries `dist/`, `dist-renderer/` and
`package.json`. It does not carry `assets/`, but `createWindow` resolves the
window icon out of it:
icon: join(import.meta.dirname, '..', '..', 'assets', 'icon.png')
In a packaged app that path does not exist. The failure is silent — Electron
reports an unreadable file as an empty NativeImage rather than raising — so
the window simply carries no icon, which is most visible on Linux where there
is no executable icon to fall back on.
Copy `assets/` beside the app the way `resources/status` already is, and
resolve the root against `process.resourcesPath` when packaged. The dev path
is unchanged.
hqhq1025
left a comment
There was a problem hiding this comment.
Review of exact head 4d3956a441a97765b506e6bf803884e758912a91.
No actionable code findings.
Problem and mechanism: the packaged BrowserWindow resolves assets/icon.png from the application resources tree, but the builder previously used that source image only to generate bundle/install icons and did not ship it as a runtime resource. The PR adds the single asset directory to extraResources and selects process.resourcesPath only in packaged builds while preserving the existing repository-relative development path.
The problem definition is correct and the solution follows first principles and Occam's razor. The runtime reads one file, the package now contains that file at the matching location, and development behavior is unchanged. assets/ currently contains only the 728 KB icon, so the directory copy does not introduce unrelated package contents. The small pure path helper is justified by making both runtime layouts testable without booting Electron.
Deletion/refactor assessment: I found no production code or tests that should be removed, and no deeper refactor is required. The two tests cover the meaningful path split without mirroring electron-builder internals.
Installed-runtime verification on this head:
- full repository build passed;
- Desktop typecheck, formatting,
git diff --check, and the 2/2 focused asset tests passed; - an unsigned macOS arm64 unpacked app was built with electron-builder;
Maka.app/Contents/Resources/assets/icon.pngexists and is byte-identical to the source image (SHA-2561a4b892e4793d2e54fbb09ed5143b3875f642c33963182acc70127d07c18975a);- the packaged path helper resolves exactly to that installed file;
- the Windows workflow has successfully packaged the installer/ZIP and passed the Windows release verifier.
Merge verdict: the patch itself is ready, but I am not approving while the required GitHub state is red/incomplete. Main CI failed one unrelated Settings/titlebar E2E after 38 tests passed; the exact failed test passed when rerun locally. The Windows upgrade/autoupdate workflow is still running. Re-run the failed CI and wait for the package workflow to finish; if both are green on the same head, this revision is ready to merge without further code changes.
Residual gap: I did not visually inspect a Linux window icon because this repository's release configuration currently packages macOS and Windows. The packaged resource contract itself is verified.
Astro-Han
left a comment
There was a problem hiding this comment.
Thanks for fixing the packaged window icon path. The extraResources entry now ships assets/ beside the packaged app, while process.resourcesPath is used only for packaged runs and the existing development path remains unchanged. The focused tests and packaged Windows release checks pass on this exact head, and I found no actionable issues.
AI-assisted review disclosure: OpenAI Codex assisted with the exact-head review of resource packaging, runtime path resolution, cross-platform behavior, tests, and release checks. I verified the final diff, packaged-resource path, current head, CI, and merge state; no unverified AI output is presented as a finding.
|
Post-merge review of PR head
Please add AI-assisted review disclosure: OpenAI Codex inspected the exact diff, current packaging configuration, runtime path resolution, focused tests, and macOS/Windows artifact verifier call sites. This comment is an automated follow-up finding and does not count as independent human review. |
The bug
createWindowresolves the window icon out ofapps/desktop/assets:filesinelectron-builder.config.mjscarriesdist/**,dist-renderer/**and
package.json. It does not carryassets/, andassets/is not inextraResourceseither — so in a packaged app that path does not exist.It fails silently:
nativeImagereports an unreadable file as an emptyimage rather than raising, and
BrowserWindowthen draws no icon at all. Thesame trap the
resources/statusentry in that file already documents.macOS hides it, because the dock uses the bundle icon electron-builder
generates at build time from
icon: 'assets/icon.png'. Linux has no suchfallback for the window icon.
The fix
assets/beside the app, the wayresources/statusalready isprocess.resourcesPathwhen packagedThe dev path is unchanged: two levels up from
dist/main/still lands onapps/desktop.Notes
desktop-assets.tsis a pure helper so the packaged branch is testablewithout booting Electron; both branches are covered.
feat(desktop): let the user choose or import the app icon #3431 builds on this commit.
Verification
tsc -p apps/desktop/tsconfig.main.json --noEmitcleannode --test dist/main/__tests__/desktop-assets.test.js— 2/2I could not verify a packaged build end to end: this machine cannot start an
Electron GUI (it hangs during GUI init), so the dock/window icon was not
observed directly. The path resolution itself is covered by the tests.