feat(web): humanize task and session state labels
Mobile task sheet was rendering raw enum values like "IN_PROGRESS". Add formatTaskStateLabel + formatTaskSessionStateLabel helpers and use them in the mobile task sheet badge. Session state badge in the new mobile sessions picker also reuses the formatter.
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
import { Badge } from "@kandev/ui/badge";
|
||||
import { IconArrowRight, IconEdit, IconTrash } from "@tabler/icons-react";
|
||||
import type { Task } from "@/components/kanban-card";
|
||||
import { formatTaskStateLabel } from "@/lib/ui/state-labels";
|
||||
|
||||
type MobileTaskSheetProps = {
|
||||
task: Task | null;
|
||||
@@ -42,7 +43,7 @@ export function MobileTaskSheet({
|
||||
)}
|
||||
<div className="flex items-center gap-2 mt-1">
|
||||
<Badge variant="secondary" className="text-xs">
|
||||
{task.state ?? "not_started"}
|
||||
{formatTaskStateLabel(task.state)}
|
||||
</Badge>
|
||||
</div>
|
||||
</DrawerHeader>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { TaskState, TaskSessionState } from "@/lib/types/http";
|
||||
|
||||
const TASK_STATE_LABELS: Record<TaskState, string> = {
|
||||
CREATED: "Created",
|
||||
SCHEDULING: "Scheduling",
|
||||
TODO: "To do",
|
||||
IN_PROGRESS: "In progress",
|
||||
REVIEW: "Review",
|
||||
BLOCKED: "Blocked",
|
||||
WAITING_FOR_INPUT: "Waiting for input",
|
||||
COMPLETED: "Completed",
|
||||
FAILED: "Failed",
|
||||
CANCELLED: "Cancelled",
|
||||
};
|
||||
|
||||
const TASK_SESSION_STATE_LABELS: Record<TaskSessionState, string> = {
|
||||
CREATED: "Created",
|
||||
STARTING: "Starting",
|
||||
RUNNING: "Running",
|
||||
WAITING_FOR_INPUT: "Waiting for input",
|
||||
COMPLETED: "Completed",
|
||||
FAILED: "Failed",
|
||||
CANCELLED: "Cancelled",
|
||||
};
|
||||
|
||||
export function formatTaskStateLabel(state: TaskState | null | undefined): string {
|
||||
if (!state) return "Not started";
|
||||
return TASK_STATE_LABELS[state] ?? state;
|
||||
}
|
||||
|
||||
export function formatTaskSessionStateLabel(state: TaskSessionState | null | undefined): string {
|
||||
if (!state) return "";
|
||||
return TASK_SESSION_STATE_LABELS[state] ?? state;
|
||||
}
|
||||
Reference in New Issue
Block a user