Repository navigation
fix(desktop): give the dev app an icon on linux - #216
Closed
quickbeard wants to merge 1 commit into
Closed
quickbeard wants to merge 1 commit into
quickbeard wants to merge 1 commit into
Conversation
BrowserWindow's `icon` only reaches the shell through X11's _NET_WM_ICON,
and Electron 42 runs as a native Wayland client on GNOME, where the icon
comes from the .desktop file matching the window's app_id. An unpackaged
`bun dev:desktop` therefore showed the generic executable icon, while
macOS (app.dock.setIcon) and Windows (the HWND icon) were unaffected.
Electron slugifies package.json `productName ?? name` into that app_id
before main runs — `@opencode-ai/desktop` becomes `opencode-ai-desktop`,
which matches nothing installed. app.setName(), --class and CHROME_DESKTOP
were all measured (WAYLAND_DEBUG=1, reading xdg_toplevel.set_app_id) not
to override it, so predev writes the matching entry instead.
Packaged builds need nothing: a linux deb announces
set_app_id("ai.opencode.desktop.dev"), which already agrees with the
desktop file, StartupWMClass and hicolor icon electron-builder installs.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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
On GNOME/Wayland,
bun dev:desktopshowed the generic executable icon instead of the CoDev C. macOS and Windows were fine.BrowserWindow'sicon(src/main/windows.ts:182) only reaches the shell through X11's_NET_WM_ICON, and Electron 42 runs as a native Wayland client on GNOME — where the shell resolves a window's icon by matching itsapp_idto an installed.desktopfile. macOS sets its dock icon at runtime (app.dock.setIcon) and Windows uses the HWND icon, so only Linux was affected.Root cause
Electron slugifies the app's package.json
productName ?? nameinto the Wayland app_id before main runs. Measured withWAYLAND_DEBUG=1, readingxdg_toplevel.set_app_id:@opencode-ai/desktop(the dev app)opencode-ai-desktopproductName: "CoDev Code Dev"codev-code-devai.opencode.desktop.devai-opencode-desktop-devapp.setName(),--classandCHROME_DESKTOPwere each tested and none of them override it (setNameonly changed the window title). Nothing namedopencode-ai-desktop.desktopis installed, so the shell had no icon to show.Fix
scripts/install-dev-desktop-entry.ts(new) derives that app_id from the package manifest and writes~/.local/share/applications/<app_id>.desktoppointingIcon=at the channel iconcopy-iconsalready stages, withStartupWMClassfor the X11 path andNoDisplay=trueso it never shows in the launcher.predevruns it aftercopy-icons; it is Linux-only and idempotent.Packaged builds need no change
Verified by building a deb and running it: the packaged app announces
set_app_id("ai.opencode.desktop.dev"), which already agrees with everything electron-builder installs —/usr/share/applications/ai.opencode.desktop.dev.desktop, itsIcon=/StartupWMClass, and the hicolor icon basename. Packaged Electron takes the app_id from the executable name; only the unpackaged run, where the executable is plainelectron, falls back to the package name.Test plan
bun test scripts/install-dev-desktop-entry.test.ts— 3/3 pass (the slug cases are the ones measured against Electron 42)bun typecheckcleandesktop-file-validateaccepts the generated entrybun dev:desktopon GNOME/Wayland now shows the CoDev icon in the dash — confirmed visuallyelectron-builder --linux debbuilt and the packaged binary's app_id read back as aboveDIVERGENCES.md: the existingpackages/desktop/scripts/predev.tsrow covers the added line and its reasoning; the new script and its test are fork-only files.🤖 Generated with Claude Code