diff --git a/cli/pkg/cli/instances.go b/cli/pkg/cli/instances.go index 072ee442..f6c737e1 100644 --- a/cli/pkg/cli/instances.go +++ b/cli/pkg/cli/instances.go @@ -156,6 +156,7 @@ func killAllCLIInstances(ctx context.Context, registry *global.ClientRegistry) e } var killResults []killResult + killedAddresses := make(map[string]bool) // Kill all CLI instances for _, instance := range cliInstances { @@ -168,31 +169,42 @@ func killAllCLIInstances(ctx context.Context, registry *global.ClientRegistry) e fmt.Printf("⚠ Instance %s appears to be already dead\n", instance.Address) } else { fmt.Printf("✓ Killed %s (PID %d)\n", instance.Address, result.pid) + killedAddresses[instance.Address] = true } } - // Wait for all instances to clean up their registry entries - fmt.Printf("Waiting for instances to clean up registry entries...\n") + // Wait for killed instances to clean up their registry entries + if len(killedAddresses) > 0 { + fmt.Printf("Waiting for instances to clean up registry entries...\n") - maxWaitTime := 10 // seconds - for i := 0; i < maxWaitTime; i++ { - time.Sleep(1 * time.Second) + maxWaitTime := 10 // seconds + for i := 0; i < maxWaitTime; i++ { + time.Sleep(1 * time.Second) - remainingInstances, err := registry.ListInstancesCleaned(ctx) - if err != nil { - fmt.Printf("Warning: failed to check registry status: %v\n", err) - continue - } + remainingInstances, err := registry.ListInstancesCleaned(ctx) + if err != nil { + fmt.Printf("Warning: failed to check registry status: %v\n", err) + continue + } - if len(remainingInstances) == 0 { - fmt.Printf("✓ All instances successfully removed from registry.\n") - break - } - - if i == maxWaitTime-1 { - fmt.Printf("⚠ %d instances still in registry after %d seconds\n", len(remainingInstances), maxWaitTime) + // Check if any of the killed instances are still in the registry + stillPresent := []string{} for _, remaining := range remainingInstances { - fmt.Printf(" - %s\n", remaining.Address) + if killedAddresses[remaining.Address] { + stillPresent = append(stillPresent, remaining.Address) + } + } + + if len(stillPresent) == 0 { + fmt.Printf("✓ All killed instances successfully removed from registry.\n") + break + } + + if i == maxWaitTime-1 { + fmt.Printf("⚠ %d killed instance(s) still in registry after %d seconds\n", len(stillPresent), maxWaitTime) + for _, addr := range stillPresent { + fmt.Printf(" - %s\n", addr) + } } } } @@ -490,4 +502,4 @@ func newInstanceNewCommand() *cobra.Command { cmd.Flags().BoolVarP(&setDefault, "default", "d", false, "set as default instance") return cmd -} +} \ No newline at end of file diff --git a/cli/pkg/cli/task/manager.go b/cli/pkg/cli/task/manager.go index 0b0bf31d..25ba0cae 100644 --- a/cli/pkg/cli/task/manager.go +++ b/cli/pkg/cli/task/manager.go @@ -658,18 +658,6 @@ func (m *Manager) ShowConversation(ctx context.Context) error { } func (m *Manager) FollowConversation(ctx context.Context, instanceAddress string, interactive bool) error { - // Check if there's an active task before entering follow mode - err := m.CheckSendEnabled(ctx) - if err != nil { - // Handle specific error cases - if errors.Is(err, ErrNoActiveTask) { - fmt.Println("No active task found. Use 'cline task new' to create a task first.") - return nil - } - // For other errors (like task busy), we can still enter follow mode - // as the user may want to observe the task - } - // Enable streaming mode m.mu.Lock() m.isStreamingMode = true @@ -770,18 +758,6 @@ func (m *Manager) FollowConversation(ctx context.Context, instanceAddress string // FollowConversationUntilCompletion streams conversation updates until task completion func (m *Manager) FollowConversationUntilCompletion(ctx context.Context) error { - // Check if there's an active task before entering follow mode - err := m.CheckSendEnabled(ctx) - if err != nil { - // Handle specific error cases - if errors.Is(err, ErrNoActiveTask) { - fmt.Println("No active task found. Use 'cline task new' to create a task first.") - return nil - } - // For other errors (like task busy), we can still enter follow mode - // as the user may want to observe the task - } - // Enable streaming mode m.mu.Lock() m.isStreamingMode = true @@ -1278,4 +1254,4 @@ func (m *Manager) Cleanup() { if m.streamingDisplay != nil { m.streamingDisplay.Cleanup() } -} \ No newline at end of file +}