From bedccb1634e522f35832449af5c1dbdfdf225dee Mon Sep 17 00:00:00 2001 From: beads/crew/emma Date: Tue, 13 Jan 2026 13:27:14 -0800 Subject: [PATCH] fix(handoff): use workspace.FindFromCwd for town root detection detectTownRootFromCwd() only checked for mayor/town.json, but workspace.FindFromCwd() also accepts mayor/ directory as a secondary marker. This fixes handoff failing in workspaces without town.json. Co-Authored-By: Claude Opus 4.5 --- internal/cmd/handoff.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/internal/cmd/handoff.go b/internal/cmd/handoff.go index 99d1c24c..9a97c37e 100644 --- a/internal/cmd/handoff.go +++ b/internal/cmd/handoff.go @@ -479,27 +479,13 @@ func sessionToGTRole(sessionName string) string { // detectTownRootFromCwd walks up from the current directory to find the town root. func detectTownRootFromCwd() string { - cwd, err := os.Getwd() + // Use workspace.FindFromCwd which handles both primary (mayor/town.json) + // and secondary (mayor/ directory) markers + townRoot, err := workspace.FindFromCwd() if err != nil { return "" } - - dir := cwd - for { - // Check for primary marker (mayor/town.json) - markerPath := filepath.Join(dir, "mayor", "town.json") - if _, err := os.Stat(markerPath); err == nil { - return dir - } - - // Move up - parent := filepath.Dir(dir) - if parent == dir { - break - } - dir = parent - } - return "" + return townRoot } // handoffRemoteSession respawns a different session and optionally switches to it.