mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 13:05:14 +03:00
fix(desktop): stop AppImage executable name ending in .desktop (#58263)
This commit is contained in:
committed by
GitHub
Unverified
parent
7a62a46695
commit
91a7fe54cf
@@ -51,7 +51,14 @@ test.each(channels)("channel identity for $channel", ({ channel, appId }) => {
|
||||
const config = load(channel)
|
||||
expect(config.appId).toBe(appId)
|
||||
expect(config.extraMetadata?.desktopName).toBe(`${appId}.desktop`)
|
||||
expect(config.linux?.executableName).toBe(appId)
|
||||
// The executable must never end in `.desktop`: libappimage resolves the
|
||||
// AppImage's desktop entry by globbing `*.desktop`, and an ELF matching
|
||||
// that glob breaks integration (anomalyco/opencode#51867).
|
||||
expect(config.linux?.executableName).toBe(appId.replace(/\.desktop$/, ""))
|
||||
expect(config.linux?.executableName).not.toMatch(/\.desktop$/)
|
||||
// The installed `.desktop` filename still derives from `desktopName` so
|
||||
// window association (StartupWMClass/desktop file basename) is unchanged.
|
||||
expect(config.linux?.syncDesktopName).toBe(true)
|
||||
expect(config.linux?.desktop?.entry?.StartupWMClass).toBe(appId)
|
||||
|
||||
for (const fpm of [config.deb?.fpm, config.rpm?.fpm]) {
|
||||
@@ -69,8 +76,8 @@ test.each(channels)("channel identity for $channel", ({ channel, appId }) => {
|
||||
|
||||
test("legacy Linux launcher stays hidden", async () => {
|
||||
const desktop = await Bun.file(path.join(import.meta.dirname, "resources/linux/opencode-desktop.desktop")).text()
|
||||
expect(desktop).toContain("Exec=/opt/OpenCode/ai.opencode.desktop %U")
|
||||
expect(desktop).toContain("Icon=ai.opencode.desktop")
|
||||
expect(desktop).toContain("Exec=/opt/OpenCode/ai.opencode %U")
|
||||
expect(desktop).toContain("Icon=ai.opencode")
|
||||
expect(desktop).toContain("StartupWMClass=ai.opencode.desktop")
|
||||
expect(desktop).toContain("NoDisplay=true")
|
||||
})
|
||||
|
||||
@@ -76,6 +76,19 @@ const APP_IDS = {
|
||||
prod: "ai.opencode.desktop",
|
||||
} as const
|
||||
|
||||
// libappimage (used by AppImageLauncher) resolves the .desktop entry inside an
|
||||
// AppImage by globbing `*.desktop` at the squashfs root. If the main
|
||||
// executable itself ends in `.desktop` (prod appId `ai.opencode.desktop`), the
|
||||
// ELF binary matches the glob and is parsed as a desktop entry, so
|
||||
// integration fails with `Malformed desktop entry: Unexpected char '\x7f' at 0`
|
||||
// (0x7F is the first byte of the ELF magic).
|
||||
// https://github.com/anomalyco/opencode/issues/51867
|
||||
// Strip a trailing `.desktop` so the executable can never collide with the
|
||||
// desktop-entry glob. Beta/dev appIds end in `.beta`/`.dev` and are unaffected.
|
||||
function linuxExecutableName(appId: string): string {
|
||||
return appId.replace(/\.desktop$/, "")
|
||||
}
|
||||
|
||||
const getBase = (appId: string): Configuration => {
|
||||
const target = getCurrentCli()
|
||||
|
||||
@@ -205,7 +218,11 @@ const getBase = (appId: string): Configuration => {
|
||||
linux: {
|
||||
icon: `resources/icons`,
|
||||
category: "Development",
|
||||
executableName: appId,
|
||||
executableName: linuxExecutableName(appId),
|
||||
// Derive the installed `.desktop` filename from `desktopName`
|
||||
// (`ai.opencode.desktop.desktop` for prod) instead of `executableName`,
|
||||
// so window association is unaffected by the executable rename above.
|
||||
syncDesktopName: true,
|
||||
desktop: {
|
||||
entry: {
|
||||
// Match the installed .desktop file and hicolor icon basename so
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Name=OpenCode
|
||||
Exec=/opt/OpenCode/ai.opencode.desktop %U
|
||||
Exec=/opt/OpenCode/ai.opencode %U
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Icon=ai.opencode.desktop
|
||||
Icon=ai.opencode
|
||||
StartupWMClass=ai.opencode.desktop
|
||||
NoDisplay=true
|
||||
Comment=Open source AI coding agent
|
||||
|
||||
Reference in New Issue
Block a user