package session import ( "github.com/warrenronsiek/ctask/internal/shell" ) // attacher is the test seam used by AttachExisting. Production code calls // shell.AttachSession directly; tests override this variable to capture // invocations or simulate failures. Do not run tests that override this // variable in parallel — it is a package global. var attacher = shell.AttachSession // AttachExisting is the passive-reattach path. It is invoked when a tmux // session for the workspace already exists and the lease is fresh and local // (the original ctask owner is alive and heartbeating). // // AttachExisting performs no Preflight, writes no lease, captures no // manifest, starts no heartbeat, prints no banner, and runs no finalize. // It connects the user's terminal to the existing tmux session via // shell.AttachSession and returns when the user detaches or the session // ends. shell.AttachSession's contract handles failure-mode classification: // nil on clean exit, wrapped error on non-zero exit. // // If the session disappeared between the dispatcher's HasSession check // and this call, AttachSession returns an error and the user can retry — // the next invocation will hit the owner-create path. func AttachExisting(tmuxPath, name string) error { return attacher(tmuxPath, name) }