From 83ddef4f88ecd3a4098cb27306673138c6a146c4 Mon Sep 17 00:00:00 2001 From: mayor Date: Thu, 22 Jan 2026 21:27:26 -0800 Subject: [PATCH] fix(rig): dock/undock require main branch to prevent silent failures Docking on non-main branches silently fails because rig identity beads live on main. The dock appeared to work but was lost on checkout to main. Now dock/undock check current branch and error with helpful message: "cannot dock: must be on main branch (currently on X)" Fixes hq-kc7 Co-Authored-By: Claude Opus 4.5 --- internal/cmd/rig_dock.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/internal/cmd/rig_dock.go b/internal/cmd/rig_dock.go index a0fd4f06..a4cc6df9 100644 --- a/internal/cmd/rig_dock.go +++ b/internal/cmd/rig_dock.go @@ -66,6 +66,18 @@ func init() { func runRigDock(cmd *cobra.Command, args []string) error { rigName := args[0] + // Check we're on main branch - docking on other branches won't persist + branchCmd := exec.Command("git", "branch", "--show-current") + branchOutput, err := branchCmd.Output() + if err == nil { + currentBranch := string(branchOutput) + currentBranch = currentBranch[:len(currentBranch)-1] // trim newline + if currentBranch != "main" && currentBranch != "master" { + return fmt.Errorf("cannot dock: must be on main branch (currently on %s)\n"+ + "Docking on other branches won't persist. Run: git checkout main", currentBranch) + } + } + // Get rig _, r, err := getRig(rigName) if err != nil { @@ -166,6 +178,18 @@ func runRigDock(cmd *cobra.Command, args []string) error { func runRigUndock(cmd *cobra.Command, args []string) error { rigName := args[0] + // Check we're on main branch - undocking on other branches won't persist + branchCmd := exec.Command("git", "branch", "--show-current") + branchOutput, err := branchCmd.Output() + if err == nil { + currentBranch := string(branchOutput) + currentBranch = currentBranch[:len(currentBranch)-1] // trim newline + if currentBranch != "main" && currentBranch != "master" { + return fmt.Errorf("cannot undock: must be on main branch (currently on %s)\n"+ + "Undocking on other branches won't persist. Run: git checkout main", currentBranch) + } + } + // Get rig and town root _, r, err := getRig(rigName) if err != nil {