Fix --issue flag in gt session start to hook work to polecat (gt-pxsna)

When starting a polecat session with --issue flag, the issue is now
properly hooked to the polecat via bd update --status=hooked. This
ensures 'gt mol status' shows the assigned work when the session starts.

🤖 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-29 21:56:20 -08:00
parent 1dbb9555e2
commit 81b250ee32

View File

@@ -153,6 +153,15 @@ func (m *Manager) Start(polecat string, opts StartOptions) error {
_ = m.tmux.SetEnvironment(sessionID, "BEADS_NO_DAEMON", "1")
_ = m.tmux.SetEnvironment(sessionID, "BEADS_AGENT_NAME", fmt.Sprintf("%s/%s", m.rig.Name, polecat))
// Hook the issue to the polecat if provided via --issue flag
if opts.Issue != "" {
agentID := fmt.Sprintf("%s/polecats/%s", m.rig.Name, polecat)
if err := m.hookIssue(opts.Issue, agentID, workDir); err != nil {
// Non-fatal - warn but continue (session can still start)
fmt.Printf("Warning: could not hook issue %s: %v\n", opts.Issue, err)
}
}
// Apply theme (non-fatal: theming failure doesn't affect operation)
theme := tmux.AssignTheme(m.rig.Name)
_ = m.tmux.ConfigureGasTownSession(sessionID, theme, m.rig.Name, polecat, "polecat")
@@ -176,10 +185,6 @@ func (m *Manager) Start(polecat string, opts StartOptions) error {
return fmt.Errorf("sending command: %w", err)
}
// NOTE: No issue injection needed here. Work assignments are sent via mail
// before session start, and the SessionStart hook runs gt prime + mail check
// which shows the polecat its assignment.
return nil
}
@@ -389,3 +394,17 @@ func (m *Manager) StopAll(force bool) error {
return lastErr
}
// hookIssue pins an issue to a polecat's hook using bd update.
// This makes the work visible via 'gt mol status' when the session starts.
func (m *Manager) hookIssue(issueID, agentID, workDir string) error {
// Use bd update to set status=hooked and assign to the polecat
cmd := exec.Command("bd", "update", issueID, "--status=hooked", "--assignee="+agentID)
cmd.Dir = workDir
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("bd update failed: %w", err)
}
fmt.Printf("✓ Hooked issue %s to %s\n", issueID, agentID)
return nil
}