Skip to content

feat(sessions): add an option to close tabs when a session ends - #35

Merged
WolffTech merged 1 commit into
mainfrom
t3code/close-tab-on-session-end
Sep 30, 2026
Merged

WolffTech merged 1 commit into
mainfrom
t3code/close-tab-on-session-end

Conversation

@WolffTech

Copy link
Copy Markdown
Owner

When a remote session ended from the remote side, for example typing exit over SSH, the tab always stayed open with a "Session disconnected" banner and a Reconnect button. Sometimes you just want the tab gone.

Settings → General → Sessions now has a "When a remote session ends" option:

  • Keep the tab open (default): same as before.
  • Close the tab: the tab closes as soon as the session ends cleanly.

"Ends cleanly" means SSH exited with status 0, or an RDP/VNC session was ended by the remote side without an error, such as signing out of Windows. These cases always keep the tab, so you can still read the error or reconnect:

  • failed sessions (a non-zero exit, an authentication failure, a remote desktop error)
  • sessions you end yourself with Disconnect
  • local terminals, which aren't remote sessions

The tab closes a moment after the session ends rather than inside the terminal's exit callback. Freeing the SSH terminal surface from within its own callback could crash the app. If you reconnect or close the tab in that moment, the automatic close is skipped.

Testing

  • The app test target passes (122 tests). New tests cover: the default keeps the tab; a clean SSH exit closes it; a failed exit keeps it; a remote desktop sign-out closes its tab while a user Disconnect keeps its tab; reconnecting before the deferred close keeps the tab.
  • Tried it in a Debug build against a throwaway local sshd, using a scratch library and a separate bundle ID:
    • Default setting + exit: the tab stays with the Reconnect banner.
    • Switched to "Close the tab" in Settings + exit: the tab closes and the app keeps running.
    • "Close the tab" + exit 3: the tab stays, showing "SSH exited with status 3."
  • Not tested in the app: RDP/VNC sign-out. The unit tests cover it.

- Add a General setting to close the tab when a remote session ends
  cleanly, such as exit over SSH or signing out of a desktop
- Keep the current Reconnect banner as the default
- Keep tabs for failed sessions and user-requested disconnects
- Defer the close so SSH surfaces aren't freed in their exit callback
@WolffTech
WolffTech merged commit a1c2e68 into main Sep 30, 2026
2 checks passed
@WolffTech
WolffTech deleted the t3code/close-tab-on-session-end branch November 10, 2026 20:20
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