Fix: Prevent Multiple Electron Icons in macOS Dock#11
Open
pomelo-nwu wants to merge 1 commit intomainfrom
Open
Fix: Prevent Multiple Electron Icons in macOS Dock#11pomelo-nwu wants to merge 1 commit intomainfrom
pomelo-nwu wants to merge 1 commit intomainfrom
Conversation
…subprocesses When SDK spawns subprocesses during development, each Electron child process would appear as a separate icon in the macOS Dock. This fix: - Adds ELECTRON_RUN_AS_NODE=1 for all modes (not just packaged) - Creates hide-dock.js preload script to hide Dock icons on macOS - Configures NODE_OPTIONS to preload the script in child processes - Updates build script to copy .js files to dist-electron/libs/ Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
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.
Problem
When running
npm run devon macOS and sending a message (e.g., typing "hi"), multiple Electron icons appear in the Dock. These icons disappear after the API response is received.Root Cause
SDK Spawns Child Processes: The
@qwen-code/sdklibrary internally useschild_process.spawnto spawn child processes for handling user requests.Missing Environment Variable in Dev Mode: The original code only set
ELECTRON_RUN_AS_NODE=1whenapp.isPackagedwas true (production mode). In development mode, this environment variable was not set.Electron Runs as GUI App: Without
ELECTRON_RUN_AS_NODE, when the SDK spawns a child process usingprocess.execPath(which points to the Electron executable), macOS treats it as a separate GUI application, causing it to appear in the Dock.Processes Exit After Response: Once the API response is received, the child processes exit, and the Dock icons disappear.
Solution
Changes Made
Always Set
ELECTRON_RUN_AS_NODE=1app.isPackagedcondition so this variable is set in both development and production modesCreate
hide-dock.jsPreload ScriptLSUIElement=1environment variableapp.dock.hide()to hide the Dock iconConfigure
NODE_OPTIONS--require "hide-dock.js"toNODE_OPTIONSenvironment variableUpdate Build Script
transpile:electronto copy.jsfiles todist-electron/libs/Files Changed
src/electron/libs/hide-dock.jssrc/electron/libs/util.tsELECTRON_RUN_AS_NODE=1for all modes; addNODE_OPTIONSwith hide-dock scriptpackage.jsontranspile:electronscript to copy.jsfilesTesting
npm run devon macOSnpm run dist:mac)Checklist
Related Issues
Fixes: Multiple Electron icons appearing in macOS Dock during SDK subprocess execution