Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions internal/cmd/helpers_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ func attachToTmuxSession(sessionID string) error {
cmd.Stderr = os.Stderr

if err := cmd.Run(); err != nil {
// psmux on Windows can successfully list sessions but still fail
// attach-session with "can't find session" even when the session exists.
// Fall back to a plain attach invocation, which targets the most recent
// session and works reliably for the single-session attach workflow.
if !isInSameTmuxSocket() {
fallbackArgs := []string{"-u"}
if socket := tmux.GetDefaultSocket(); socket != "" {
fallbackArgs = append(fallbackArgs, "-L", socket)
}
fallbackArgs = append(fallbackArgs, "attach")
fallback := exec.Command(tmuxPath, fallbackArgs...)
fallback.Stdin = os.Stdin
fallback.Stdout = os.Stdout
fallback.Stderr = os.Stderr
if fallbackErr := fallback.Run(); fallbackErr == nil {
os.Exit(0)
}
}
if exitErr, ok := err.(*exec.ExitError); ok {
os.Exit(exitErr.ExitCode())
}
Expand Down