From b6f2281f1358e58228458e7254439fa6d305dd62 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Wed, 17 Dec 2025 15:50:18 -0800 Subject: [PATCH] feat: add gt mayor restart command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complete the mayor command set for GGT cutover. Now have: start, stop, attach, status, restart. Skipped wake-queue as it's part of the pooling model being deprecated in favor of ephemeral polecats (gt-7ik). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/mayor.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/internal/cmd/mayor.go b/internal/cmd/mayor.go index 8d26538e..bf85f9df 100644 --- a/internal/cmd/mayor.go +++ b/internal/cmd/mayor.go @@ -62,11 +62,21 @@ var mayorStatusCmd = &cobra.Command{ RunE: runMayorStatus, } +var mayorRestartCmd = &cobra.Command{ + Use: "restart", + Short: "Restart the Mayor session", + Long: `Restart the Mayor tmux session. + +Stops the current session (if running) and starts a fresh one.`, + RunE: runMayorRestart, +} + func init() { mayorCmd.AddCommand(mayorStartCmd) mayorCmd.AddCommand(mayorStopCmd) mayorCmd.AddCommand(mayorAttachCmd) mayorCmd.AddCommand(mayorStatusCmd) + mayorCmd.AddCommand(mayorRestartCmd) rootCmd.AddCommand(mayorCmd) } @@ -208,3 +218,25 @@ func runMayorStatus(cmd *cobra.Command, args []string) error { return nil } + +func runMayorRestart(cmd *cobra.Command, args []string) error { + t := tmux.NewTmux() + + // Stop if running + running, err := t.HasSession(MayorSessionName) + if err != nil { + return fmt.Errorf("checking session: %w", err) + } + if running { + fmt.Println("Stopping Mayor session...") + t.SendKeysRaw(MayorSessionName, "C-c") + time.Sleep(100 * time.Millisecond) + if err := t.KillSession(MayorSessionName); err != nil { + return fmt.Errorf("killing session: %w", err) + } + fmt.Printf("%s Mayor session stopped.\n", style.Bold.Render("✓")) + } + + // Start fresh + return runMayorStart(cmd, args) +}