Skip to content

Keep Necto running when the last window is closed - #43

Merged
heoblitz merged 1 commit into
mainfrom
feature/hide-last-window-on-close
Nov 16, 2026
Merged

heoblitz merged 1 commit into
mainfrom
feature/hide-last-window-on-close

Conversation

@heoblitz

Copy link
Copy Markdown
Collaborator

Summary

Closing Necto's last window quit the app. That also closed the control socket, so necto-cli, and any agent driving Necto through it, failed until someone opened the app again.

The last window now hides instead of closing:

  • The app keeps running, so the CLI and connected apps stay reachable.
  • The Dock icon brings back the same window, with its selection and panels as they were.
  • A window that is not the last one still closes. So does a full screen window, because ordering one out leaves its empty Space behind.
  • Command-Q quits as before.
  • An install or shell approval prompt that arrives while the window is hidden brings it back.

SwiftUI has no way to hide a WindowGroup window on close, and it owns the window's delegate. NectoCloseInterceptor stands in front of that delegate, answers windowShouldClose and forwards everything else.

Changelog

Closing the last window no longer quits Necto. The window hides, the CLI keeps working, and the Dock icon brings the window back.

Test Plan

  • xcodebuild -project Necto.xcodeproj -scheme Necto -configuration Debug -destination 'platform=macOS' build: ** BUILD SUCCEEDED **
  • script/test native: ** TEST SUCCEEDED **, all tests passed
  • Manually, in a Debug build: closed the last window, then clicked the Dock icon. The same window returned with its selection and panel intact. Command-N still opens a second window.

Not verified:

  • necto-cli calls while the window is hidden
  • Command-Q while the window is hidden
  • Closing a full screen window
  • An install or shell approval prompt arriving while the window is hidden

No screenshots: nothing changes visually.

Closing the last window quit the app, which also closed the control
socket, so necto-cli had nothing to talk to until the app was opened
again.

The last window now hides instead of closing. The app keeps serving the
CLI and connected apps, and the Dock icon brings back the same window
with its selection and panels intact. Other windows still close, and
Command-Q still quits.

SwiftUI owns the window's delegate, so a forwarding delegate answers
only the close question and passes everything else on.
@heoblitz
heoblitz merged commit 7263df8 into main Nov 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant