feat: Add crew session cycling fix and daemon exponential backoff (gt-ws8ol)

- Fix crew next/prev: Pass session name via key binding to avoid run-shell context issue
- Add TouchTownActivity() for town-level activity signaling
- Implement daemon exponential backoff based on activity.json:
  - 0-5 min idle → 5 min heartbeat
  - 5-15 min idle → 10 min heartbeat
  - 15-45 min idle → 30 min heartbeat
  - 45+ min idle → 60 min heartbeat (max)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-26 21:15:08 -08:00
parent 305345bf36
commit fa0dfc324e
5 changed files with 158 additions and 15 deletions

View File

@@ -273,6 +273,11 @@ func init() {
crewCmd.AddCommand(crewRenameCmd)
crewCmd.AddCommand(crewPristineCmd)
crewCmd.AddCommand(crewRestartCmd)
// Add --session flag to next/prev commands for tmux key binding support
// When run via run-shell, tmux session context may be wrong, so we pass it explicitly
crewNextCmd.Flags().StringVarP(&crewCycleSession, "session", "s", "", "tmux session name (for key bindings)")
crewPrevCmd.Flags().StringVarP(&crewCycleSession, "session", "s", "", "tmux session name (for key bindings)")
crewCmd.AddCommand(crewNextCmd)
crewCmd.AddCommand(crewPrevCmd)
crewCmd.AddCommand(crewStartCmd)

View File

@@ -8,16 +8,30 @@ import (
"github.com/spf13/cobra"
)
// crewCycleSession is the --session flag for crew next/prev commands.
// When run via tmux key binding (run-shell), the session context may not be
// correct, so we pass the session name explicitly via #{session_name} expansion.
var crewCycleSession string
// cycleCrewSession switches to the next or previous crew session in the same rig.
// direction: 1 for next, -1 for previous
func cycleCrewSession(direction int) error {
// Get current session (uses existing function from handoff.go)
currentSession, err := getCurrentTmuxSession()
if err != nil {
return fmt.Errorf("not in a tmux session: %w", err)
}
if currentSession == "" {
return fmt.Errorf("not in a tmux session")
// sessionOverride: if non-empty, use this instead of detecting current session
func cycleCrewSession(direction int, sessionOverride string) error {
var currentSession string
var err error
if sessionOverride != "" {
// Use the provided session name (from tmux key binding)
currentSession = sessionOverride
} else {
// Get current session (uses existing function from handoff.go)
currentSession, err = getCurrentTmuxSession()
if err != nil {
return fmt.Errorf("not in a tmux session: %w", err)
}
if currentSession == "" {
return fmt.Errorf("not in a tmux session")
}
}
// Parse rig name from current session
@@ -73,9 +87,9 @@ func cycleCrewSession(direction int) error {
}
func runCrewNext(cmd *cobra.Command, args []string) error {
return cycleCrewSession(1)
return cycleCrewSession(1, crewCycleSession)
}
func runCrewPrev(cmd *cobra.Command, args []string) error {
return cycleCrewSession(-1)
return cycleCrewSession(-1, crewCycleSession)
}

View File

@@ -22,6 +22,10 @@ across distributed teams of AI agents working on shared codebases.`,
// Build command path: gt status, gt mail send, etc.
cmdPath := buildCommandPath(cmd)
keepalive.TouchWithArgs(cmdPath, args)
// Also signal town-level activity for daemon exponential backoff
// This resets the backoff when any gt command runs
keepalive.TouchTownActivity(cmdPath)
},
}