Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: domzilla/Caffeine
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: bubbleee030/Caffeine
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 10 commits
  • 32 files changed
  • 1 contributor

Commits on May 18, 2026

  1. Add Swift Package test scaffold and IO backend protocols

    Introduces a root Package.swift that compiles a subset of model code into
    a CaffeineCore library so swift test can run automated unit tests without
    touching the Xcode project. Adds two backend protocols that abstract the
    system APIs that subsequent milestones will depend on:
    
    - LaunchItemBackend wraps SMAppService.mainApp for login-item registration.
    - PowerAssertionBackend wraps IOPMAssertionCreateWithDescription /
      IOPMAssertionRelease for sleep prevention.
    
    Includes a smoke test exercising the default implementations.
    bubbleee030 committed May 18, 2026
    Configuration menu
    Copy the full SHA
    f9a0d87 View commit details
    Browse the repository at this point in the history
  2. Add Launch at Login preference

    Adds a new "Launch at Login" toggle in Preferences that registers the
    app as a macOS login item via SMAppService.mainApp. The published state
    mirrors the underlying SMAppService status so manual toggles in System
    Settings flow back into the UI on next appearance.
    
    Tests cover register/unregister wiring, the no-op-when-already-enabled
    case, and recovery when the backend throws.
    bubbleee030 committed May 18, 2026
    Configuration menu
    Copy the full SHA
    2ebef57 View commit details
    Browse the repository at this point in the history
  3. Allow Mac to run with lid closed; prevent system idle sleep

    Adds an "Allow Mac to run with lid closed" preference. SleepPreventionManager
    now holds up to three IOPMAssertions while active:
      - PreventUserIdleDisplaySleep (display does not dim from inactivity)
      - PreventUserIdleSystemSleep  (system does not idle-sleep — previously absent)
      - PreventSystemSleep          (only when the new flag is on, lets the Mac
                                     keep running with the lid closed on AC power)
    
    The assertion timeout is bumped from 8 s to 30 s so the 10 s refresh always
    overlaps; the previous values left a 2 s gap every cycle.
    
    The manager accepts an injected PowerAssertionBackend so tests can verify
    which assertion types are created. Toggling the flag while active applies
    live without re-activating.
    
    Integration smoke test in scripts/integration-test.sh launches the built
    app with a debug env var, then verifies `pmset -g assertions` reflects the
    expected types.
    bubbleee030 committed May 18, 2026
    Configuration menu
    Copy the full SHA
    1d4bbad View commit details
    Browse the repository at this point in the history
  4. Add Traditional Chinese localization and new preference strings

    Adds zh-Hant.lproj/Localizable.strings (full translation) and appends the
    three new preference strings — "Launch at Login", "Allow Mac to run with
    lid closed", and the AC-power caveat — to every shipped locale (best-effort
    native translations for de/es/fr/it/nl/pt/pt-BR/ru/uk; native review
    welcome via follow-up PRs).
    
    LocalizationTests parses each .strings file and asserts the full key set
    is present, so future user-facing strings can't land without updating
    every locale.
    bubbleee030 committed May 18, 2026
    Configuration menu
    Copy the full SHA
    671fece View commit details
    Browse the repository at this point in the history
  5. Rewrite README; add Traditional Chinese tutorial; update CHANGELOG

    The README now describes this fork (bubbleee030/Caffeine) instead of the
    upstream project's download page and support contact. Adds a tutorial for
    the two new toggles, including a `pmset -g assertions` verification step,
    a Languages section listing all 14 shipped locales, and a Building from
    source section. The original FAQ entries are kept and the alternatives
    question is updated to reflect that this fork now provides lid-close
    parity with Amphetamine.
    
    README.zh-Hant.md mirrors the English README with localized headings and
    Taiwan-style vocabulary so Traditional-Chinese readers get the same
    information without an English detour.
    bubbleee030 committed May 18, 2026
    Configuration menu
    Copy the full SHA
    8479dbc View commit details
    Browse the repository at this point in the history

