fix(costs): derive session name for mayor/deacon without GT_TOWN

Error: Ran 1 stop hook
  ⎿  Stop hook error: Failed with non-blocking status code: Error: --session flag required (or set GT_SESSION env var, or GT_RIG/GT_ROLE)
  Usage:
    gt costs record [flags]

deriveSessionName() now falls back to gt-{role} when GT_ROLE is mayor
or deacon but GT_TOWN is not set. Previously this case returned empty
string, causing the Stop hook to fail.
This commit is contained in:
Martin Emde
2026-01-07 19:17:28 -08:00
committed by GitHub
parent ffeff97d9f
commit 6209a49d54
2 changed files with 21 additions and 3 deletions

View File

@@ -61,6 +61,20 @@ func TestDeriveSessionName(t *testing.T) {
},
expected: "gt-ai-deacon",
},
{
name: "mayor session without GT_TOWN",
envVars: map[string]string{
"GT_ROLE": "mayor",
},
expected: "gt-mayor",
},
{
name: "deacon session without GT_TOWN",
envVars: map[string]string{
"GT_ROLE": "deacon",
},
expected: "gt-deacon",
},
{
name: "no env vars",
envVars: map[string]string{},