#18

Single-instance apps and reopen handling

Open1byeopened 6d ago

Problem

On Windows and Linux, opening a file or a custom URL while the app is running starts a second copy. The running app never sees it. Rake already has a URL activation inbox, but only the instance that receives the URL can use it. On macOS, clicking the dock icon with no windows open (reopen) has no Rake hook.

Proposal

  • An opt-in single-instance policy on App. A second launch checks for a running instance of the same app and user, sends it its arguments, URLs and files, and exits.
  • The running instance receives them through the existing receive_open_url inbox.
  • Use the gpui-pre on_reopen callback so apps can open a window when the user reopens with none showing.
  • Use a channel only the current user can access, similar to the existing development control transport.

Out of scope

  • Web, where each tab is its own instance.
  • Several deliberately separate instances, such as profiles. Allow it through a per-instance key if needed later.

Done when

  • On Windows and Linux, opening a file or URL while the app runs reaches the running instance, and no second window appears.
  • On macOS, reopen calls the app's callback.
  • Tests cover a stale lock from a crashed instance and two launches at once.

Depends on

The move from GPUI CE to gpui-pre, for on_reopen.

Activity

0

No activity yet.