fix(tasks): preserve task order when carrying over to next day

Append new tasks after existing ones in TODAY_TAG.taskIds instead of
prepending, so manually sorted tasks retain their order across days.

Closes #6750
This commit is contained in:
Johannes Millan 2026-03-06 13:43:16 +01:00
parent 5b9f3f8278
commit a2d75478fb
3 changed files with 12 additions and 12 deletions

View file

@ -229,7 +229,7 @@ describe('taskSharedSchedulingMetaReducer', () => {
});
describe('planTasksForToday action', () => {
it('should add new tasks to the top of Today tag', () => {
it('should append new tasks after existing tasks in Today tag', () => {
const testState = createStateWithExistingTasks([], [], [], ['existing-task']);
const action = TaskSharedActions.planTasksForToday({
taskIds: ['task1', 'task2'],
@ -238,14 +238,14 @@ describe('taskSharedSchedulingMetaReducer', () => {
metaReducer(testState, action);
expectStateUpdate(
expectTagUpdate('TODAY', { taskIds: ['task1', 'task2', 'existing-task'] }),
expectTagUpdate('TODAY', { taskIds: ['existing-task', 'task1', 'task2'] }),
action,
mockReducer,
testState,
);
});
it('should not add tasks that are already in Today tag', () => {
it('should preserve existing order when adding new tasks', () => {
const testState = createStateWithExistingTasks(
[],
[],
@ -259,7 +259,7 @@ describe('taskSharedSchedulingMetaReducer', () => {
metaReducer(testState, action);
expectStateUpdate(
expectTagUpdate('TODAY', { taskIds: ['task2', 'task1', 'existing-task'] }),
expectTagUpdate('TODAY', { taskIds: ['task1', 'existing-task', 'task2'] }),
action,
mockReducer,
testState,
@ -275,7 +275,7 @@ describe('taskSharedSchedulingMetaReducer', () => {
metaReducer(testState, action);
expectStateUpdate(
expectTagUpdate('TODAY', { taskIds: ['task2', 'parent-task'] }),
expectTagUpdate('TODAY', { taskIds: ['parent-task', 'task2'] }),
action,
mockReducer,
testState,
@ -363,7 +363,7 @@ describe('taskSharedSchedulingMetaReducer', () => {
// subtask1 should NOT be added (parent1 is in Today)
// subtask2 SHOULD be added (parent2 is not in Today)
expectStateUpdate(
expectTagUpdate('TODAY', { taskIds: ['subtask2', 'parent1'] }),
expectTagUpdate('TODAY', { taskIds: ['parent1', 'subtask2'] }),
action,
mockReducer,
testState,

View file

@ -248,7 +248,7 @@ const handlePlanTasksForToday = (
{
id: TODAY_TAG.id,
changes: {
taskIds: unique([...newTasksForToday, ...todayTag.taskIds]),
taskIds: unique([...todayTag.taskIds, ...newTasksForToday]),
},
},
]);

View file

@ -1866,7 +1866,7 @@ describe('taskSharedMetaReducer', () => {
});
describe('planTasksForToday action', () => {
it('should add new tasks to the top of Today tag', () => {
it('should append new tasks after existing tasks in Today tag', () => {
const testState = createStateWithExistingTasks([], [], [], ['existing-task']);
const action = TaskSharedActions.planTasksForToday({
taskIds: ['task1', 'task2'],
@ -1874,13 +1874,13 @@ describe('taskSharedMetaReducer', () => {
});
expectStateUpdate(
expectTagUpdate('TODAY', { taskIds: ['task1', 'task2', 'existing-task'] }),
expectTagUpdate('TODAY', { taskIds: ['existing-task', 'task1', 'task2'] }),
action,
testState,
);
});
it('should not add tasks that are already in Today tag', () => {
it('should preserve existing order when adding new tasks', () => {
const testState = createStateWithExistingTasks(
[],
[],
@ -1893,7 +1893,7 @@ describe('taskSharedMetaReducer', () => {
});
expectStateUpdate(
expectTagUpdate('TODAY', { taskIds: ['task2', 'task1', 'existing-task'] }),
expectTagUpdate('TODAY', { taskIds: ['task1', 'existing-task', 'task2'] }),
action,
testState,
);
@ -1907,7 +1907,7 @@ describe('taskSharedMetaReducer', () => {
});
expectStateUpdate(
expectTagUpdate('TODAY', { taskIds: ['task2', 'parent-task'] }),
expectTagUpdate('TODAY', { taskIds: ['parent-task', 'task2'] }),
action,
testState,
);