agent tracker + tmux updates

This commit is contained in:
David Chen 2026-04-09 10:07:43 -07:00
parent ba2c8ef54e
commit 75403c927f
5 changed files with 67 additions and 17 deletions

View file

@ -1339,15 +1339,24 @@ func activeAgentWindowID(record *agentRecord) string {
return windowID
}
func launchAgentLayout(record *agentRecord) error {
func launchAgentLayout(record *agentRecord) (err error) {
previousWindowID := currentTmuxWindowID()
cleanupWindow := false
windowID := ""
windowID, sessionID, sessionName, attachAfter, err := createWindow(record.Name, record.RepoCopyPath, record.LaunchWindowID)
if err != nil {
return err
}
if err := runTmux("select-window", "-t", windowID); err != nil {
return err
}
cleanupWindow = true
defer func() {
if err == nil || !cleanupWindow || strings.TrimSpace(windowID) == "" {
return
}
_ = runTmux("kill-window", "-t", windowID)
if strings.TrimSpace(previousWindowID) != "" {
_ = runTmux("select-window", "-t", previousWindowID)
}
}()
topPane, err := currentPane(windowID)
if err != nil {
return err
@ -1400,12 +1409,20 @@ func launchAgentLayout(record *agentRecord) error {
return err
}
}
if attachAfter && canAttachTmux() {
if err := runTmux("attach-session", "-t", sessionID); err != nil {
return err
}
cleanupWindow = false
return nil
}
if err := runTmux("select-window", "-t", windowID); err != nil {
return err
}
if err := runTmux("select-pane", "-t", aiPane); err != nil {
return err
}
if attachAfter && canAttachTmux() {
return runTmux("attach-session", "-t", sessionID)
}
cleanupWindow = false
return nil
}