From 81b250ee3219fc6ff46c692e2ce889c370866363 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Mon, 29 Dec 2025 21:56:20 -0800 Subject: [PATCH] Fix --issue flag in gt session start to hook work to polecat (gt-pxsna) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- internal/session/manager.go | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/internal/session/manager.go b/internal/session/manager.go index 431160aa..39f02307 100644 --- a/internal/session/manager.go +++ b/internal/session/manager.go @@ -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 +}