Skip to content

switch-client is non-functional (returns exit 0 but never switches) #202

@tarikguney

Description

@tarikguney

Summary

switch-client is registered in list-commands and accepts all standard tmux flags (-t, -c, -n, -p, -l), but it never actually switches the client session. It always returns exit code 0 silently.

This was discovered while building claude-watch, a TUI dashboard that monitors Claude Code sessions across psmux windows and needs to programmatically navigate to a specific session/window.

Environment

  • psmux version: 3.3.2 (installed via WinGet)
  • OS: Windows 11 (10.0.26200)
  • Terminal: Windows Terminal
  • Shell: PowerShell 7+

Steps to Reproduce

# Start psmux with two sessions
psmux new-session -d -s alpha
psmux new-session -s beta

# From within the 'beta' session, try to switch to 'alpha'
psmux switch-client -t "alpha"

# Verify: client is still on 'beta'
psmux list-clients
# Output: /dev/pts/XXXXX: beta: ... (unchanged)

Detailed Testing

All of these return exit code 0 but have no observable effect (verified via list-clients before/after each):

Command Result
psmux switch-client -t session No-op
psmux switch-client -t session:window No-op
psmux switch-client -c /dev/pts/XXXXX -t session No-op
psmux -S /tmp/psmux-XXXXX/default switch-client -t session No-op
psmux run-shell "psmux switch-client -t session" No-op
bind-key -n F5 switch-client -t session + manual F5 press No-op

Additionally:

  • select-window -t other_session:window (cross-session) has no effect
  • attach-session -t session from within psmux only prints the version string (psmux 3.3.2) and exits without attaching (with or without -d, with or without $TMUX env set)
  • choose-session and choose-tree from CLI show no visible overlay

What DOES Work

The keyboard prefix path works perfectly: Ctrl+B, s (prefix + choose-session) opens the interactive session picker and switching works. This means the server-side session switching logic is implemented and functional — the issue is that switch-client (and related CLI commands) never reach or trigger that logic.

Expected Behavior

switch-client -t <target> should switch the current client (identified via $TMUX environment variable) to display the target session, matching tmux behavior.

Context

This appears related to the pattern described in #95, where several commands were registered in list-commands but non-functional. The audit in #95 did not cover switch-client, attach-session (from within psmux), or the CLI path for choose-session/choose-tree.

The scripting commands (send-keys, run-shell, list-panes, display-message -p, etc.) all work correctly. The issue is specifically with client/session navigation commands.

Impact

Without a working switch-client, there is no programmatic way to navigate between sessions. This blocks tools that want to provide session navigation (like tmux-sessionizer, fzf-based session switchers, or monitoring dashboards like claude-watch).

Workaround Attempts

  • Interactive choose-session overlay works via prefix keybinding but cannot be triggered programmatically from CLI or from within a TUI application.
  • Keybinding a key to switch-client -t target and pressing it manually does not work.
  • send-keys to trigger prefix + keybinding does not work (sends to pane PTY, not psmux input handler).

Thank you for building psmux — the scripting foundation is excellent and this is the last piece needed for full programmatic session control.

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