Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/extending/SOCKET_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ list_agents
complete_agent
restart_agent
trigger_cleanup
trigger_refresh
repair_state
get_repo_config
update_repo_config
Expand Down Expand Up @@ -49,6 +50,7 @@ Each command below matches a `case` in `handleRequest`.
| `complete_agent` | Mark agent ready for cleanup | `repo`, `name`, `summary`, `failure_reason` |
| `restart_agent` | Restart a persistent agent | `repo`, `name` |
| `trigger_cleanup` | Force cleanup cycle | none |
| `trigger_refresh` | Force worktree refresh cycle | none |
| `repair_state` | Run state repair routine | none |
| `get_repo_config` | Get merge-queue / pr-shepherd config | `repo` |
| `update_repo_config` | Update repo config | `repo`, `config` (JSON object) |
Expand Down Expand Up @@ -644,6 +646,27 @@ class MulticlaudeClient {
}
```

#### trigger_refresh

**Description:** Trigger immediate worktree refresh for all agents (syncs with main branch)

**Request:**
```json
{
"command": "trigger_refresh"
}
```

**Response:**
```json
{
"success": true,
"data": "Worktree refresh triggered"
}
```

**Note:** Refresh runs asynchronously in the background.

#### repair_state

**Description:** Repair inconsistent state (equivalent to `multiclaude repair`)
Expand Down
23 changes: 18 additions & 5 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"strings"
"time"

"github.com/google/uuid"

"github.com/dlorenc/multiclaude/internal/agents"
"github.com/dlorenc/multiclaude/internal/bugreport"
"github.com/dlorenc/multiclaude/internal/daemon"
Expand Down Expand Up @@ -5538,14 +5540,25 @@ func (c *CLI) restartClaude(args []string) error {

// Build the command
var cmdArgs []string
sessionID := agent.SessionID
if hasHistory {
// Session has history - use --resume to continue
cmdArgs = []string{"--resume", agent.SessionID}
fmt.Printf("Resuming Claude session %s...\n", agent.SessionID)
cmdArgs = []string{"--resume", sessionID}
fmt.Printf("Resuming Claude session %s...\n", sessionID)
} else {
// New session - use --session-id
cmdArgs = []string{"--session-id", agent.SessionID}
fmt.Printf("Starting new Claude session %s...\n", agent.SessionID)
// No history - generate a new session ID to avoid "already in use" errors
// This can happen when Claude exits abnormally or the previous session
// was started but never used
sessionID = uuid.New().String()
cmdArgs = []string{"--session-id", sessionID}
fmt.Printf("Starting new Claude session %s...\n", sessionID)

// Update agent with new session ID
agent.SessionID = sessionID
if err := st.UpdateAgent(repoName, agentName, agent); err != nil {
fmt.Printf("Warning: failed to save new session ID: %v\n", err)
// Continue anyway - the session will work, just won't persist
}
}

// Add common flags
Expand Down