From 2fb787c7a21b49e039bc5210c28708a1fe57d9bd Mon Sep 17 00:00:00 2001 From: Julian Knutsen Date: Sat, 24 Jan 2026 19:46:05 -1000 Subject: [PATCH] fix(rig): remove route from routes.jsonl on rig remove (#910) When a rig is removed with `gt rig remove`, the route entry in routes.jsonl was not being cleaned up. This caused problems when re-adding the rig with a different prefix, resulting in duplicate entries and prefix mismatch errors. The fix calls beads.RemoveRoute() during rig removal to clean up the route entry from routes.jsonl. Fixes #899 Co-authored-by: dementus Co-authored-by: Claude Opus 4.5 --- internal/cmd/rig.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/cmd/rig.go b/internal/cmd/rig.go index c3127d08..355f842f 100644 --- a/internal/cmd/rig.go +++ b/internal/cmd/rig.go @@ -505,6 +505,12 @@ func runRigRemove(cmd *cobra.Command, args []string) error { return fmt.Errorf("loading rigs config: %w", err) } + // Get the rig's beads prefix before removing (needed for route cleanup) + var beadsPrefix string + if entry, ok := rigsConfig.Rigs[name]; ok && entry.BeadsConfig != nil { + beadsPrefix = entry.BeadsConfig.Prefix + } + // Create rig manager g := git.NewGit(townRoot) mgr := rig.NewManager(townRoot, rigsConfig, g) @@ -518,6 +524,14 @@ func runRigRemove(cmd *cobra.Command, args []string) error { return fmt.Errorf("saving rigs config: %w", err) } + // Remove route from routes.jsonl (issue #899) + if beadsPrefix != "" { + if err := beads.RemoveRoute(townRoot, beadsPrefix+"-"); err != nil { + // Non-fatal: log warning but continue + fmt.Printf(" %s Could not remove route from routes.jsonl: %v\n", style.Warning.Render("!"), err) + } + } + fmt.Printf("%s Rig %s removed from registry\n", style.Success.Render("✓"), name) fmt.Printf("\nNote: Files at %s were NOT deleted.\n", filepath.Join(townRoot, name)) fmt.Printf("To delete: %s\n", style.Dim.Render(fmt.Sprintf("rm -rf %s", filepath.Join(townRoot, name))))