Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

fix: task detail crash on hand-written cards - always normalize through parseTasks

Gulum03fa8e961783
diff --git a/src/renderer/src/components/TaskDetailOverlay.tsx b/src/renderer/src/components/TaskDetailOverlay.tsx
index 1e6651ab..a0e562ac 100644
--- a/src/renderer/src/components/TaskDetailOverlay.tsx
+++ b/src/renderer/src/components/TaskDetailOverlay.tsx
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { useStore } from '@/store/store';
-import { TaskDetail, type HiveTask } from './TasksKanban';
+import { TaskDetail, parseTasks, type HiveTask } from './TasksKanban';
/**
* App-wide host for the task detail: whoever calls store.openTaskDetail(id) —
@@ -11,13 +11,6 @@ import { TaskDetail, type HiveTask } from './TasksKanban';
const POLL_MS = 5000;
-function parse(raw: unknown): HiveTask[] {
- const list = (raw && typeof raw === 'object' && Array.isArray((raw as { tasks?: unknown }).tasks))
- ? (raw as { tasks: HiveTask[] }).tasks
- : [];
- return list.filter((t) => !!t && typeof t === 'object' && typeof (t as { id?: unknown }).id === 'string');
-}
-
export function TaskDetailOverlay() {
const taskDetailId = useStore((s) => s.taskDetailId);
const closeTaskDetail = useStore((s) => s.closeTaskDetail);
@@ -27,7 +20,10 @@ export function TaskDetailOverlay() {
const timer = useRef<ReturnType<typeof setInterval> | null>(null);
const refresh = useCallback(async () => {
- try { setTasks(parse(await window.cth.hiveTasks())); } catch { /* keep last good */ }
+ // parseTasks NORMALIZES (the ledger is a hand-written file; cards may lack
+ // dependsOn/priority/etc.) — a raw card without dependsOn crashed the
+ // detail once. Never feed TaskDetail unparsed ledger entries.
+ try { setTasks(parseTasks(await window.cth.hiveTasks())); } catch { /* keep last good */ }
}, []);
useEffect(() => {
diff --git a/src/renderer/src/components/TasksKanban.tsx b/src/renderer/src/components/TasksKanban.tsx
index 0eeeeb5a..a1ad2b8e 100644
--- a/src/renderer/src/components/TasksKanban.tsx
+++ b/src/renderer/src/components/TasksKanban.tsx
@@ -66,8 +66,11 @@ function stableId(seed: string): string {
return `t-${(h >>> 0).toString(36)}`;
}
-/** Normalize whatever hive:tasks returns into a typed task array. */
-function parseTasks(raw: unknown): HiveTask[] {
+/** Normalize whatever hive:tasks returns into a typed task array. The god
+ * writes this file by hand — every field except the shape itself is optional
+ * in practice, so EVERY consumer must go through this (exported for the
+ * detail overlay; a raw card without dependsOn once crashed it). */
+export function parseTasks(raw: unknown): HiveTask[] {
const list = (raw && typeof raw === 'object' && Array.isArray((raw as { tasks?: unknown }).tasks))
? (raw as { tasks: unknown[] }).tasks
: [];
@@ -258,7 +261,9 @@ export function TaskDetail({ task, all, assigneeName, onMove, onAssign, onClose
onClose: () => void;
}) {
const col = COLUMNS.find((c) => c.key === task.status) ?? COLUMNS[0];
- const deps = task.dependsOn
+ // Belt + suspenders: parseTasks normalizes these, but the ledger is a
+ // hand-written file — never trust a card's shape at the point of use.
+ const deps = (task.dependsOn ?? [])
.map((id) => all.find((t) => t.id === id))
.filter((t): t is HiveTask => !!t);
const created = new Date(task.createdAt);