From 153e24b94adbf987e5d6e63a87d576a4eab7ced2 Mon Sep 17 00:00:00 2001 From: Andrei Eternal <206184+Garoth@users.noreply.github.com> Date: Wed, 15 Oct 2025 03:40:12 -0700 Subject: [PATCH] fix ctrl-c in task view. should just disconnect the view (#6876) Co-authored-by: Andrei Edell --- cli/pkg/cli/task/manager.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cli/pkg/cli/task/manager.go b/cli/pkg/cli/task/manager.go index d7ab0068..2a7b205a 100644 --- a/cli/pkg/cli/task/manager.go +++ b/cli/pkg/cli/task/manager.go @@ -703,17 +703,24 @@ func (m *Manager) FollowConversation(ctx context.Context, instanceAddress string case <-ctx.Done(): return case <-sigChan: - // Check if input is currently being shown - if coordinator.IsInputAllowed() { - // Input form is showing - huh will handle the signal via ErrUserAborted - // Do nothing here, let the input handler deal with it - } else { - // Streaming mode - cancel the task and stay in follow mode - m.renderer.RenderTaskCancelled() - if err := m.CancelTask(context.Background()); err != nil { - fmt.Printf("Error cancelling task: %v\n", err) + if interactive { + // Interactive mode (task chat) + // Check if input is currently being shown + if coordinator.IsInputAllowed() { + // Input form is showing - huh will handle the signal via ErrUserAborted + // Do nothing here, let the input handler deal with it + } else { + // Streaming mode - cancel the task and stay in follow mode + m.renderer.RenderTaskCancelled() + if err := m.CancelTask(context.Background()); err != nil { + fmt.Printf("Error cancelling task: %v\n", err) + } + // Don't cancel main context - stay in follow mode } - // Don't cancel main context - stay in follow mode + } else { + // Non-interactive mode (task view --follow) + // Just exit without canceling the task + cancel() } } }() @@ -1231,4 +1238,4 @@ func (m *Manager) Cleanup() { if m.streamingDisplay != nil { m.streamingDisplay.Cleanup() } -} +} \ No newline at end of file