Skip to content

Commit 6cde243

Browse files
committed
status casing + sorting fix
1 parent ead49ea commit 6cde243

File tree

3 files changed

+53
-13
lines changed

3 files changed

+53
-13
lines changed

src/renderer/components/tasks/TaskItem.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function TaskItemComponent({
6464
// Determine status: If PR exists, mark as completed, otherwise use latest_run status
6565
const prUrl = task.latest_run?.output?.pr_url as string | undefined;
6666
const hasPR = !!prUrl;
67-
const status = hasPR ? "completed" : task.latest_run?.status || "Backlog";
67+
const status = hasPR ? "completed" : task.latest_run?.status || "backlog";
6868

6969
const handleOpenPR = (e: React.MouseEvent) => {
7070
e.stopPropagation();
@@ -81,7 +81,15 @@ function TaskItemComponent({
8181
failed: "red",
8282
in_progress: "blue",
8383
started: "amber",
84-
Backlog: "gray",
84+
backlog: "gray",
85+
};
86+
87+
const statusDisplayMap: Record<string, string> = {
88+
completed: "Completed",
89+
failed: "Failed",
90+
in_progress: "In progress",
91+
started: "Started",
92+
backlog: "Backlog",
8593
};
8694

8795
const handleDragStart = (e: React.DragEvent) => {
@@ -226,7 +234,8 @@ function TaskItemComponent({
226234
size="1"
227235
style={{ flexShrink: 0 }}
228236
>
229-
{status}
237+
{statusDisplayMap[status] ||
238+
status.charAt(0).toUpperCase() + status.slice(1)}
230239
</Badge>
231240

232241
<Flex

src/renderer/components/tasks/hooks/useTaskFiltering.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ export function useTaskFiltering(
99
filter: string,
1010
) {
1111
return useMemo(() => {
12+
// Helper to get computed status (same logic as TaskItem and useTaskGrouping)
13+
const getTaskStatus = (task: Task): string => {
14+
const hasPR = task.latest_run?.output?.pr_url;
15+
return hasPR ? "completed" : task.latest_run?.status || "backlog";
16+
};
17+
18+
// Status order for sorting
19+
const statusOrder = [
20+
"failed",
21+
"in_progress",
22+
"started",
23+
"completed",
24+
"backlog",
25+
];
26+
1227
// Sort tasks
1328
const orderedTasks = [...tasks].sort((a, b) => {
1429
let compareResult = 0;
@@ -18,9 +33,24 @@ export function useTaskFiltering(
1833
compareResult =
1934
new Date(a.created_at).getTime() - new Date(b.created_at).getTime();
2035
break;
21-
case "status":
22-
compareResult = (a.status || "").localeCompare(b.status || "");
36+
case "status": {
37+
const statusA = getTaskStatus(a);
38+
const statusB = getTaskStatus(b);
39+
const indexA = statusOrder.indexOf(statusA);
40+
const indexB = statusOrder.indexOf(statusB);
41+
42+
// Use index-based comparison if both found, otherwise alphabetical
43+
if (indexA !== -1 && indexB !== -1) {
44+
compareResult = indexA - indexB;
45+
} else if (indexA !== -1) {
46+
compareResult = -1;
47+
} else if (indexB !== -1) {
48+
compareResult = 1;
49+
} else {
50+
compareResult = statusA.localeCompare(statusB);
51+
}
2352
break;
53+
}
2454
case "title":
2555
compareResult = a.title.localeCompare(b.title);
2656
break;

src/renderer/components/tasks/hooks/useTaskGrouping.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export function useTaskGrouping(
6262

6363
// Sort groups with specific ordering for status groups
6464
// Priority: action needed > in progress > completed > backlog
65+
// Note: Status values are lowercase from TaskRun, except "Backlog" which is the fallback
6566
const statusOrder = [
6667
"failed",
6768
"in_progress",
@@ -76,14 +77,7 @@ export function useTaskGrouping(
7677
tasks,
7778
}))
7879
.sort((a, b) => {
79-
const aIsEmpty = a.name.startsWith("No ");
80-
const bIsEmpty = b.name.startsWith("No ");
81-
82-
// Empty groups always go to bottom
83-
if (aIsEmpty && !bIsEmpty) return 1;
84-
if (!aIsEmpty && bIsEmpty) return -1;
85-
86-
// If grouping by status, use status order
80+
// If grouping by status, use status order first
8781
if (groupBy === "status") {
8882
const aIndex = statusOrder.indexOf(a.name);
8983
const bIndex = statusOrder.indexOf(b.name);
@@ -95,6 +89,13 @@ export function useTaskGrouping(
9589
if (bIndex !== -1) return 1;
9690
}
9791

92+
const aIsEmpty = a.name.startsWith("No ");
93+
const bIsEmpty = b.name.startsWith("No ");
94+
95+
// Empty groups always go to bottom
96+
if (aIsEmpty && !bIsEmpty) return 1;
97+
if (!aIsEmpty && bIsEmpty) return -1;
98+
9899
return a.name.localeCompare(b.name);
99100
});
100101

0 commit comments

Comments
 (0)