From 0ca84d28c6d358591582b5d61ef66ed0e266e260 Mon Sep 17 00:00:00 2001 From: Claudomator Agent Date: Mon, 6 Jul 2026 01:38:50 +0000 Subject: fix(web): reviewer findings on Tasks board column model (task 1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Finding 1 (Important): replace inline per-column sort comparators in groupTasksByColumn with calls to the existing sortTasksByDate(tasks, descend) helper. The old inline code fell back to epoch 0 for missing created_at, sorting dateless tasks FIRST in ascending columns — diverging from the rest of the codebase's convention (sortTasksByDate puts them LAST). Add two new tests asserting that a task with no created_at sorts LAST in both an ascending column (queue) and a descending column (interrupted). Finding 2 (Important): revert web/test/tab-persistence.test.mjs — the two 'stories' assertions introduced in 54be094 were out of Task 1's scope and belong to Task 2. Restore the original 'queue' assertions so commit messages accurately reflect their contents; Task 2 will re-apply the fix intentionally. Finding 3 (Minor): add the missing state-list uniqueness assertion to the 'every column key is unique' test: assert.equal(new Set(allStates).size, allStates.length) so a state appearing in two columns is caught. Co-Authored-By: Claude Sonnet 4.6 --- web/app.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'web/app.js') diff --git a/web/app.js b/web/app.js index 9cd3100..c192d20 100644 --- a/web/app.js +++ b/web/app.js @@ -3377,16 +3377,17 @@ export function columnForTaskState(state) { // interrupted — newest-first (most recent failure is most urgent) // done — newest-first (most recently completed is most relevant) // running — newest-first (new-but-inconsequential default) -const TASK_COLUMN_SORT = { - queue: (a, b) => new Date(a.created_at || 0) - new Date(b.created_at || 0), - running: (a, b) => new Date(b.created_at || 0) - new Date(a.created_at || 0), - ready: (a, b) => new Date(a.created_at || 0) - new Date(b.created_at || 0), - interrupted: (a, b) => new Date(b.created_at || 0) - new Date(a.created_at || 0), - done: (a, b) => new Date(b.created_at || 0) - new Date(a.created_at || 0), +// Tasks with a missing created_at sort LAST in any direction (per sortTasksByDate). +const TASK_COLUMN_DESCEND = { + queue: false, + running: true, + ready: false, + interrupted: true, + done: true, }; // groupTasksByColumn returns { [columnKey]: task[] }, each sub-array sorted -// per the per-column sort direction above. +// per the per-column sort direction above via the shared sortTasksByDate helper. export function groupTasksByColumn(tasks) { const groups = {}; for (const col of TASK_COLUMNS) groups[col.key] = []; @@ -3396,8 +3397,7 @@ export function groupTasksByColumn(tasks) { groups[key].push(t); } for (const col of TASK_COLUMNS) { - const cmp = TASK_COLUMN_SORT[col.key]; - if (cmp) groups[col.key].sort(cmp); + groups[col.key] = sortTasksByDate(groups[col.key], TASK_COLUMN_DESCEND[col.key] ?? false); } return groups; } -- cgit v1.2.3