Automatic Updates
Relevant source files
The following files were used as context for generating this wiki page:
The Automatic Updates system in Messenger Unleashed is designed to ensure the application remains current with the latest features, security patches, and privacy enhancements without requiring manual user intervention. The system utilizes platform-specific update mechanisms: electron-updater for Windows and a custom shell-script-based installer for macOS.
This module handles version comparison against the GitHub releases API, manages update downloads in the background, and provides a user interface for confirming installations and restarts. Sources: src/main/updates.ts:1-12, CLAUDE.md:73-77
Architecture and Components
The update system is divided into three primary logical flows: Version Verification, Windows Auto-Updating, and macOS Scripted Installation.
Version Verification Logic
The application checks for updates by querying the GitHub Releases API for the latest tag. It normalizes version strings (e.g., removing 'v' prefixes and build metadata) to perform a numeric comparison between the current app.getVersion() and the candidate release. Sources: src/main/updates.ts:25-50, src/main/updates.ts:79-88
The flow diagram above illustrates the initial logic used to determine if an update is necessary before triggering platform-specific drivers. Sources: src/main/updates.ts:168-232
Windows Update System (electron-updater)
On Windows, the system leverages electron-updater. It is configured to automatically download updates and prepare them for installation when the application quits. Sources: src/main/updates.ts:91-100
Key event handlers for the Windows updater include:
- update-available: Informs the user that a download has started if the check was not silent.
- update-downloaded: Prompts the user to "Restart Now" or "Later".
- error: Catches and logs update failures, displaying a dialog if necessary.
Sources: src/main/updates.ts:102-143
macOS Update System (Scripted)
Because standard auto-updaters can be restricted on macOS, the project uses a custom bash script method. When a new version is detected, the app downloads a script from a GitHub URL and executes it via osascript with administrator privileges. Sources: src/main/updates.ts:17-19, src/main/updates.ts:145-166
The sequence diagram shows the unique privilege escalation flow required for macOS updates. Sources: src/main/updates.ts:145-166
Update Configuration and Metadata
The system relies on specific repository metadata and environment variables to locate assets.
Key Update Constants
| Variable | Value / Source | Description |
|---|---|---|
UPDATE_REPO | pcstyleorg/messenger-desktop | The GitHub repository path. |
INSTALL_SCRIPT_URL | https://raw.githubusercontent.../install.sh | The source for the macOS installer script. |
autoUpdater | electron-updater | Library used for Windows binary delta updates. |
normalizeVersion | Internal Function | Strips 'v' and '-' to ensure 2.1.3 format for comparison. |
Sources: src/main/updates.ts:16-23, src/main/updates.ts:25-30
Build Configuration (package.json)
The electron-builder configuration defines how updates are published and distributed. It specifies GitHub as the provider and defines the storage of platform-specific artifacts like .dmg for macOS and .exe for Windows. Sources: package.json:64-75
Integration with User Interface
Updates can be triggered manually or automatically upon application startup.
- Manual Check: Available via the "Unleashed" menu under "Check for Updates...". Sources: src/main/index.ts:1120-1123
- Automatic Check: Triggered in
app.whenReady()with thesilentflag set totrue. Sources: src/main/updates.ts:232, src/main/index.ts:1418 - Landing Page: The project website provides direct links to the latest release binaries based on the version defined in the codebase. Sources: landing-page/src/app/HomeClient.tsx:64-70
Settings Modal Representation
The application version and update status are visible within the custom Settings UI, which is managed via the preload bridge and displayed as a sandboxed modal. Sources: src/preload/settings-modal.ts:114-118
Technical Constraints and Security
- Packaged Builds Only: Update logic is explicitly disabled for non-packaged (development) builds to prevent errors in the development environment. Sources: src/main/updates.ts:173-181, src/main/updates.ts:213-221
- Request Headers: All update-related network requests use a specific User-Agent identifying the app and platform to comply with GitHub API requirements. Sources: src/main/updates.ts:58-61
- Script Validation: The macOS installer script must start with a shebang (
#!) or the application will throw an "invalid script" error. Sources: src/main/updates.ts:147-149
Conclusion
The Automatic Update system provides a robust cross-platform solution for maintaining Messenger Unleashed. By combining the industry-standard electron-updater for Windows with a specialized privilege-aware script for macOS, the application ensures high reliability and security in its distribution model. Sources: src/main/updates.ts:227-232, CLAUDE.md:73-77