fix: Add startup delay before nudging newly spawned polecats (gt-1dbcp)

Claude needs ~2 seconds to initialize before it can process nudges.
Without this delay, the initial "Work slung" message would arrive
before Claude was ready, causing the SessionStart hook not to fire.

🤖 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-28 16:18:52 -08:00
parent 11d86423ba
commit 99a619ae09

View File

@@ -6,6 +6,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
"time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/steveyegge/gastown/internal/beads" "github.com/steveyegge/gastown/internal/beads"
@@ -13,6 +14,10 @@ import (
"github.com/steveyegge/gastown/internal/tmux" "github.com/steveyegge/gastown/internal/tmux"
) )
// claudeStartupDelay is how long to wait for Claude to start before nudging.
// This fixes gt-1dbcp: polecat auto-start doesn't process initial nudge.
const claudeStartupDelay = 2 * time.Second
var slingCmd = &cobra.Command{ var slingCmd = &cobra.Command{
Use: "sling <bead-or-formula> [target]", Use: "sling <bead-or-formula> [target]",
GroupID: GroupWork, GroupID: GroupWork,
@@ -176,6 +181,12 @@ func runSling(cmd *cobra.Command, args []string) error {
} }
targetAgent = spawnInfo.AgentID() targetAgent = spawnInfo.AgentID()
targetPane = spawnInfo.Pane targetPane = spawnInfo.Pane
// Wait for Claude to start up before nudging (fixes gt-1dbcp)
if targetPane != "" {
fmt.Printf("Waiting for Claude to initialize...\n")
time.Sleep(claudeStartupDelay)
}
} }
} else { } else {
// Slinging to an existing agent // Slinging to an existing agent
@@ -531,6 +542,12 @@ func runSlingFormula(args []string) error {
} }
targetAgent = spawnInfo.AgentID() targetAgent = spawnInfo.AgentID()
targetPane = spawnInfo.Pane targetPane = spawnInfo.Pane
// Wait for Claude to start up before nudging (fixes gt-1dbcp)
if targetPane != "" {
fmt.Printf("Waiting for Claude to initialize...\n")
time.Sleep(claudeStartupDelay)
}
} }
} else { } else {
// Slinging to an existing agent // Slinging to an existing agent