Skip to content

Should not start psmux new session when in a psmux session #55

@ErrorPower2001

Description

@ErrorPower2001

Summary

psmux currently allows users to start a new psmux session from within an active psmux session shell. This lack of nesting prevention leads to UI confusion.

Environment

OS: Windows 11 25H2 version 26200.7922

Terminal: Windows Terminal / Alacritty / Wezterm

Shell: PowerShell 7.5.4 / msys2 bash / nushell / busybox ash

psmux: release 0.4.5 install by scoop

What I expected

psmux should detect if it is already running in the current shell environment. If an active session is detected, it should prevent the launch of a nested session by default or provide a warning to the user.

What happened

Running the psmux command inside an existing session successfully spawns a new instance within the current window. Then that session cannot use shortcut, session program cannot exit.

Image

Reproduction

  1. Open a Windows terminal.
  2. Start psmux: psmux
  3. Inside the psmux session, run psmux again. Note that a second session starts inside the first one.

Suggested Fix (Reference to tmux)

A proven solution, as seen in tmux, is to export a unique environment variable $TMUX upon session initialization.

The logic would be:

  1. When psmux starts, it checks for the existence of an environment variable like PSMUX.
  2. If the variable exists, the application exits with an error message: sessions should not be nested.
  3. If it does not exist, the application sets $PSMUX and proceeds to launch.

Impact

  • Usability: Conflicting keybindings between nested layers.
  • UI: Overlapping status bars or screen corruption.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions