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(tasks): stable fallback task id + validate writeTasks IPC input

Chaitanya Giri81a495c220a8
diff --git a/src/main/index.ts b/src/main/index.ts
index 82a7841e..02966d0e 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -382,7 +382,9 @@ ipcMain.handle('hive:send', (_evt, partial: Partial<HiveMessage>, from: unknown)
const msg = hive.send(partial ?? {}, typeof from === 'string' ? from : 'system');
return { ok: true, message: msg };
});
-ipcMain.handle('hive:writeTasks', (_evt, tasks) => {
+ipcMain.handle('hive:writeTasks', (_evt, tasks: unknown) => {
+ if (!Array.isArray(tasks)) return { ok: false, error: 'invalid tasks' };
+ if (!hive.enabled()) return { ok: false, error: 'hive disabled (no harnessHome)' };
hive.writeTasks(tasks as HiveTask[]);
return { ok: true };
});
diff --git a/src/renderer/src/components/TasksKanban.tsx b/src/renderer/src/components/TasksKanban.tsx
index 67994bb5..eff31ef8 100644
--- a/src/renderer/src/components/TasksKanban.tsx
+++ b/src/renderer/src/components/TasksKanban.tsx
@@ -35,6 +35,16 @@ function shortId(): string {
return `t-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
}
+/** Deterministic fallback id derived from a task's content (djb2 → base36).
+ * Used for tasks lacking a valid string id so re-parsing tasks.json on every
+ * 5s poll yields the SAME id — no React key churn / card remount. Unlike
+ * shortId() (random, for brand-new tasks), this never changes across polls. */
+function stableId(seed: string): string {
+ let h = 5381;
+ for (let i = 0; i < seed.length; i++) h = (((h << 5) + h) ^ seed.charCodeAt(i)) | 0;
+ return `t-${(h >>> 0).toString(36)}`;
+}
+
/** Normalize whatever hive:tasks returns into a typed task array. */
function parseTasks(raw: unknown): HiveTask[] {
const list = (raw && typeof raw === 'object' && Array.isArray((raw as { tasks?: unknown }).tasks))
@@ -42,8 +52,10 @@ function parseTasks(raw: unknown): HiveTask[] {
: [];
return list
.filter((t): t is Record<string, unknown> => !!t && typeof t === 'object')
- .map((t) => ({
- id: typeof t.id === 'string' ? t.id : shortId(),
+ .map((t, i) => ({
+ id: typeof t.id === 'string' && t.id
+ ? t.id
+ : stableId(`${typeof t.title === 'string' ? t.title : ''}|${typeof t.createdAt === 'string' ? t.createdAt : ''}|${i}`),
title: typeof t.title === 'string' ? t.title : '(untitled)',
description: typeof t.description === 'string' ? t.description : undefined,
assignee: typeof t.assignee === 'string' ? t.assignee : undefined,