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) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-01 21:03:56 +02:00
parent 8409f8a8a2
commit e94775de25

View file

@ -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<string, unknown>) ?? {};
const updated = await taskCollection.update(id, {
metadata: { labelIds },
metadata: { ...existingMeta, labelIds },
} as Partial<LocalTask>);
if (updated) {
return toTask(updated);