Skip to catalogue

222

single instance

also single instance lock

The second launch focuses the window that is already open. It does not start another copy.

What is single instance?

A single-instance lock makes the second process exit and hand its arguments to the first: a file to open, a protocol URL, a deep link. Document apps and menu-bar apps need this. Two copies fight over the same files and the same port.

Why does single instance matter when vibe coding?

Generated apps ignore the second launch. The user double-clicks a file and gets a second window that does not know about the first, or a port collision on the local helper.

How do you do single instance?

Take the lock at startup. On the second instance, focus the existing window and forward argv. If the lock is lost, quit.

How do you ask a model for single instance?

Enforce a single instance. If the app is already running, focus it and deliver (file or URL) to that process. Do not open a second window or a second local server.

What goes wrong with single instance?

Taking the lock after the window opens. Two windows flash before one dies.

adjacent