Skip to content

fix(application/updater): desktop shortcut icon survives updates on linux - #239

Merged
Nat3z merged 2 commits into
mainfrom
fix/desktop-shortcut-icon-survives-update
Aug 23, 2026
Merged

fix(application/updater): desktop shortcut icon survives updates on linux#239
Nat3z merged 2 commits into
mainfrom
fix/desktop-shortcut-icon-survives-update

Conversation

@Nat3z

@Nat3z Nat3z commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Description

On Linux, addToDesktop() copied the shortcut icon to ./favicon.png — but the app's cwd is the updater's update/ directory, which prepareUpdateDestination() wipes on every update. The .desktop file's Icon= path then pointed at a deleted file, blanking the shortcut icon.

Fixes:

  • addToDesktop now copies the icon into the OGI data dir (~/.local/share/OpenGameInstaller/favicon.png), which updates never touch. Moved it out of handler.app.ts into helpers.app/desktop-shortcut.ts so migrations and the RPC handler import a testable leaf module.
  • Added a repair-desktop-shortcut-icon migration (linux, 2.5.04.3.0) that rewrites the shortcut with the durable icon path — only if the user still has the .desktop file.
  • The updater's PRESERVED_UPDATE_ENTRIES now keeps favicon.png, so shortcuts written by older app versions survive updates too.

Regression test recreates the real layout (cwd = update/, sandboxed home + data dirs), creates the shortcut, simulates the updater wipe, and asserts the icon path still exists. Red before the fix, green after.

Example

$ bun test tests/desktop-shortcut.test.ts
 1 pass
 0 fail

.desktop now points at the durable copy:

Icon=/home/user/.local/share/OpenGameInstaller/favicon.png

Next Steps

  • Lower the migration's to: 4.3.0 bound if the next release is 4.2.10 instead.
  • Optionally regenerate the shortcut on every launch to self-heal stale Exec= paths.

Summary by CodeRabbit

  • New Features

    • Added Linux desktop shortcut creation with support for development, installed, and setup environments.
    • Existing shortcuts are automatically refreshed during Linux migrations.
  • Bug Fixes

    • Desktop shortcut icons now remain available after application updates and cleanup operations.
  • Tests

    • Added coverage verifying shortcut creation and icon persistence after updates.

@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
open-game-installer-web Ready Ready Preview Aug 23, 2026 11:36pm

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1a8a7ca7-8229-4c8f-86a0-0f7d7c69a449

📥 Commits

Reviewing files that changed from the base of the PR and between c4e3c29 and b027715.

📒 Files selected for processing (5)
  • application/src/electron/handlers/handler.app.ts
  • application/src/electron/handlers/helpers.app/desktop-shortcut.ts
  • application/src/electron/migrations.ts
  • application/tests/desktop-shortcut.test.ts
  • updater/src/main.ts

📝 Walkthrough

Walkthrough

The change moves desktop shortcut creation into a shared helper, adds a Linux migration to repair existing shortcuts, preserves favicon.png during updates, and tests icon persistence after updater cleanup.

Changes

Desktop shortcut lifecycle

Layer / File(s) Summary
Shortcut helper and RPC wiring
application/src/electron/handlers/helpers.app/desktop-shortcut.ts, application/src/electron/handlers/handler.app.ts
The RPC procedure now calls the shared addToDesktop helper. The helper resolves paths, creates the shortcut, and returns structured filesystem errors.
Icon preservation and validation
updater/src/main.ts, application/tests/desktop-shortcut.test.ts
Updater cleanup preserves favicon.png. Tests verify that the shortcut icon remains after the update directory is wiped.
Shortcut repair migration
application/src/electron/migrations.ts
A Linux migration recreates an existing desktop shortcut when the shortcut is present.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: nat-openclaw

Sequence Diagram(s)

sequenceDiagram
  participant ElectronRpcApp
  participant addToDesktop
  participant FileSystem
  participant Updater
  ElectronRpcApp->>addToDesktop: create desktop shortcut
  addToDesktop->>FileSystem: copy favicon.png and write .desktop file
  Updater->>FileSystem: remove update entries
  Updater->>FileSystem: preserve favicon.png
  FileSystem-->>addToDesktop: icon path remains available
