Skip to content

feat: scope desktop instance locks by key - #339

Merged
houko merged 1 commit into
mainfrom
feat/instance-key
Nov 17, 2026
Merged

houko merged 1 commit into
mainfrom
feat/instance-key

Conversation

@houko

@houko houko commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Windows and Linux previously forced all launches with the same app ID into one process, preventing isolated profiles or test runs. nsgo.InstanceKey(key) now scopes both the lock and its handoff socket/pipe: different keys run independently, and launches with the same key still deliver their files (and, on Windows, a Jump List task) to the matching owner. An empty key preserves the existing lock names and behavior; other targets ignore the option. docs/architecture/application.md §Lifecycle and the roadmap's one-instance row describe the option.

Regression tests keep the default instance and two keyed instances alive together, then verify file delivery to each owner; a Linux test pins the default socket path to the pre-existing name. The Test workflow's Windows job now also runs the Windows instance tests (Linux's already run in its full suite).

Validation:

  • go build ./...; GOOS=windows (amd64, 386, arm64), linux, android/arm64 and js/wasm builds or vets of the touched packages; go tool nsgo check -target all; go tool nsgo test of ./internal/platform/linux instance tests, ./internal/backend and -run 'Layer|Skills|Doc' ..
  • Windows 11, native: TestInstanceHandsOffByKey passed three times in a row.
  • End to end on Windows 11 and Ubuntu 24.04 GNOME with a probe app (nsgo.Run with nsgo.InstanceKey(os.Getenv(...))): owners with keys "", "a" and "b" ran side by side; a second launch per key exited and its owner, and only its owner, heard OnReopen and OnOpenFiles with that launch's file.

Closes #332.

@github-actions github-actions Bot added size/M enhancement New feature or request documentation Improvements or additions to documentation Windows Linux ci conflict Conflicts with the base branch; resolve it first labels Nov 16, 2026
@houko
houko force-pushed the feat/instance-key branch from f494bf1 to b50893b Compare November 16, 2026 00:48
@github-actions github-actions Bot removed the conflict Conflicts with the base branch; resolve it first label Nov 16, 2026
@github-actions github-actions Bot added the conflict Conflicts with the base branch; resolve it first label Nov 16, 2026
@houko
houko force-pushed the feat/instance-key branch from b50893b to 46c439c Compare November 17, 2026 04:02
@github-actions github-actions Bot removed the conflict Conflicts with the base branch; resolve it first label Nov 17, 2026
@houko
houko force-pushed the feat/instance-key branch from 46c439c to 11255a2 Compare November 17, 2026 04:08
@github-actions github-actions Bot added the conflict Conflicts with the base branch; resolve it first label Nov 17, 2026
@houko
houko force-pushed the feat/instance-key branch from 11255a2 to 7bc7672 Compare November 17, 2026 04:12
@houko

houko commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed. The diff against main scopes the Windows mutex/pipe and the Linux socket/lock by hashing id + "\x00" + key only when the key is non-empty, so the default names are unchanged; nsgo.InstanceKey reaches both platforms through backend.Options, and the Windows claim still forwards Jump List task arguments. No CHANGELOG change, no hard-wrapped lines, docs (application.md §Lifecycle, roadmap row) match the behaviour, and all three Acceptance items of #332 are covered.

Checks on this head (rebased onto current main; the only conflict was the Windows CI job, resolved by keeping main's new focus steps and appending the instance step):

  • Ubuntu build host: go build ./...; vets for GOOS=windows/amd64 and linux of the touched packages; builds for windows/386, windows/arm64, android/arm64 and js/wasm; go tool nsgo test for the Linux instance tests (6 passed, real Unix sockets), ./internal/backend (8 passed) and -run 'Layer|Skills|Doc' . (35 passed).
  • Negative check: with the key ignored in instancePath, TestInstanceKeySeparatesOwners fails (key "one" is handed to the default owner instead of starting its own), while the default-path compatibility test still passes.
  • Windows 11, native test binary: TestInstanceHandsOffByKey passed with -count=3 (real named mutexes and pipes, three owners side by side, each same-key launch delivered its file to its own owner).

@houko
houko marked this pull request as ready for review November 17, 2026 04:12
@houko
houko merged commit 17c8c69 into main Nov 17, 2026
11 of 14 checks passed
@houko
houko deleted the feat/instance-key branch November 17, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci conflict Conflicts with the base branch; resolve it first documentation Improvements or additions to documentation enhancement New feature or request Linux size/M Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

One instance: no way to run a deliberate second copy, or scope the lock, on Windows and Linux

1 participant