From a234bd4658e097c1d81048278cd7fc7b992fc7e8 Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Thu, 17 Jul 2025 13:58:45 +0100 Subject: [PATCH] fix: distinguish between stopped and failed task attempts (#241) * distinguish between stopped and failed task attempts * push types * deduplicate --- backend/src/models/task_attempt.rs | 8 ++-- .../components/tasks/TaskDetails/LogsTab.tsx | 42 ++++++++++++------- shared/types.ts | 2 +- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/backend/src/models/task_attempt.rs b/backend/src/models/task_attempt.rs index 53336f73..ba4cc3ad 100644 --- a/backend/src/models/task_attempt.rs +++ b/backend/src/models/task_attempt.rs @@ -181,9 +181,11 @@ pub enum ExecutionState { SetupRunning, SetupComplete, SetupFailed, + SetupStopped, CodingAgentRunning, CodingAgentComplete, CodingAgentFailed, + CodingAgentStopped, Complete, } @@ -1042,7 +1044,7 @@ impl TaskAttempt { ExecutionState::CodingAgentFailed } crate::models::execution_process::ExecutionProcessStatus::Killed => { - ExecutionState::CodingAgentFailed + ExecutionState::CodingAgentStopped } } } else { @@ -1053,7 +1055,7 @@ impl TaskAttempt { ExecutionState::SetupFailed } crate::models::execution_process::ExecutionProcessStatus::Killed => { - ExecutionState::SetupFailed + ExecutionState::SetupStopped } } } else if let Some(agent) = coding_agent_process { @@ -1069,7 +1071,7 @@ impl TaskAttempt { ExecutionState::CodingAgentFailed } crate::models::execution_process::ExecutionProcessStatus::Killed => { - ExecutionState::CodingAgentFailed + ExecutionState::CodingAgentStopped } } } else { diff --git a/frontend/src/components/tasks/TaskDetails/LogsTab.tsx b/frontend/src/components/tasks/TaskDetails/LogsTab.tsx index d0102311..0937ae5d 100644 --- a/frontend/src/components/tasks/TaskDetails/LogsTab.tsx +++ b/frontend/src/components/tasks/TaskDetails/LogsTab.tsx @@ -54,12 +54,15 @@ function LogsTab() { const isSetupRunning = executionState.execution_state === 'SetupRunning'; const isSetupComplete = executionState.execution_state === 'SetupComplete'; const isSetupFailed = executionState.execution_state === 'SetupFailed'; + const isSetupStopped = executionState.execution_state === 'SetupStopped'; const isCodingAgentRunning = executionState.execution_state === 'CodingAgentRunning'; const isCodingAgentComplete = executionState.execution_state === 'CodingAgentComplete'; const isCodingAgentFailed = executionState.execution_state === 'CodingAgentFailed'; + const isCodingAgentStopped = + executionState.execution_state === 'CodingAgentStopped'; const isComplete = executionState.execution_state === 'Complete'; const hasChanges = executionState.has_changes; @@ -73,8 +76,8 @@ function LogsTab() { ); } - // When setup failed, show error message and conversation - if (isSetupFailed) { + // When setup failed or was stopped + if (isSetupFailed || isSetupStopped) { const setupProcess = executionState.setup_process_id ? attemptData.runningProcessDetails[executionState.setup_process_id] : Object.values(attemptData.runningProcessDetails).find( @@ -84,12 +87,16 @@ function LogsTab() { return (
-

- Setup Script Failed -

-

- The setup script encountered an error. Error details below: +

+ {isSetupFailed ? 'Setup Script Failed' : 'Setup Script Stopped'}

+ {isSetupFailed && ( +

+ The setup script encountered an error. Error details below: +

+ )}
{setupProcess && ( @@ -99,8 +106,8 @@ function LogsTab() { ); } - // When coding agent failed, show error message and conversation - if (isCodingAgentFailed) { + // When coding agent failed or was stopped + if (isCodingAgentFailed || isCodingAgentStopped) { const codingAgentProcess = executionState.coding_agent_process_id ? attemptData.runningProcessDetails[ executionState.coding_agent_process_id @@ -112,12 +119,18 @@ function LogsTab() { return (
-

- Coding Agent Failed -

-

- The coding agent encountered an error. Error details below: +

+ {isCodingAgentFailed + ? 'Coding Agent Failed' + : 'Coding Agent Stopped'}

+ {isCodingAgentFailed && ( +

+ The coding agent encountered an error. Error details below: +

+ )}
{codingAgentProcess && ( @@ -133,6 +146,7 @@ function LogsTab() { !isCodingAgentRunning && !isCodingAgentComplete && !isCodingAgentFailed && + !isCodingAgentStopped && !hasChanges ) { return ( diff --git a/shared/types.ts b/shared/types.ts index fff63d88..c7f33b2f 100644 --- a/shared/types.ts +++ b/shared/types.ts @@ -92,7 +92,7 @@ export type WorktreeDiff = { files: Array, }; export type BranchStatus = { is_behind: boolean, commits_behind: number, commits_ahead: number, up_to_date: boolean, merged: boolean, has_uncommitted_changes: boolean, base_branch_name: string, }; -export type ExecutionState = "NotStarted" | "SetupRunning" | "SetupComplete" | "SetupFailed" | "CodingAgentRunning" | "CodingAgentComplete" | "CodingAgentFailed" | "Complete"; +export type ExecutionState = "NotStarted" | "SetupRunning" | "SetupComplete" | "SetupFailed" | "SetupStopped" | "CodingAgentRunning" | "CodingAgentComplete" | "CodingAgentFailed" | "CodingAgentStopped" | "Complete"; export type TaskAttemptState = { execution_state: ExecutionState, has_changes: boolean, has_setup_script: boolean, setup_process_id: string | null, coding_agent_process_id: string | null, };