Skip to content

fix: Always prevent display sleep, remove dock icon, add auto-updates#14

Merged
GordonBeeming merged 4 commits intomainfrom
always-prevent-display-sleep
Apr 3, 2026
Merged

fix: Always prevent display sleep, remove dock icon, add auto-updates#14
GordonBeeming merged 4 commits intomainfrom
always-prevent-display-sleep

Conversation

@GordonBeeming
Copy link
Copy Markdown
Owner

@GordonBeeming GordonBeeming commented Apr 3, 2026

Summary

  • Always use PreventUserIdleDisplaySleep when caffeinated (prevents both display and system sleep), removing the toggle that defaulted to system-only
  • Remove "Show dock icon" toggle -- app always runs as menu bar-only
  • Remove --display CLI flag (now the default behavior)
  • Delete unused DockIconController
  • Add auto-update checker: queries GitHub Releases API hourly (and on manual click)
  • Show down arrow indicator in menu bar when update is available
  • "Download" button in menu downloads DMG to ~/Downloads and mounts it

Test plan

  • 133 tests pass (16 new for AppVersion parsing/comparison)
  • Run app and verify no dock icon appears
  • Verify caffeination prevents display sleep (pmset -g assertions shows PreventUserIdleDisplaySleep)
  • Click "Check for Updates" -- should query GitHub and report status
  • When update available, down arrow appears next to menu bar icon
  • "Download" button downloads DMG and opens it

🤖 Generated with Claude Code

GordonBeeming and others added 2 commits April 3, 2026 10:32
- Change all PowerAssertionType defaults from preventUserIdleSystemSleep
  to preventUserIdleDisplaySleep so screens stay on when caffeinated
- Remove the "Prevent display sleep" settings toggle (always on now)
- Remove the "Show dock icon" settings toggle (always hidden now)
- Remove --display CLI flag from caffeinate and for commands
- Delete unused DockIconController
- Update CLAUDE.md window focus pattern docs

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
- Check GitHub Releases API for new versions (hourly + manual)
- Show download arrow in menu bar when update available
- Download DMG to ~/Downloads and mount for drag-install
- AppVersion model in InsomniaCore for version parsing/comparison
- 16 new tests for version parsing and comparison logic
- Skip periodic checks in dev builds

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
@GordonBeeming GordonBeeming changed the title fix: Always prevent display sleep and remove dock icon fix: Always prevent display sleep, remove dock icon, add auto-updates Apr 3, 2026
@GordonBeeming GordonBeeming marked this pull request as ready for review April 3, 2026 00:47
Copilot AI review requested due to automatic review settings April 3, 2026 00:47
Remove @mainactor from UpdateChecker to fix actor-isolation errors
in Swift 5.10 strict concurrency mode. Add strict concurrency build
command to CLAUDE.md so future changes are tested before pushing.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes Insomnia’s caffeination behavior to always prevent display sleep (and thus system sleep), simplifies the GUI to be menu bar–only (no Dock icon toggle / controller), and introduces a basic auto-update flow that checks GitHub Releases and offers a DMG download action.

Changes:

  • Switch default power assertion type across core/scheduling/CLI/tests to PreventUserIdleDisplaySleep and remove the “prevent display sleep” toggle + --display CLI flag.
  • Make the GUI always run as an accessory (menu bar–only) app and delete the Dock icon controller and related settings.
  • Add a GitHub Releases–based update checker, an update-available indicator in the menu bar label, and menu actions to check/download.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
Tests/InsomniaIntegrationTests/PowerAssertionIntegrationTests.swift Updates assertion expectation to display sleep prevention.
Tests/InsomniaCoreTests/PowerAssertionManagerTests.swift Updates default assertion expectation; removes redundant display-type test.
Tests/InsomniaCoreTests/AppVersionTests.swift Adds coverage for version parsing/comparison used by updater.
Sources/InsomniaCore/Scheduling/ScheduleRule.swift Changes default assertion type to display sleep prevention.
Sources/InsomniaCore/Scheduling/CaffeinationScheduler.swift Changes default assertion type for scheduler entrypoints.
Sources/InsomniaCore/Power/PowerAssertionManager.swift Changes default assertion type for manager APIs (docs need alignment).
Sources/InsomniaCore/Models/InsomniaConfiguration.swift Removes display-sleep toggle; makes preferred assertion type always display sleep.
Sources/InsomniaCore/Models/AppVersion.swift Introduces AppVersion parsing/comparison helper.
Sources/InsomniaCLI/Commands/CaffeinateForCommand.swift Removes --display; always uses default (display sleep prevention).
Sources/InsomniaCLI/Commands/CaffeinateCommand.swift Removes --display; always uses default (display sleep prevention).
Sources/Insomnia/Views/SettingsView.swift Removes display sleep + dock icon settings UI sections.
Sources/Insomnia/Views/MenuBarView.swift Adds update menu section (check/download).
Sources/Insomnia/Views/AboutView.swift Switches icon loading to use the app icon image (current implementation is problematic).
Sources/Insomnia/ViewModels/SettingsViewModel.swift Removes dock icon + display sleep related bindings/side effects.
Sources/Insomnia/Update/UpdateChecker.swift Adds periodic GitHub Releases checks and DMG download/open behavior.
Sources/Insomnia/Update/GitHubRelease.swift Adds minimal Codable model to decode GitHub releases/assets.
Sources/Insomnia/InsomniaApp.swift Injects UpdateChecker into menu view; shows update indicator in menu bar label.
Sources/Insomnia/DockIconController.swift Deleted unused Dock icon controller implementation.
Sources/Insomnia/AppDelegate.swift Always sets accessory mode; wires up UpdateChecker periodic checks.
CLAUDE.md Updates documented window focus pattern for always-accessory app.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Only set isUpdateAvailable when valid DMG URL exists
- Gate download button on downloadURL presence in menu UI
- Show lastError in update section for user-visible feedback
- Validate download URL host against GitHub allowlist
- Move file I/O in downloadAndInstall to background thread
- Fix NSApp.applicationIconImage optional binding in AboutView
- Update all doc comments from "system sleep" to "display sleep"

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
@GordonBeeming GordonBeeming merged commit 85cdfd5 into main Apr 3, 2026
2 checks passed
@GordonBeeming GordonBeeming deleted the always-prevent-display-sleep branch April 3, 2026 01:01
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.

2 participants