spawn: Add work instruction + export SessionName
- Export session.Manager.SessionName for spawn.go access - Add --address alias for --identity in mail inbox/check - Send explicit work instruction to polecat after spawn - Add CapturePaneLines and WaitForClaudeReady helpers (unused for now) - Proper solution filed as gt-hb0 (needs Witness/Deacon AI monitoring) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -177,6 +177,18 @@ func (t *Tmux) CapturePaneAll(session string) (string, error) {
|
||||
return t.run("capture-pane", "-p", "-t", session, "-S", "-")
|
||||
}
|
||||
|
||||
// CapturePaneLines captures the last N lines of a pane as a slice.
|
||||
func (t *Tmux) CapturePaneLines(session string, lines int) ([]string, error) {
|
||||
out, err := t.CapturePane(session, lines)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out == "" {
|
||||
return nil, nil
|
||||
}
|
||||
return strings.Split(out, "\n"), nil
|
||||
}
|
||||
|
||||
// AttachSession attaches to an existing session.
|
||||
// Note: This replaces the current process with tmux attach.
|
||||
func (t *Tmux) AttachSession(session string) error {
|
||||
@@ -314,6 +326,30 @@ func (t *Tmux) WaitForShellReady(session string, timeout time.Duration) error {
|
||||
return fmt.Errorf("timeout waiting for shell")
|
||||
}
|
||||
|
||||
// WaitForClaudeReady polls until Claude's prompt indicator appears in the pane.
|
||||
// Claude is ready when we see "> " at the start of a line (the input prompt).
|
||||
// This is more reliable than just checking if node is running.
|
||||
func (t *Tmux) WaitForClaudeReady(session string, timeout time.Duration) error {
|
||||
deadline := time.Now().Add(timeout)
|
||||
for time.Now().Before(deadline) {
|
||||
// Capture last few lines of the pane
|
||||
lines, err := t.CapturePaneLines(session, 10)
|
||||
if err != nil {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
// Look for Claude's prompt indicator "> " at start of line
|
||||
for _, line := range lines {
|
||||
trimmed := strings.TrimSpace(line)
|
||||
if strings.HasPrefix(trimmed, "> ") || trimmed == ">" {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
return fmt.Errorf("timeout waiting for Claude prompt")
|
||||
}
|
||||
|
||||
// GetSessionInfo returns detailed information about a session.
|
||||
func (t *Tmux) GetSessionInfo(name string) (*SessionInfo, error) {
|
||||
format := "#{session_name}|#{session_windows}|#{session_created_string}|#{session_attached}"
|
||||
|
||||
Reference in New Issue
Block a user