fix(crew): exec claude when already in target session
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -557,8 +558,9 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
// Check if we're already in the target session
|
// Check if we're already in the target session
|
||||||
if isInTmuxSession(sessionID) {
|
if isInTmuxSession(sessionID) {
|
||||||
fmt.Printf("Already in session %s\n", sessionID)
|
// We're in the session at a shell prompt - just start Claude directly
|
||||||
return nil
|
fmt.Printf("Starting Claude in current session...\n")
|
||||||
|
return execClaude()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach to session using exec to properly forward TTY
|
// Attach to session using exec to properly forward TTY
|
||||||
@@ -576,6 +578,19 @@ func isShellCommand(cmd string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// execClaude execs claude, replacing the current process.
|
||||||
|
// Used when we're already in the target session and just need to start Claude.
|
||||||
|
func execClaude() error {
|
||||||
|
claudePath, err := exec.LookPath("claude")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("claude not found: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// exec replaces current process with claude
|
||||||
|
args := []string{"claude", "--dangerously-skip-permissions"}
|
||||||
|
return syscall.Exec(claudePath, args, os.Environ())
|
||||||
|
}
|
||||||
|
|
||||||
// isInTmuxSession checks if we're currently inside the target tmux session.
|
// isInTmuxSession checks if we're currently inside the target tmux session.
|
||||||
func isInTmuxSession(targetSession string) bool {
|
func isInTmuxSession(targetSession string) bool {
|
||||||
// TMUX env var format: /tmp/tmux-501/default,12345,0
|
// TMUX env var format: /tmp/tmux-501/default,12345,0
|
||||||
|
|||||||
Reference in New Issue
Block a user