fix(peek): Support cross-rig crew paths like beads/crew/dave
gt peek now correctly handles crew worker paths by detecting the crew/
prefix and using the proper crew session name format (gt-{rig}-crew-{name}).
Changes:
- Add CaptureSession method to Manager for raw session ID capture
- Detect crew/ prefix in peek command and use CrewSessionName
- Update help text with crew path examples
Fixes: gt-yud21
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,9 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/steveyegge/gastown/internal/session"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -18,8 +20,8 @@ func init() {
|
||||
var peekCmd = &cobra.Command{
|
||||
Use: "peek <rig/polecat> [count]",
|
||||
GroupID: GroupComm,
|
||||
Short: "View recent output from a polecat session",
|
||||
Long: `Capture and display recent terminal output from a polecat session.
|
||||
Short: "View recent output from a polecat or crew session",
|
||||
Long: `Capture and display recent terminal output from an agent session.
|
||||
|
||||
This is the ergonomic alias for 'gt session capture'. Use it to check
|
||||
what an agent is currently doing or has recently output.
|
||||
@@ -28,10 +30,15 @@ The nudge/peek pair provides the canonical interface for agent sessions:
|
||||
gt nudge - send messages TO a session (reliable delivery)
|
||||
gt peek - read output FROM a session (capture-pane wrapper)
|
||||
|
||||
Supports both polecats and crew workers:
|
||||
- Polecats: rig/name format (e.g., greenplace/furiosa)
|
||||
- Crew: rig/crew/name format (e.g., beads/crew/dave)
|
||||
|
||||
Examples:
|
||||
gt peek greenplace/furiosa # Last 100 lines (default)
|
||||
gt peek greenplace/furiosa 50 # Last 50 lines
|
||||
gt peek greenplace/furiosa -n 200 # Last 200 lines`,
|
||||
gt peek greenplace/furiosa # Polecat: last 100 lines (default)
|
||||
gt peek greenplace/furiosa 50 # Polecat: last 50 lines
|
||||
gt peek beads/crew/dave # Crew: last 100 lines
|
||||
gt peek beads/crew/dave -n 200 # Crew: last 200 lines`,
|
||||
Args: cobra.RangeArgs(1, 2),
|
||||
RunE: runPeek,
|
||||
}
|
||||
@@ -59,7 +66,18 @@ func runPeek(cmd *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
output, err := mgr.Capture(polecatName, lines)
|
||||
var output string
|
||||
|
||||
// Handle crew/ prefix for cross-rig crew workers
|
||||
// e.g., "beads/crew/dave" -> session name "gt-beads-crew-dave"
|
||||
if strings.HasPrefix(polecatName, "crew/") {
|
||||
crewName := strings.TrimPrefix(polecatName, "crew/")
|
||||
sessionID := session.CrewSessionName(rigName, crewName)
|
||||
output, err = mgr.CaptureSession(sessionID, lines)
|
||||
} else {
|
||||
output, err = mgr.Capture(polecatName, lines)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("capturing output: %w", err)
|
||||
}
|
||||
|
||||
@@ -395,6 +395,21 @@ func (m *Manager) Capture(polecat string, lines int) (string, error) {
|
||||
return m.tmux.CapturePane(sessionID, lines)
|
||||
}
|
||||
|
||||
// CaptureSession returns the recent output from a session by raw session ID.
|
||||
// Use this for crew workers or other non-polecat sessions where the session
|
||||
// name doesn't follow the standard gt-{rig}-{polecat} pattern.
|
||||
func (m *Manager) CaptureSession(sessionID string, lines int) (string, error) {
|
||||
running, err := m.tmux.HasSession(sessionID)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("checking session: %w", err)
|
||||
}
|
||||
if !running {
|
||||
return "", ErrSessionNotFound
|
||||
}
|
||||
|
||||
return m.tmux.CapturePane(sessionID, lines)
|
||||
}
|
||||
|
||||
// Inject sends a message to a polecat session.
|
||||
// Uses a longer debounce delay for large messages to ensure paste completes.
|
||||
func (m *Manager) Inject(polecat, message string) error {
|
||||
|
||||
Reference in New Issue
Block a user