Skip to content

hubfly ssh should let users exit the local SSH session without terminating the container shell #4

Description

@bonheur15

Problem

hubfly ssh currently behaves like a raw terminal passthrough.

When a user types exit, that exits the shell running inside the container. What we also need is a way to leave the local hubfly ssh session itself and get back to the user's normal terminal workflow without treating that as a command to the container shell.

This matters because users may want to disconnect from the CLI session while leaving the container process state alone, or simply recover from an attached session without sending shell-exit semantics into the container.

Requested behavior

Add a local detach/exit mechanism for interactive hubfly ssh sessions.

Desired outcome:

  • User can leave the hubfly ssh session and return to their local shell.
  • This action should close the local websocket/terminal session.
  • It should not send exit to the container shell.
  • It should not require terminating the container or changing container state.

Example UX

A local escape sequence is the safest direction, for example:

  • Ctrl+]
  • or ~. style handling similar to OpenSSH
  • or another explicit local-only detach shortcut

Typing plain exit should remain container-shell behavior.

Suggested implementation direction

The likely fix is in the CLI terminal client path:

  • Detect a local escape sequence inside pumpStdin() / interactive terminal handling.
  • When that sequence is seen:
    • stop forwarding further input to the container,
    • close the websocket cleanly,
    • restore the local terminal state,
    • return control to the local shell,
    • avoid injecting exit, Ctrl-D, or other shell-closing bytes into the remote container.

Potential files involved:

  • internal/cli/shell.go

A reasonable approach is:

  1. reserve a local-only escape sequence,
  2. parse it before sending stdin bytes upstream,
  3. trigger local shutdown from the CLI side,
  4. keep remote shell semantics unchanged for ordinary input like exit.

Notes

A non-interactive path already exists via:

hubfly ssh <container> -- <cmd>

This issue is specifically about the interactive attached shell mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions