Skip to content

tmux session detection only works on the default socket — custom -L/-S sockets and TMUX_TMPDIR are not detected (diff viewer greyed out) #6

Description

@bedfordsean

(Filing here as moshi-hooks is archived and homebrew-moshi has issues disabled — happy to move this wherever you prefer.)

Environment: moshi-hook 0.2.63 (brew), macOS 15 (arm64), iOS app with Pro, mosh + SSH sessions.

Summary

Remote tmux session detection (moshi-hook context --ssh-connection/--mosh-port) only detects tmux when the server runs on the literal default socket /tmp/tmux-<uid>/default. Two common setups break it:

  1. Custom socket (tmux -L name or tmux -S /path/sock)
  2. TMUX_TMPDIR relocation (still default-socket semantics, different directory — a common macOS setup because /private/tmp gets periodically cleaned)

In both cases context falls back to the login shell:

$ moshi-hook context --mosh-port 60001   # session IS attached to tmux (custom socket)
{
  "kind": "shell",
  "cwd": "/Users/sean"
}

Consequence: the diff viewer button stays greyed out for any tmux user with a non-stock socket (cwd resolves to the login shell's ~, which isn't a git repo), while plain no-tmux shells work fine. Everything else (pairing, tmux picker, gateway) works with custom sockets, so the greyed diff button looks like a client bug rather than a socket-path issue — took a while to pin down.

Migrating our servers to the true default socket fixed detection completely, confirming by elimination.

Suggested fixes (any one would do)

  • Resolve the socket from the attached tmux client process argv (-S/-L are visible under the session's process tree), or from $TMUX of any pane process
  • Honor TMUX_TMPDIR when probing the default socket
  • Or an env override on the daemon, e.g. MOSHI_TMUX_SOCKET, analogous to the existing MOSHI_HERDR_PATH

Related packaging note

The brew service plist ships no PATH in EnvironmentVariables, so the daemon runs with the bare system PATH — on a stock homebrew-tmux Mac the daemon itself can't find tmux for its gateway/capture spawns until the user hand-patches the plist (which brew services restart reverts). Consider baking a sane PATH into the formula's service block.

Happy to test builds — the app is excellent, this was the one rough edge.

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