Skip to content

Conversation

@sumitduster-iMac
Copy link
Owner

@sumitduster-iMac sumitduster-iMac commented Dec 31, 2025

Ensure the app icon consistently displays the new gradient-heart icon across development, built applications, and DMGs.

The previous setup lacked explicit icon configuration for electron-builder and runtime, leading to default Electron icons being displayed instead of the intended custom icon. This PR establishes a deterministic pipeline to generate and apply the correct icon.


Open in Cursor Open in Web


Note

Ensures the custom icon is generated and consistently used at runtime and in macOS builds.

  • Adds scripts/generate-icons.mjs using @resvg/resvg-js to render assets/icon.png from assets/icon.svg; hooks into prestart, prebuild, and prebuild-dmg
  • Sets BrowserWindow icon and applies macOS dock icon at startup in main.js
  • Configures electron-builder to use assets/icon.png for app, mac, and dmg; sets directories.buildResources: assets and includes assets/**/* in files
  • Adds @resvg/resvg-js dev dependency

Written by Cursor Bugbot for commit e6a54dd. Configure here.

Adds a script to generate PNG icons from SVG and configures the app to use them.

Co-authored-by: sumitduster <[email protected]>
@cursor
Copy link

cursor bot commented Dec 31, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@sumitduster-iMac sumitduster-iMac marked this pull request as ready for review December 31, 2025 08:16
Copilot AI review requested due to automatic review settings December 31, 2025 08:16
@sumitduster-iMac sumitduster-iMac merged commit 6d401b9 into main Dec 31, 2025
5 of 6 checks passed
@sumitduster-iMac sumitduster-iMac deleted the cursor/app-icon-update-issue-a809 branch December 31, 2025 08:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR establishes a deterministic icon generation pipeline to ensure the custom gradient-heart icon displays consistently across development, built applications, and DMGs. It addresses an issue where the default Electron icon was being shown instead of the intended custom icon.

  • Adds automated SVG-to-PNG icon generation using @resvg/resvg-js
  • Configures electron-builder with explicit icon paths for macOS builds and DMGs
  • Sets runtime dock icon on macOS to ensure proper icon display during development

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 6 comments.

File Description
scripts/generate-icons.mjs New script that converts the SVG icon to a 1024x1024 PNG format
package.json Adds pre-hooks to auto-generate icons, configures electron-builder icon paths, and adds @resvg/resvg-js dependency
package-lock.json Locks @resvg/resvg-js and its platform-specific optional dependencies
main.js Adds icon path configuration for the BrowserWindow and sets the macOS dock icon at runtime

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"directories": {
"buildResources": "assets"
},
"icon": "assets/icon.png",
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

For macOS applications, electron-builder expects .icns format for the icon, not .png. While electron-builder can auto-convert PNG to ICNS in some cases, explicitly providing an ICNS file ensures better quality and reliability. Consider generating an .icns file from the PNG or using electron-builder's icon conversion capabilities by removing the extension and letting it auto-detect the correct format based on platform.

Copilot uses AI. Check for mistakes.
app.whenReady().then(() => {
// Ensure dock icon is correct in development builds on macOS.
if (process.platform === 'darwin' && app.dock) {
const iconPath = path.join(__dirname, 'assets', 'icon.png');
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The iconPath variable is declared twice - once at line 7 and again at line 56. Consider declaring it once before the conditional check to avoid code duplication and ensure consistency.

Copilot uses AI. Check for mistakes.
const svg = await fs.readFile(svgPath, 'utf8');

const resvg = new Resvg(svg, {
fitTo: { mode: 'width', value: SIZE },
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The fitTo configuration only constrains width but not height. If the SVG has a different aspect ratio, this could result in a non-square icon. For app icons, it's important to ensure both dimensions are SIZE x SIZE. Consider using fitTo mode 'original' with explicit width and height, or verify the SVG has a 1:1 aspect ratio.

Copilot uses AI. Check for mistakes.

const SIZE = 1024;

async function main() {
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The script doesn't verify that the input SVG file exists before attempting to read it. If assets/icon.svg is missing, the error message will be generic. Consider adding an explicit check with a helpful error message, such as checking if the file exists using fs.access() before reading.

Suggested change
async function main() {
async function main() {
try {
await fs.access(svgPath);
} catch (err) {
if (err && err.code === 'ENOENT') {
const relativeSvgPath = path.relative(projectRoot, svgPath);
throw new Error(`Input SVG file not found at ${relativeSvgPath}. Please ensure the file exists before running this script.`);
}
throw err;
}

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +63
maybePromise.catch(() => {});
}
} catch (_) {
// Ignore failures (e.g., missing icon in some dev setups).
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The empty catch block silently ignores all errors from app.dock.setIcon(). While the comment mentions this is intentional for missing icons, it would be better to at least log the error in development mode (e.g., if app.isPackaged is false) to help with debugging icon-related issues during development.

Suggested change
maybePromise.catch(() => {});
}
} catch (_) {
// Ignore failures (e.g., missing icon in some dev setups).
maybePromise.catch((err) => {
if (!app.isPackaged) {
console.error('Failed to set dock icon (async):', err);
}
});
}
} catch (err) {
// Ignore failures in production (e.g., missing icon in some dev setups),
// but log them in development for easier debugging.
if (!app.isPackaged) {
console.error('Failed to set dock icon (sync):', err);
}

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +49
"icon": "assets/icon.png",
"identity": null
},
"dmg": {
"icon": "assets/icon.png"
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The icon path is specified three times: at the build level (line 36), in the mac configuration (line 45), and in the dmg configuration (line 49). The build-level icon should be sufficient as it's inherited by platform-specific configurations. This redundancy could lead to maintenance issues if the icon path needs to be updated. Consider removing the redundant specifications and keeping only the build-level icon configuration.

Suggested change
"icon": "assets/icon.png",
"identity": null
},
"dmg": {
"icon": "assets/icon.png"
"identity": null
},
"dmg": {

Copilot uses AI. Check for mistakes.
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.

3 participants