Fix witness session to start in witness directory
The witness session was starting in the rig root (e.g., /gt/gastown) instead of the witness directory (e.g., /gt/gastown/witness/rig). This caused gt prime to detect the Mayor role instead of Witness role. Now ensureWitnessSession uses the same pattern as ensureRefinerySession: 1. Try <rig>/witness/rig/ first (for rigs with worktree setup) 2. Fall back to <rig>/witness/ (for simpler setups) 3. Last resort: use rig root (shouldn't happen normally) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/gastown/internal/claude"
|
||||
@@ -294,13 +295,25 @@ func ensureWitnessSession(rigName string, r *rig.Rig) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// Working directory is the witness's rig clone (if it exists) or witness dir
|
||||
// This ensures gt prime detects the Witness role correctly
|
||||
witnessDir := filepath.Join(r.Path, "witness", "rig")
|
||||
if _, err := os.Stat(witnessDir); os.IsNotExist(err) {
|
||||
// Try witness/ without rig subdirectory
|
||||
witnessDir = filepath.Join(r.Path, "witness")
|
||||
if _, err := os.Stat(witnessDir); os.IsNotExist(err) {
|
||||
// Fall back to rig path (shouldn't happen in normal setup)
|
||||
witnessDir = r.Path
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure Claude settings exist (autonomous role needs mail in SessionStart)
|
||||
if err := claude.EnsureSettingsForRole(r.Path, "witness"); err != nil {
|
||||
if err := claude.EnsureSettingsForRole(witnessDir, "witness"); err != nil {
|
||||
return false, fmt.Errorf("ensuring Claude settings: %w", err)
|
||||
}
|
||||
|
||||
// Create new tmux session
|
||||
if err := t.NewSession(sessionName, r.Path); err != nil {
|
||||
if err := t.NewSession(sessionName, witnessDir); err != nil {
|
||||
return false, fmt.Errorf("creating session: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user