fix: Make Mayor/Deacon session names include town name
Session names `gt-mayor` and `gt-deacon` were hardcoded, causing tmux
session name collisions when running multiple towns simultaneously.
Changed to `gt-{town}-mayor` and `gt-{town}-deacon` format (e.g.,
`gt-ai-mayor`) to allow concurrent multi-town operation.
Key changes:
- session.MayorSessionName() and DeaconSessionName() now take townName param
- Added workspace.GetTownName() helper to load town name from config
- Updated all callers in cmd/, daemon/, doctor/, mail/, rig/, templates/
- Updated tests with new session name format
- Bead IDs remain unchanged (already scoped by .beads/ directory)
Fixes #60
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/gastown/internal/config"
|
||||
"github.com/steveyegge/gastown/internal/session"
|
||||
"github.com/steveyegge/gastown/internal/tmux"
|
||||
"github.com/steveyegge/gastown/internal/workspace"
|
||||
)
|
||||
@@ -116,10 +117,20 @@ func runThemeApply(cmd *cobra.Command, args []string) error {
|
||||
// Determine current rig
|
||||
rigName := detectCurrentRig()
|
||||
|
||||
// Get town name for session name comparison
|
||||
var mayorSession, deaconSession string
|
||||
townRoot, err := workspace.FindFromCwd()
|
||||
if err == nil && townRoot != "" {
|
||||
if townName, err := workspace.GetTownName(townRoot); err == nil {
|
||||
mayorSession = session.MayorSessionName(townName)
|
||||
deaconSession = session.DeaconSessionName(townName)
|
||||
}
|
||||
}
|
||||
|
||||
// Apply to matching sessions
|
||||
applied := 0
|
||||
for _, session := range sessions {
|
||||
if !strings.HasPrefix(session, "gt-") {
|
||||
for _, sess := range sessions {
|
||||
if !strings.HasPrefix(sess, "gt-") {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -127,23 +138,23 @@ func runThemeApply(cmd *cobra.Command, args []string) error {
|
||||
var theme tmux.Theme
|
||||
var rig, worker, role string
|
||||
|
||||
if session == "gt-mayor" {
|
||||
if sess == mayorSession {
|
||||
theme = tmux.MayorTheme()
|
||||
worker = "Mayor"
|
||||
role = "coordinator"
|
||||
} else if session == "gt-deacon" {
|
||||
} else if sess == deaconSession {
|
||||
theme = tmux.DeaconTheme()
|
||||
worker = "Deacon"
|
||||
role = "health-check"
|
||||
} else if strings.HasSuffix(session, "-witness") && strings.HasPrefix(session, "gt-") {
|
||||
} else if strings.HasSuffix(sess, "-witness") && strings.HasPrefix(sess, "gt-") {
|
||||
// Witness sessions: gt-<rig>-witness
|
||||
rig = strings.TrimPrefix(strings.TrimSuffix(session, "-witness"), "gt-")
|
||||
rig = strings.TrimPrefix(strings.TrimSuffix(sess, "-witness"), "gt-")
|
||||
theme = getThemeForRole(rig, "witness")
|
||||
worker = "witness"
|
||||
role = "witness"
|
||||
} else {
|
||||
// Parse session name: gt-<rig>-<worker> or gt-<rig>-crew-<name>
|
||||
parts := strings.SplitN(session, "-", 3)
|
||||
parts := strings.SplitN(sess, "-", 3)
|
||||
if len(parts) < 3 {
|
||||
continue
|
||||
}
|
||||
@@ -171,20 +182,20 @@ func runThemeApply(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// Apply theme and status format
|
||||
if err := t.ApplyTheme(session, theme); err != nil {
|
||||
fmt.Printf(" %s: failed (%v)\n", session, err)
|
||||
if err := t.ApplyTheme(sess, theme); err != nil {
|
||||
fmt.Printf(" %s: failed (%v)\n", sess, err)
|
||||
continue
|
||||
}
|
||||
if err := t.SetStatusFormat(session, rig, worker, role); err != nil {
|
||||
fmt.Printf(" %s: failed to set format (%v)\n", session, err)
|
||||
if err := t.SetStatusFormat(sess, rig, worker, role); err != nil {
|
||||
fmt.Printf(" %s: failed to set format (%v)\n", sess, err)
|
||||
continue
|
||||
}
|
||||
if err := t.SetDynamicStatus(session); err != nil {
|
||||
fmt.Printf(" %s: failed to set dynamic status (%v)\n", session, err)
|
||||
if err := t.SetDynamicStatus(sess); err != nil {
|
||||
fmt.Printf(" %s: failed to set dynamic status (%v)\n", sess, err)
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf(" %s: applied %s theme\n", session, theme.Name)
|
||||
fmt.Printf(" %s: applied %s theme\n", sess, theme.Name)
|
||||
applied++
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user