From f3f83722e5e5c97a73307b6454bd1de709dc281e Mon Sep 17 00:00:00 2001 From: propane Date: Fri, 23 Jan 2026 15:40:49 -0800 Subject: [PATCH] fix(statusline): ensure crew sessions have correct hook display Root cause: tmux statusline showed wrong hook for all java crewmembers because GT_CREW env var wasn't set in tmux session environment. Changes: - statusline.go: Add early return in getHookedWork() when identity is empty to prevent returning ALL hooked beads regardless of assignee - crew_at.go: Call SetEnvironment in the restart path so sessions created before GT_CREW was being set get it on restart Fixes gt-zxnr. Co-Authored-By: Claude Opus 4.5 --- internal/cmd/crew_at.go | 16 +++++++++++++++- internal/cmd/statusline.go | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/internal/cmd/crew_at.go b/internal/cmd/crew_at.go index d8a6918d..c5241abf 100644 --- a/internal/cmd/crew_at.go +++ b/internal/cmd/crew_at.go @@ -250,8 +250,22 @@ func runCrewAt(cmd *cobra.Command, args []string) error { Topic: "restart", }) + // Ensure tmux session environment is set (for gt status-line to read). + // Sessions created before this was added may be missing GT_CREW, etc. + envVars := config.AgentEnv(config.AgentEnvConfig{ + Role: "crew", + Rig: r.Name, + AgentName: name, + TownRoot: townRoot, + RuntimeConfigDir: claudeConfigDir, + BeadsNoDaemon: true, + }) + for k, v := range envVars { + _ = t.SetEnvironment(sessionID, k, v) + } + // Use respawn-pane to replace shell with runtime directly - // Export GT_ROLE and BD_ACTOR since tmux SetEnvironment only affects new panes + // Export GT_ROLE and BD_ACTOR in the command since pane inherits from shell, not session env startupCmd, err := config.BuildCrewStartupCommandWithAgentOverride(r.Name, name, r.Path, beacon, crewAgentOverride) if err != nil { return fmt.Errorf("building startup command: %w", err) diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go index 2edf1be8..f8f24b9d 100644 --- a/internal/cmd/statusline.go +++ b/internal/cmd/statusline.go @@ -713,6 +713,12 @@ func getMailPreviewWithRoot(identity string, maxLen int, townRoot string) (int, // beadsDir should be the directory containing .beads (for rig-level) or // empty to use the town root (for town-level roles). func getHookedWork(identity string, maxLen int, beadsDir string) string { + // Guard: identity must be non-empty to filter by assignee. + // Without identity, the query would return ALL hooked beads regardless of assignee. + if identity == "" { + return "" + } + // If no beadsDir specified, use town root if beadsDir == "" { var err error