Skip to content

Commit 682315c

Browse files
authored
Fix progress display off-by-one issue (#23)
1 parent bacb0de commit 682315c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/renderer/components/TaskDetail.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,12 @@ export function TaskDetail({ task: initialTask }: TaskDetailProps) {
303303
<DataList.Label>Progress</DataList.Label>
304304
<DataList.Value>
305305
<Text size="2">
306-
{progress.completed_steps ?? 0}/
306+
{(progress.completed_steps ?? 0) + 1}/
307307
{typeof progress.total_steps === "number"
308308
? progress.total_steps
309309
: "-"}
310-
{typeof progress.progress_percentage === "number" &&
311-
` · ${Math.round(progress.progress_percentage)}%`}
310+
{typeof progress.total_steps === "number" &&
311+
` · ${Math.round((((progress.completed_steps ?? 0) + 1) / progress.total_steps) * 100)}%`}
312312
{progress.current_step && ` · ${progress.current_step}`}
313313
</Text>
314314
</DataList.Value>

src/renderer/stores/taskExecutionStore.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ const createProgressSignature = (progress: AgentTaskProgress): string =>
2828

2929
const formatProgressLog = (progress: AgentTaskProgress): string => {
3030
const statusLabel = progress.status?.replace(/_/g, " ") ?? "in progress";
31-
const completed =
32-
typeof progress.completed_steps === "number" ? progress.completed_steps : 0;
31+
const currentStep =
32+
typeof progress.completed_steps === "number"
33+
? progress.completed_steps + 1
34+
: 1;
3335
const total =
3436
typeof progress.total_steps === "number" && progress.total_steps >= 0
3537
? progress.total_steps
@@ -40,10 +42,10 @@ const formatProgressLog = (progress: AgentTaskProgress): string => {
4042
? progress.current_step
4143
: "-";
4244
const percentage =
43-
typeof progress.progress_percentage === "number"
44-
? ` ${Math.round(progress.progress_percentage)}%`
45+
typeof progress.total_steps === "number" && progress.total_steps > 0
46+
? ` ${Math.round((currentStep / progress.total_steps) * 100)}%`
4547
: "";
46-
return `📊 Progress: ${statusLabel} | step=${step} (${completed}/${total})${percentage}`;
48+
return `📊 Progress: ${statusLabel} | step=${step} (${currentStep}/${total})${percentage}`;
4749
};
4850

4951
interface TaskExecutionState {

0 commit comments

Comments
 (0)