Context
Surfaced by @tobiu after #12304 (tickets chunked tree, PR #12306) merged + theme rebuild. The chunk folders in a group render with their positional range labels out of sequence:
Tickets 1501-1509
Tickets 1401-1500
Tickets 601-700
Tickets 1301-1400
Tickets 401-500
Tickets 501-600
Expected: a sequential order (e.g. 1501-1509, 1401-1500, 1301-1400, … or ascending 1-100, 101-200, …). The same range scheme is in pulls PR #12307 (still open at filing), so this affects both chunked views.
The Problem
buildChunkedIndex sorts the chunk-folder nodes within a group by sortDate (the chunk's max item date), while treeNodeName labels each chunk folder positionally by chunk-number ((chunk-N − 1) * 100 + 1). When a chunk's max-date is not monotonic with its chunk-number — which happens because issue/PR updates bump older chunks' sortDate — the sortDate order diverges from the chunk-number order, so the positional labels appear scrambled.
There is also a deeper coupling: a positional label (Tickets 1501-1509) is only meaningful when the chunk folders are displayed in chunk-number order (so chunk-N really is the N-th 100-block). Sorting by date breaks that invariant regardless of the visible scramble.
The Architectural Reality
buildScripts/docs/index/tickets.mjs (~line 185) and buildScripts/docs/index/pulls.mjs (~line 186): groupChunks ... .sort((a, b) => new Date(b.sortDate || 0) - new Date(a.sortDate || 0) || a.id.localeCompare(b.id)) — sorts chunk folders by sortDate desc.
apps/portal/model/Ticket.mjs + apps/portal/model/Pull.mjs treeNodeName.calculate: positional range label (chunk-N − 1) * 100 + 1 .. + childCount.
discussions.mjs shares the same sortDate chunk sort but apps/portal/model/Discussion.mjs labels chunk folders with the raw title (title || id), NOT positional ranges — so it has no label/order mismatch bug. Reconciling its sort is deferred to the operator's discussions folder-naming + open/closed brainstorm (see Scope Correction).
The Fix
Sort the chunk-folder nodes by chunk-number (numeric, extracted from the chunk id/title chunk-(\d+)) so the positional range labels are sequential and meaningful. Apply to tickets.mjs + pulls.mjs buildChunkedIndex. (discussions.mjs deferred — see Scope Correction.)
Acceptance Criteria
Out of Scope (the cross-view chunk-folder UX brainstorm)
The direction (descending = newest 1501-… first, vs ascending = 1-100 first) and the broader label scheme (positional "1-100" vs the misreadable "Tickets " which looks like IDs; the open/closed-state indicator @tobiu raised for discussions) are the cross-view UX brainstorm to be decided + applied across tickets+pulls+discussions together. This ticket only fixes the out-of-sequence ordering bug. The implementation (PR #12310) picks descending for whole-tree newest-first consistency (release groups are semver-descending and leaves within a chunk are date/id-descending; descending chunk folders keep the whole tree newest-first) — a one-line reversal if the brainstorm prefers ascending.
Scope Correction (implemented in PR #12310)
discussions.mjs excluded. V-B-A of apps/portal/model/Discussion.mjs showed it labels chunk folders with the raw title (title || id), not positional ranges — so discussions has no label/order mismatch bug. Aligning its sort would change folder order for no fix benefit and pre-empt the operator's separate discussions folder-naming + open/closed brainstorm. AC2 + The Fix narrowed to tickets + pulls.
- Direction = descending (was tentatively noted as "ascending" at filing). Chosen for whole-tree newest-first consistency; brainstorm-reversible.
- Data not committed. Index JSON is regenerated by the data-sync pipeline (§critical_gate 3); PR #12310 ships generator code + regression tests only.
Related
- Parent epic #12204 (Portal news — chunked lazy-load tree).
- Regression from #12304 (PR #12306, merged) + present in #12305 (PR #12307, open) — both ship the
sortDate-sorted positional labels.
Origin Session ID: da9a6007-1250-4363-8c15-dff69eccb3be
Retrieval Hint: "portal chunked tree chunk folder order sortDate positional range label scramble"
Context
Surfaced by @tobiu after #12304 (tickets chunked tree, PR #12306) merged + theme rebuild. The chunk folders in a group render with their positional range labels out of sequence:
Expected: a sequential order (e.g.
1501-1509,1401-1500,1301-1400, … or ascending1-100,101-200, …). The same range scheme is in pulls PR #12307 (still open at filing), so this affects both chunked views.The Problem
buildChunkedIndexsorts the chunk-folder nodes within a group bysortDate(the chunk's max item date), whiletreeNodeNamelabels each chunk folder positionally by chunk-number ((chunk-N − 1) * 100 + 1). When a chunk's max-date is not monotonic with its chunk-number — which happens because issue/PR updates bump older chunks'sortDate— the sortDate order diverges from the chunk-number order, so the positional labels appear scrambled.There is also a deeper coupling: a positional label (
Tickets 1501-1509) is only meaningful when the chunk folders are displayed in chunk-number order (so chunk-N really is the N-th 100-block). Sorting by date breaks that invariant regardless of the visible scramble.The Architectural Reality
buildScripts/docs/index/tickets.mjs(~line 185) andbuildScripts/docs/index/pulls.mjs(~line 186):groupChunks ... .sort((a, b) => new Date(b.sortDate || 0) - new Date(a.sortDate || 0) || a.id.localeCompare(b.id))— sorts chunk folders bysortDatedesc.apps/portal/model/Ticket.mjs+apps/portal/model/Pull.mjstreeNodeName.calculate: positional range label(chunk-N − 1) * 100 + 1 .. + childCount.discussions.mjsshares the samesortDatechunk sort butapps/portal/model/Discussion.mjslabels chunk folders with the raw title (title || id), NOT positional ranges — so it has no label/order mismatch bug. Reconciling its sort is deferred to the operator's discussions folder-naming + open/closed brainstorm (see Scope Correction).The Fix
Sort the chunk-folder nodes by chunk-number (numeric, extracted from the chunk id/title
chunk-(\d+)) so the positional range labels are sequential and meaningful. Apply totickets.mjs+pulls.mjsbuildChunkedIndex. (discussions.mjsdeferred — see Scope Correction.)Acceptance Criteria
Out of Scope (the cross-view chunk-folder UX brainstorm)
The direction (descending = newest" which looks like IDs; the open/closed-state indicator @tobiu raised for discussions) are the cross-view UX brainstorm to be decided + applied across tickets+pulls+discussions together. This ticket only fixes the out-of-sequence ordering bug. The implementation (PR #12310) picks descending for whole-tree newest-first consistency (release groups are semver-descending and leaves within a chunk are date/id-descending; descending chunk folders keep the whole tree newest-first) — a one-line reversal if the brainstorm prefers ascending.
1501-…first, vs ascending =1-100first) and the broader label scheme (positional "1-100" vs the misreadable "TicketsScope Correction (implemented in PR #12310)
discussions.mjsexcluded. V-B-A ofapps/portal/model/Discussion.mjsshowed it labels chunk folders with the raw title (title || id), not positional ranges — so discussions has no label/order mismatch bug. Aligning its sort would change folder order for no fix benefit and pre-empt the operator's separate discussions folder-naming + open/closed brainstorm. AC2 + The Fix narrowed to tickets + pulls.Related
sortDate-sorted positional labels.Origin Session ID: da9a6007-1250-4363-8c15-dff69eccb3be Retrieval Hint: "portal chunked tree chunk folder order sortDate positional range label scramble"