Skip to content

Remove Helper Apps (Menu Helper, Login Helper) #844

Open

Description

@jakob

Currently, Postgres.app has two helper apps:

  • Login Helper (starts PostgreSQL servers on login, and the menu helper)
  • Menu Helper (shows the menu bar icon)

The main reason for the helpers is that we don't want to show any user interface on login (dock icon, app window) but still launch servers.

However, I've realised that we could maybe do away with the helpers alltogether by dynamically changing the "activation policy" using NSApp.setActivationPolicy(.regular) and NSApp.setActivationPolicy(.accessory) to show/hide the dock icon.

Then instead of a helper app, we could just launch the main app on login.

  • if the app is opened as a login item, we call .setActivationPolicy(.accessory)
  • if the app is opened normally (eg. double clicking in Finder) we call .setActivationPolicy(.regular)
  • if the main window is closed we call .setActivationPolicy(.accessory)
  • when the app is terminated (eg. using the "quit" command or when the user logs out) we stop all servers and quit the app

Behavior would be similar to how it is now, but we would only have a single app and no helpers.

Advantages:

Activity

  1. jakob commented on May 5, 2026

    @jakob
    MemberAuthor

    Technical notes:

    On macOS 13 and later we could do the following:

    • check if Postgres.app is registered as a login item with SMAppService.mainApp.status: the result can be enabled if it is registered as a login item, and notFound if it is not.
    • we can add/remove the login item with register() and unregister() methods
    • if the user removes the login item, we can just add it again, but we don't want to add it if the user removed it. We should probably store the setting in user defaults, or automatically add it only once and don't re-add it if the user manually removed it

    We can use the LSSharedFileListSessionLoginItems API to do exactly the same thing on macOS 11 and macOS 12. These APIs are officially deprecated since 10.11, but they still work on macOS 26. Calling the deprecated API from Swift is not easy, so I will probably just write a simple Objective C helper class.

  2. jakob commented on May 6, 2026

    @jakob
    MemberAuthor

    Here are some drawbacks / advantages of using SMAppService.mainApp vs SMAppService.loginItem()

    SMAppService.mainApp

    • appears at the top in a section named "open at login"
    • user can not prevent apps from registering login items, so app needs a toggle in app settings to disable launch at login
    • launches main app
    • seems 100% compatible with LSSharedFileList API (which is officially deprecated since macOS 10.11 but still works on macOS 26)

    SMAppService.loginItem

    • appears in a section named "background activities"
    • includes a toggle to disable an item. once a user disables item, app can not enable it any more
    • launches a separate helper app from inside main app bundle

    Upgrade considerations

    • if we switch from .loginItem to .mainApp macOS will show a notification (something like "Postgres installed a login item")
    • if user disabled the login item we should not add it again
    • we could keep the LoginHelper and just have it launch the main app (in background)
  3. jakob commented on May 6, 2026

    @jakob
    MemberAuthor
    Image
  4. jakob commented on May 7, 2026

    @jakob
    MemberAuthor

    Todo:

    • show warning when user quits ("Do you want to quit
    • hide app when last window closes, switch to accessory mode after resign active (avoids reshuffling of next app windows)
    • workaround for monterey activation bug
  5. jakob commented on May 20, 2026

    @jakob
    MemberAuthor

    I implemented a dialog in 469f77d

    Image

    The dialog is shown only when using Cmd-Q (or selecting "Quit" from the "Postgres" menu). There is no confirmation when selecting "Quit" from the menu bar icon. This is what I would personally expect, and it is also similar to the existing behavior.

    Suggestions for better text in the alert are welcome :)

  6. jakob commented on Jun 16, 2026

    @jakob
    MemberAuthor

    I did some testing on the macOS 27 beta. Apple improved the background activities toggle so that it also applies to login item. Adding a login item automatically enables the background activities setting.

    So I think maybe we should just use .loginItem? Using .mainApp is confusing, since that effectively just adds another way for users to disable background activities (remove from login items, turn off the background activities toggle, or disable in Postgres.app preferences).

  7. jakob commented on Jun 25, 2026

    @jakob
    MemberAuthor

    Here's a summary of behavior differences regarding .loginItem vs .mainApp (on macOS 27):

    .loginItem

    • shows "background activity" toggle
    • when you enable "background activity" the login item is launched immediately
    • 2 ways to disable: deactivate background activity in system settings or deactivate "launch at login" in Postgres.app settings

    .mainApp

    • adds app to "login items"
    • shows "background activity" toggle. when disabled, the app is not launched even though it appears in login items above
    • when you enable "background activity", the app is launched at next login
    • 3 ways to disable: deactivate background activity in system settings, remove login item in system settings, or decativate "launch at login" in Postgres.app settings

    If you want to test the differences:

    • 3alpha4 uses .mainApp
    • 3alpha5 uses .loginItem

    I think I slighly prefer .loginItem, but I am not sure.

  8. dchacke commented on Oct 13, 2026

    @dchacke

    A data point for this from macOS 27.0.1 (26A434), with Postgres.app 2.9.6 and PostgreSQL 16.15:

    On macOS 27, quitting Postgres.app already stops any server the app started, even though 2.9.6 doesn't do that itself. About a second after the app exits, loginwindow sends the server SIGTERM:

    08:32:52.781 Postgres: (AppKit) [com.apple.AppKit:Application] terminate:
    08:32:52.803 launchd: [gui/501/application.com.postgresapp.Postgres2…] exited due to exit(0)
    08:32:53.899 loginwindow: (libquit.dylib) force quit (caller responsible for termination)
    08:32:53.905 loginwindow: (libLaunchServicesSupport.dylib) quitOrKillSubordinateProcesses: Failed to quit or kill application "Postgres", error=-600 procNotFound
    08:32:53.910 postgres: LOG:  received smart shutdown request
    

    It isn't specific to Postgres.app. Quitting Terminal also stops a gpg-agent that was started from Terminal, and another project reported the same thing: nexu-io/open-design#8276

    So on macOS 27, any server the app starts appears to be tied to the app: it stops when the app quits, whatever 3.0 decides. If users should be able to keep servers running without the app, the servers would probably need to be started by launchd (for example, a LaunchAgent or SMAppService.agent) rather than by the app. As a workaround, I now run the server from my own LaunchAgent (postgres -D <data dir>), and it survives quitting the app.


    Drafted with Claude (Anthropic's AI assistant) from my own logs and testing.

  9. jakob commented on Nov 4, 2026

    @jakob
    MemberAuthor

    @dchacke Did you disable App Background Activities for Postgres.app (in System Settings -> General -> Login Items & Extensions)?

    If you disable app background activities, then macOS 27 kills postgres processes started by Postgres.app 2.x after you quit the app. (However, when the server is started from the menu item it is not killed -- it is rather confusing)

    So if you are using Postgres.app 2.x on macOS 27, please don't turn off app background activities.

    Postgres.app 3.0 does not have this limitation, it should work with app background activities turned off as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions