From de32cb0be2703ce332adb93e7875f7dd6ed3634d Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Mon, 29 Dec 2025 23:37:41 -0800 Subject: [PATCH] Fix mail inbox detecting wrong identity from witness/refinery dirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When GT_ROLE env var is not set, detectSender() now falls back to cwd-based detection instead of immediately returning "overseer". This allows running mail commands from witness/refinery directories without GT_ROLE set (e.g., debugging sessions) and correctly detecting the identity from the current working directory path. (gt-od1g) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/mail.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/cmd/mail.go b/internal/cmd/mail.go index 2b140fa7..5fa6707e 100644 --- a/internal/cmd/mail.go +++ b/internal/cmd/mail.go @@ -704,10 +704,12 @@ func findLocalBeadsDir() (string, error) { // detectSender determines the current context's address. // Priority: // 1. GT_ROLE env var → use the role-based identity (agent session) -// 2. No GT_ROLE → return "overseer" (human at terminal) +// 2. No GT_ROLE → try cwd-based detection (witness/refinery/polecat/crew directories) +// 3. No match → return "overseer" (human at terminal) // // All Gas Town agents run in tmux sessions with GT_ROLE set at spawn. -// Humans in regular terminals won't have GT_ROLE, so they're the overseer. +// However, cwd-based detection is also tried to support running commands +// from agent directories without GT_ROLE set (e.g., debugging sessions). func detectSender() string { // Check GT_ROLE first (authoritative for agent sessions) role := os.Getenv("GT_ROLE") @@ -716,8 +718,8 @@ func detectSender() string { return detectSenderFromRole(role) } - // No GT_ROLE means human at terminal - they're the overseer - return "overseer" + // No GT_ROLE - try cwd-based detection, defaults to overseer if not in agent directory + return detectSenderFromCwd() } // detectSenderFromRole builds an address from the GT_ROLE and related env vars.