Loading

Poem

I’m a rabbit with shortcuts neat,
An icon safe from update feet.
The helper writes, migrations mend,
While favicon.png stays till the end.
Hop, hop—desktop paths now blend!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/desktop-shortcut-icon-survives-update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Nat3z
Nat3z merged commit 3a0eced into main Aug 23, 2026
6 of 7 checks passed
@Nat3z
Nat3z deleted the fix/desktop-shortcut-icon-survives-update branch August 23, 2026 23:37
@greptile-apps

greptile-apps Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR moves Linux desktop-shortcut icons into the durable OpenGameInstaller data directory, repairs existing shortcuts during migration, and preserves icons created by older versions during updater cleanup.

  • Extracts shortcut creation into a testable helper.
  • Adds a version-gated Linux shortcut repair migration.
  • Retains legacy favicon.png files in the updater destination.
  • Adds coverage for the durable data-directory placement, though not the updater’s legacy preservation branch.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking test-coverage gap around preservation of shortcuts created by older versions.

The durable icon path and migration are consistent with the application’s Linux data-directory and migration lifecycle, but the updater-specific legacy preservation branch is not directly protected by the added regression test.

Files Needing Attention: updater/src/main.ts, application/tests/desktop-shortcut.test.ts

Important Files Changed

Filename Overview
application/src/electron/handlers/helpers.app/desktop-shortcut.ts Extracts shortcut creation and relocates the copied icon from the disposable working directory to the Linux OGI data directory.
application/src/electron/migrations.ts Adds a Linux migration that repairs an existing shortcut without recreating one the user removed.
updater/src/main.ts Preserves legacy shortcut icons during update-directory cleanup, but this compatibility behavior lacks direct regression coverage.
application/tests/desktop-shortcut.test.ts Verifies that the newly durable icon survives an update-directory wipe but does not exercise preservation of an older update/favicon.png.
application/src/electron/handlers/handler.app.ts Replaces the inline shortcut implementation with an import from the extracted helper.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Linux application startup] --> B{Desktop shortcut exists?}
  B -- Yes --> C[Repair migration]
  C --> D[Copy icon to OGI data directory]
  D --> E[Rewrite desktop Icon path]
  B -- No --> F[Leave shortcut absent]
  G[Updater cleanup] --> H[Preserve legacy update/favicon.png]
  H --> I[Install updated application]
Loading

Fix all with Greploop Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
### Issue 1
updater/src/main.ts:136-142
**Legacy icon preservation is untested**

The regression test creates the icon in the new durable data directory and simulates cleanup using the old three-entry preservation set, so it never exercises the new `favicon.png` compatibility branch. A regression in `prepareUpdateDestination` could therefore delete icons referenced by shortcuts from older versions without failing this test.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(updater): preserve favicon.png when ..." | Re-trigger Greptile

Comment thread updater/src/main.ts
Comment on lines +136 to 142
const PRESERVED_UPDATE_ENTRIES = new Set([
'artifacts',
'latest.log',
'logs',
'favicon.png',
]);
const OGI_REPO_URL = 'https://github.com/Nat3z/OpenGameInstaller';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Legacy icon preservation is untested

The regression test creates the icon in the new durable data directory and simulates cleanup using the old three-entry preservation set, so it never exercises the new favicon.png compatibility branch. A regression in prepareUpdateDestination could therefore delete icons referenced by shortcuts from older versions without failing this test.

Prompt To Fix With AI
This is a comment left during a code review.
Path: updater/src/main.ts
Line: 136-142

Comment:
**Legacy icon preservation is untested**

The regression test creates the icon in the new durable data directory and simulates cleanup using the old three-entry preservation set, so it never exercises the new `favicon.png` compatibility branch. A regression in `prepareUpdateDestination` could therefore delete icons referenced by shortcuts from older versions without failing this test.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

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.

1 participant