summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-21 14:32:36 +0900
committerAdam Malczewski <[email protected]>2026-06-21 14:32:36 +0900
commit90ab92626555bb6a764a3c15fc03ac3e36966226 (patch)
tree1cfcd0127281cefb3476b102cad5f4ddfcd53927
parentb12acb26276fa8539d312b575218d2fcb6e9024e (diff)
downloaddispatch-web-90ab92626555bb6a764a3c15fc03ac3e36966226.tar.gz
dispatch-web-90ab92626555bb6a764a3c15fc03ac3e36966226.zip
refactor(todo): drop priority field — keep the tool simple
Backend removed priority from TodoItem; FE parser + renderer updated to match (status-only: pending/in_progress/completed/cancelled).
-rw-r--r--src/features/surface-host/logic/todo.test.ts47
-rw-r--r--src/features/surface-host/logic/todo.ts11
-rw-r--r--src/features/surface-host/ui/TodoList.svelte11
3 files changed, 16 insertions, 53 deletions
diff --git a/src/features/surface-host/logic/todo.test.ts b/src/features/surface-host/logic/todo.test.ts
index d310345..225ecde 100644
--- a/src/features/surface-host/logic/todo.test.ts
+++ b/src/features/surface-host/logic/todo.test.ts
@@ -1,26 +1,25 @@
import { describe, expect, it } from "vitest";
import { parseTodoPayload, type TodoItem } from "./todo";
-const item = (
- content: string,
- status: TodoItem["status"] = "pending",
- priority: TodoItem["priority"] = "medium",
-): TodoItem => ({ content, status, priority });
+const item = (content: string, status: TodoItem["status"] = "pending"): TodoItem => ({
+ content,
+ status,
+});
describe("parseTodoPayload", () => {
it("parses a well-formed payload with items", () => {
const data = parseTodoPayload({
todos: [
- item("Write tests", "in_progress", "high"),
- item("Ship it", "pending", "medium"),
- item("Read docs", "completed", "low"),
+ item("Write tests", "in_progress"),
+ item("Ship it", "pending"),
+ item("Read docs", "completed"),
],
});
expect(data).toEqual({
todos: [
- item("Write tests", "in_progress", "high"),
- item("Ship it", "pending", "medium"),
- item("Read docs", "completed", "low"),
+ item("Write tests", "in_progress"),
+ item("Ship it", "pending"),
+ item("Read docs", "completed"),
],
});
});
@@ -30,9 +29,7 @@ describe("parseTodoPayload", () => {
});
it("preserves item order", () => {
- const data = parseTodoPayload({
- todos: [item("a"), item("b"), item("c")],
- });
+ const data = parseTodoPayload({ todos: [item("a"), item("b"), item("c")] });
expect(data?.todos.map((t) => t.content)).toEqual(["a", "b", "c"]);
});
@@ -53,17 +50,6 @@ describe("parseTodoPayload", () => {
]);
});
- it("accepts all three priority values", () => {
- const data = parseTodoPayload({
- todos: [
- item("h", "pending", "high"),
- item("m", "pending", "medium"),
- item("l", "pending", "low"),
- ],
- });
- expect(data?.todos.map((t) => t.priority)).toEqual(["high", "medium", "low"]);
- });
-
it.each([
["null", null],
["a number", 7],
@@ -71,15 +57,10 @@ describe("parseTodoPayload", () => {
["missing todos key", { foo: [] }],
["todos not an array", { todos: "x" }],
["entry not an object", { todos: ["x"] }],
- ["entry missing content", { todos: [{ status: "pending", priority: "low" }] }],
- [
- "entry with non-string content",
- { todos: [{ content: 1, status: "pending", priority: "low" }] },
- ],
- ["entry missing status", { todos: [{ content: "x", priority: "low" }] }],
+ ["entry missing content", { todos: [{ status: "pending" }] }],
+ ["entry with non-string content", { todos: [{ content: 1, status: "pending" }] }],
+ ["entry missing status", { todos: [{ content: "x" }] }],
["entry with invalid status", { todos: [item("x", "done" as never)] }],
- ["entry missing priority", { todos: [{ content: "x", status: "pending" }] }],
- ["entry with invalid priority", { todos: [item("x", "pending", "urgent" as never)] }],
])("returns null for invalid payload: %s", (_label, payload) => {
expect(parseTodoPayload(payload)).toBeNull();
});
diff --git a/src/features/surface-host/logic/todo.ts b/src/features/surface-host/logic/todo.ts
index b8e027b..e442e78 100644
--- a/src/features/surface-host/logic/todo.ts
+++ b/src/features/surface-host/logic/todo.ts
@@ -14,12 +14,10 @@
* (the model hasn't created a list / cleared it); the caller hides the panel.
*/
export type TodoStatus = "pending" | "in_progress" | "completed" | "cancelled";
-export type TodoPriority = "high" | "medium" | "low";
export interface TodoItem {
readonly content: string;
readonly status: TodoStatus;
- readonly priority: TodoPriority;
}
export interface TodoData {
@@ -27,18 +25,11 @@ export interface TodoData {
}
const STATUSES = new Set<string>(["pending", "in_progress", "completed", "cancelled"]);
-const PRIORITIES = new Set<string>(["high", "medium", "low"]);
function isTodoItem(v: unknown): v is TodoItem {
if (typeof v !== "object" || v === null) return false;
const o = v as Record<string, unknown>;
- return (
- typeof o.content === "string" &&
- typeof o.status === "string" &&
- STATUSES.has(o.status) &&
- typeof o.priority === "string" &&
- PRIORITIES.has(o.priority)
- );
+ return typeof o.content === "string" && typeof o.status === "string" && STATUSES.has(o.status);
}
export function parseTodoPayload(payload: unknown): TodoData | null {
diff --git a/src/features/surface-host/ui/TodoList.svelte b/src/features/surface-host/ui/TodoList.svelte
index ca49f34..b7b2183 100644
--- a/src/features/surface-host/ui/TodoList.svelte
+++ b/src/features/surface-host/ui/TodoList.svelte
@@ -1,15 +1,9 @@
<script lang="ts">
- import { parseTodoPayload, type TodoPriority, type TodoStatus } from "../logic/todo";
+ import { parseTodoPayload } from "../logic/todo";
let { payload }: { readonly payload: unknown } = $props();
const data = $derived(parseTodoPayload(payload));
-
- const priorityDot: Record<TodoPriority, string> = {
- high: "bg-error",
- medium: "bg-warning",
- low: "bg-base-content/30",
- };
</script>
{#if data !== null && data.todos.length > 0}
@@ -61,9 +55,6 @@
>
{todo.content}
</span>
-
- <!-- Priority dot -->
- <span class="mt-1 h-2 w-2 shrink-0 rounded-full {priorityDot[todo.priority]}"></span>
</li>
{/each}
</ul>