fix(doctor): require --restart-sessions flag to cycle patrol sessions (gt-j44ri)
Previously `gt doctor --fix` would automatically kill and restart patrol sessions when fixing stale settings.json files. This was disruptive as it interrupted work without explicit consent. Now session cycling only happens when `--restart-sessions` is explicitly passed along with `--fix`. Without the flag, settings files are updated but running sessions are left alone. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ var (
|
|||||||
doctorFix bool
|
doctorFix bool
|
||||||
doctorVerbose bool
|
doctorVerbose bool
|
||||||
doctorRig string
|
doctorRig string
|
||||||
|
doctorRestartSessions bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var doctorCmd = &cobra.Command{
|
var doctorCmd = &cobra.Command{
|
||||||
@@ -82,6 +83,7 @@ func init() {
|
|||||||
doctorCmd.Flags().BoolVar(&doctorFix, "fix", false, "Attempt to automatically fix issues")
|
doctorCmd.Flags().BoolVar(&doctorFix, "fix", false, "Attempt to automatically fix issues")
|
||||||
doctorCmd.Flags().BoolVarP(&doctorVerbose, "verbose", "v", false, "Show detailed output")
|
doctorCmd.Flags().BoolVarP(&doctorVerbose, "verbose", "v", false, "Show detailed output")
|
||||||
doctorCmd.Flags().StringVar(&doctorRig, "rig", "", "Check specific rig only")
|
doctorCmd.Flags().StringVar(&doctorRig, "rig", "", "Check specific rig only")
|
||||||
|
doctorCmd.Flags().BoolVar(&doctorRestartSessions, "restart-sessions", false, "Restart patrol sessions when fixing stale settings (use with --fix)")
|
||||||
rootCmd.AddCommand(doctorCmd)
|
rootCmd.AddCommand(doctorCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +99,7 @@ func runDoctor(cmd *cobra.Command, args []string) error {
|
|||||||
TownRoot: townRoot,
|
TownRoot: townRoot,
|
||||||
RigName: doctorRig,
|
RigName: doctorRig,
|
||||||
Verbose: doctorVerbose,
|
Verbose: doctorVerbose,
|
||||||
|
RestartSessions: doctorRestartSessions,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create doctor and register checks
|
// Create doctor and register checks
|
||||||
|
|||||||
@@ -326,8 +326,10 @@ func (c *ClaudeSettingsCheck) Fix(ctx *CheckContext) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only cycle patrol roles that can auto-recover (daemon restarts them).
|
// Only cycle patrol roles if --restart-sessions was explicitly passed.
|
||||||
// Crew and polecats are spawned on-demand and won't auto-restart.
|
// This prevents unexpected session restarts during routine --fix operations.
|
||||||
|
// Crew and polecats are spawned on-demand and won't auto-restart anyway.
|
||||||
|
if ctx.RestartSessions {
|
||||||
if sf.agentType == "witness" || sf.agentType == "refinery" ||
|
if sf.agentType == "witness" || sf.agentType == "refinery" ||
|
||||||
sf.agentType == "deacon" || sf.agentType == "mayor" {
|
sf.agentType == "deacon" || sf.agentType == "mayor" {
|
||||||
running, _ := t.HasSession(sf.sessionName)
|
running, _ := t.HasSession(sf.sessionName)
|
||||||
@@ -337,6 +339,7 @@ func (c *ClaudeSettingsCheck) Fix(ctx *CheckContext) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(errors) > 0 {
|
if len(errors) > 0 {
|
||||||
return fmt.Errorf("%s", strings.Join(errors, "; "))
|
return fmt.Errorf("%s", strings.Join(errors, "; "))
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ type CheckContext struct {
|
|||||||
TownRoot string // Root directory of the Gas Town workspace
|
TownRoot string // Root directory of the Gas Town workspace
|
||||||
RigName string // Rig name (empty for town-level checks)
|
RigName string // Rig name (empty for town-level checks)
|
||||||
Verbose bool // Enable verbose output
|
Verbose bool // Enable verbose output
|
||||||
|
RestartSessions bool // Restart patrol sessions when fixing (requires explicit --restart-sessions flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RigPath returns the full path to the rig directory.
|
// RigPath returns the full path to the rig directory.
|
||||||
|
|||||||
Reference in New Issue
Block a user