@@ -2,6 +2,7 @@ package cmd
22
33import (
44 "fmt"
5+ "os"
56
67 "github.com/spf13/cobra"
78 "github.com/steveyegge/gastown/internal/beads"
@@ -18,6 +19,13 @@ import (
1819func runCrewAt (cmd * cobra.Command , args []string ) error {
1920 var name string
2021
22+ // Debug mode: --debug flag or GT_DEBUG env var
23+ debug := crewDebug || os .Getenv ("GT_DEBUG" ) != ""
24+ if debug {
25+ cwd , _ := os .Getwd ()
26+ fmt .Printf ("[DEBUG] runCrewAt: args=%v, crewRig=%q, cwd=%q\n " , args , crewRig , cwd )
27+ }
28+
2129 // Determine crew name: from arg, or auto-detect from cwd
2230 if len (args ) > 0 {
2331 name = args [0 ]
@@ -53,6 +61,10 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
5361 fmt .Printf ("Detected crew workspace: %s/%s\n " , detected .rigName , name )
5462 }
5563
64+ if debug {
65+ fmt .Printf ("[DEBUG] after detection: name=%q, crewRig=%q\n " , name , crewRig )
66+ }
67+
5668 crewMgr , r , err := getCrewManager (crewRig )
5769 if err != nil {
5870 return err
@@ -96,10 +108,16 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
96108 // Check if session exists
97109 t := tmux .NewTmux ()
98110 sessionID := crewSessionName (r .Name , name )
111+ if debug {
112+ fmt .Printf ("[DEBUG] sessionID=%q (r.Name=%q, name=%q)\n " , sessionID , r .Name , name )
113+ }
99114 hasSession , err := t .HasSession (sessionID )
100115 if err != nil {
101116 return fmt .Errorf ("checking session: %w" , err )
102117 }
118+ if debug {
119+ fmt .Printf ("[DEBUG] hasSession=%v\n " , hasSession )
120+ }
103121
104122 // Before creating a new session, check if there's already a runtime session
105123 // running in this crew's directory (might have been started manually or via
@@ -258,8 +276,12 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
258276 }
259277
260278 // If inside tmux (but different session), don't switch - just inform user
261- if tmux .IsInsideTmux () {
262- fmt .Printf ("Started %s/%s. Use C-b s to switch.\n " , r .Name , name )
279+ insideTmux := tmux .IsInsideTmux ()
280+ if debug {
281+ fmt .Printf ("[DEBUG] tmux.IsInsideTmux()=%v\n " , insideTmux )
282+ }
283+ if insideTmux {
284+ fmt .Printf ("Session %s ready. Use C-b s to switch.\n " , sessionID )
263285 return nil
264286 }
265287
@@ -269,6 +291,10 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
269291 return nil
270292 }
271293
272- // Attach to session
294+ // Attach to session - show which session we're attaching to
295+ fmt .Printf ("Attaching to %s...\n " , sessionID )
296+ if debug {
297+ fmt .Printf ("[DEBUG] calling attachToTmuxSession(%q)\n " , sessionID )
298+ }
273299 return attachToTmuxSession (sessionID )
274300}
0 commit comments