From e94775de258b364b3ca52f4aa8a6bac2f0378890 Mon Sep 17 00:00:00 2001 From: Till JS Date: Wed, 1 Apr 2026 21:03:56 +0200 Subject: [PATCH] fix(todo): persist labelIds on task creation and merge metadata on label update - createTask: store labelIds in metadata when provided (was silently ignored) - updateLabels: read existing metadata first and merge, instead of overwriting the entire metadata object (was destroying assignee, storypoints, etc.) Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/todo/apps/web/src/lib/stores/tasks.svelte.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/todo/apps/web/src/lib/stores/tasks.svelte.ts b/apps/todo/apps/web/src/lib/stores/tasks.svelte.ts index fccea4c30..7e0ce49b3 100644 --- a/apps/todo/apps/web/src/lib/stores/tasks.svelte.ts +++ b/apps/todo/apps/web/src/lib/stores/tasks.svelte.ts @@ -45,6 +45,7 @@ export const tasksStore = { order: count, recurrenceRule: data.recurrenceRule ?? null, subtasks: data.subtasks, + ...(data.labelIds?.length && { metadata: { labelIds: data.labelIds } }), }; const inserted = await taskCollection.insert(newLocal); @@ -159,8 +160,10 @@ export const tasksStore = { return withErrorHandling( setError, async () => { + const existing = await taskCollection.get(id); + const existingMeta = (existing?.metadata as Record) ?? {}; const updated = await taskCollection.update(id, { - metadata: { labelIds }, + metadata: { ...existingMeta, labelIds }, } as Partial); if (updated) { return toTask(updated);