From 8c662e7af40abb17391cab0df2f90a2492ae96c7 Mon Sep 17 00:00:00 2001 From: viettranx Date: Tue, 17 Mar 2026 14:19:29 +0700 Subject: [PATCH] fix(teams): hide progress bar on completed tasks Clear progress_percent in DB on all terminal transitions (complete, cancel, fail, approve, reject). Also hide progress bar in UI for terminal statuses as a safety net (kanban, list, detail dialog). --- internal/store/pg/teams_tasks_lifecycle.go | 8 +++++++- ui/web/src/pages/teams/board/kanban-card.tsx | 2 +- .../src/pages/teams/task-sections/task-detail-dialog.tsx | 2 +- ui/web/src/pages/teams/task-sections/task-list.tsx | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/store/pg/teams_tasks_lifecycle.go b/internal/store/pg/teams_tasks_lifecycle.go index 4e55aaa8..d474eeee 100644 --- a/internal/store/pg/teams_tasks_lifecycle.go +++ b/internal/store/pg/teams_tasks_lifecycle.go @@ -65,6 +65,7 @@ func (s *PGTeamStore) CompleteTask(ctx context.Context, taskID, teamID uuid.UUID res, err := tx.ExecContext(ctx, `UPDATE team_tasks SET status = $1, result = $2, locked_at = NULL, lock_expires_at = NULL, followup_at = NULL, followup_count = 0, followup_message = NULL, followup_channel = NULL, followup_chat_id = NULL, + progress_percent = NULL, updated_at = $3 WHERE id = $4 AND status = $5 AND team_id = $6`, store.TeamTaskStatusCompleted, result, time.Now(), @@ -98,6 +99,7 @@ func (s *PGTeamStore) CancelTask(ctx context.Context, taskID, teamID uuid.UUID, res, err := tx.ExecContext(ctx, `UPDATE team_tasks SET status = $1, result = $2, locked_at = NULL, lock_expires_at = NULL, followup_at = NULL, followup_count = 0, followup_message = NULL, followup_channel = NULL, followup_chat_id = NULL, + progress_percent = NULL, updated_at = $3 WHERE id = $4 AND status NOT IN ($5, $1) AND team_id = $6`, store.TeamTaskStatusCancelled, reason, now, @@ -131,6 +133,7 @@ func (s *PGTeamStore) FailTask(ctx context.Context, taskID, teamID uuid.UUID, er res, err := tx.ExecContext(ctx, `UPDATE team_tasks SET status = $1, result = $2, locked_at = NULL, lock_expires_at = NULL, followup_at = NULL, followup_count = 0, followup_message = NULL, followup_channel = NULL, followup_chat_id = NULL, + progress_percent = NULL, updated_at = $3 WHERE id = $4 AND status = $5 AND team_id = $6`, store.TeamTaskStatusFailed, "FAILED: "+errMsg, now, @@ -163,7 +166,8 @@ func (s *PGTeamStore) FailPendingTask(ctx context.Context, taskID, teamID uuid.U now := time.Now() res, err := tx.ExecContext(ctx, - `UPDATE team_tasks SET status = $1, result = $2, locked_at = NULL, lock_expires_at = NULL, updated_at = $3 + `UPDATE team_tasks SET status = $1, result = $2, locked_at = NULL, lock_expires_at = NULL, + progress_percent = NULL, updated_at = $3 WHERE id = $4 AND status IN ($5, $6) AND team_id = $7`, store.TeamTaskStatusFailed, "FAILED: "+errMsg, now, taskID, store.TeamTaskStatusPending, store.TeamTaskStatusBlocked, teamID, @@ -230,6 +234,7 @@ func (s *PGTeamStore) ApproveTask(ctx context.Context, taskID, teamID uuid.UUID, res, err := tx.ExecContext(ctx, `UPDATE team_tasks SET status = $1, locked_at = NULL, lock_expires_at = NULL, followup_at = NULL, followup_count = 0, followup_message = NULL, followup_channel = NULL, followup_chat_id = NULL, + progress_percent = NULL, updated_at = $2 WHERE id = $3 AND status = $4 AND team_id = $5`, store.TeamTaskStatusCompleted, now, @@ -263,6 +268,7 @@ func (s *PGTeamStore) RejectTask(ctx context.Context, taskID, teamID uuid.UUID, res, err := tx.ExecContext(ctx, `UPDATE team_tasks SET status = $1, result = $2, locked_at = NULL, lock_expires_at = NULL, followup_at = NULL, followup_count = 0, followup_message = NULL, followup_channel = NULL, followup_chat_id = NULL, + progress_percent = NULL, updated_at = $3 WHERE id = $4 AND status = $5 AND team_id = $6`, store.TeamTaskStatusCancelled, reason, now, diff --git a/ui/web/src/pages/teams/board/kanban-card.tsx b/ui/web/src/pages/teams/board/kanban-card.tsx index 31b48eda..d0c1505a 100644 --- a/ui/web/src/pages/teams/board/kanban-card.tsx +++ b/ui/web/src/pages/teams/board/kanban-card.tsx @@ -104,7 +104,7 @@ export const KanbanCard = memo(function KanbanCard({ task, isTeamV2, emojiLookup - {isTeamV2 && task.progress_percent != null && task.progress_percent > 0 && ( + {isTeamV2 && task.progress_percent != null && task.progress_percent > 0 && !isTerminalStatus(task.status) && (
diff --git a/ui/web/src/pages/teams/task-sections/task-detail-dialog.tsx b/ui/web/src/pages/teams/task-sections/task-detail-dialog.tsx index 44f26326..e8b22542 100644 --- a/ui/web/src/pages/teams/task-sections/task-detail-dialog.tsx +++ b/ui/web/src/pages/teams/task-sections/task-detail-dialog.tsx @@ -121,7 +121,7 @@ export function TaskDetailDialog({ )} {/* Progress bar (V2) */} - {isTeamV2 && task.progress_percent != null && task.progress_percent > 0 && ( + {isTeamV2 && task.progress_percent != null && task.progress_percent > 0 && !isTerminalStatus(task.status) && (
{t("tasks.detail.progress")} diff --git a/ui/web/src/pages/teams/task-sections/task-list.tsx b/ui/web/src/pages/teams/task-sections/task-list.tsx index 47c38796..f7bf81c3 100644 --- a/ui/web/src/pages/teams/task-sections/task-list.tsx +++ b/ui/web/src/pages/teams/task-sections/task-list.tsx @@ -80,7 +80,7 @@ export function TaskList({ {task.task_type && task.task_type !== "general" && ( {task.task_type} )} - {isTeamV2 && task.progress_percent != null && task.progress_percent > 0 && ( + {isTeamV2 && task.progress_percent != null && task.progress_percent > 0 && !isTerminalStatus(task.status) && (