Commits on May 19, 2026

  1. Apply swiftformat

    bubbleee030 committed May 19, 2026
    Configuration menu
    Copy the full SHA
    d023dd7 View commit details
    Browse the repository at this point in the history
  2. Address PR #1 review feedback

    #1 SleepPreventionManager.refreshAssertions now creates the three new
       assertions before releasing the old IDs, so the kernel always sees at
       least one of each type during a refresh (swap-then-release, not
       release-then-create). The doc comment claimed overlap but the code
       left a microsecond gap. New testRefreshCreatesNewAssertionsBeforeReleasingOld
       pins the ordering via an operationLog on the test fake.
    
    #2 NSWorkspace session observers now use the Combine publisher API with
       AnyCancellable, so they detach automatically when the manager
       deallocates. The previous selector-based addObserver retained the
       target forever — fine for the production singleton, but every test
       that constructed a SleepPreventionManager(backend:) leaked two
       observers. testManagerDeallocatesWhenOutOfScope proves the leak is
       fixed via a weak ref.
    
    #3 LaunchAtLoginManager.setEnabled now logs the underlying error via
       os.Logger (subsystem net.domzilla.caffeine, visible in Console.app)
       and surfaces it on a public `lastError` property so the UI layer can
       present it to the user. refresh() still snaps the published isEnabled
       back to the backend truth, so a failed register visually pops the
       Toggle back to off. Two new tests cover lastError set on throw and
       cleared on next success.
    
    #4 scripts/integration-test.sh replaces the fixed 3 s sleep with a
       poll_for_caffeine_assertions helper that retries pmset every second
       until Caffeine-owned assertions appear (default 30 s timeout,
       overridable via ASSERTION_POLL_TIMEOUT). Avoids flakiness on slow
       runners where SwiftUI initialization takes longer than 3 s.
    bubbleee030 committed May 19, 2026
    Configuration menu
    Copy the full SHA
    1b6388c View commit details
    Browse the repository at this point in the history
  3. Address PR #1 second-round review feedback

    #5 PreferencesView no longer writes CAAllowLidClose to UserDefaults twice.
       CaffeineViewModel.setAllowLidClose now only forwards the new flag to
       SleepPreventionManager; persistence is owned by PreferencesView's
       @AppStorage binding.
    
    #6 SleepPreventionManager now releases its assertion IDs immediately when
       the user session resigns active, and re-engages immediately on become-
       active rather than waiting up to 10 s for the next timer tick. The old
       early-return in refreshAssertions left the manager's stored IDs in a
       stale state after the kernel timed them out at 30 s. Three new tests
       cover resign-releases, become-reengages, and become-while-inactive
       does nothing.
    
    #7 CA_TEST_AUTOACTIVATE no longer writes to standard UserDefaults. The
       activate(...) function takes a new allowLidCloseOverride parameter so
       the test hook can drive a known state without mutating persistent
       preferences. The intentional early-return is documented in comments.
    
    #8 LocalizationTests no longer relies on a single representative key
       ("Quit") to prove zh-Hant differs from zh-Hans. Asserts that at least
       half of all 31 user-facing values are non-identical across the two
       locales.
    
    #9 About-dialog credits now point at github.com/bubbleee030/Caffeine
       instead of github.caffeine-app.net, in line with the README rewrite.
       Added a 2026 @bubbleee030 line to the copyright credits. Updated the
       source string in MenuBarController and the localized value in all 14
       .lproj/Localizable.strings files; LocalizationTests reflects the new
       key. No remaining caffeine-app.net references in the repo.
    bubbleee030 committed May 19, 2026
    Configuration menu
    Copy the full SHA
    7f6b451 View commit details
    Browse the repository at this point in the history
  4. Merge pull request #1 from bubbleee030/feature/launch-at-login-and-li…

    …d-close
    
    Add Launch at Login + lid-close support, Traditional Chinese, automated tests
    bubbleee030 authored May 19, 2026
    Configuration menu
    Copy the full SHA
    b6f504e View commit details
    Browse the repository at this point in the history
  5. Bump version to 1.7.0

    bubbleee030 committed May 19, 2026
    Configuration menu
    Copy the full SHA
    7b1d7f3 View commit details
    Browse the repository at this point in the history
Loading