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.