From a259891007b05386d0d71f69c7b42c2d8cdddefe Mon Sep 17 00:00:00 2001 From: you Date: Sat, 21 Mar 2026 23:32:05 +0000 Subject: [PATCH] feat: add Chronological sort mode for expanded packet groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pure timestamp order, no grouping — shows propagation sequence. --- public/index.html | 2 +- public/packets.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index c954721e..ea1a5655 100644 --- a/public/index.html +++ b/public/index.html @@ -84,7 +84,7 @@ - + diff --git a/public/packets.js b/public/packets.js index dba51322..315e600c 100644 --- a/public/packets.js +++ b/public/packets.js @@ -702,7 +702,8 @@ const sortMode = groupSortModes[p.hash] || SORT_OBSERVER; const obsLabel = sortMode === SORT_OBSERVER ? 'Observer' : 'Observer'; const pathLabel = sortMode === SORT_PATH_LENGTH ? 'Path length' : 'Path length'; - html += `Sort: ${obsLabel} · ${pathLabel}`; + const chronoLabel = sortMode === SORT_CHRONO ? 'Chronological' : 'Chronological'; + html += `Sort: ${obsLabel} · ${pathLabel} · ${chronoLabel}`; for (const c of p._children) { const typeName = payloadTypeName(c.payload_type); const typeClass = payloadTypeColor(c.payload_type); @@ -1251,6 +1252,7 @@ // Observation sort modes const SORT_OBSERVER = 'observer'; const SORT_PATH_LENGTH = 'path'; + const SORT_CHRONO = 'chrono'; const groupSortModes = {}; // hash → sort mode function getPathHopCount(c) { @@ -1261,7 +1263,12 @@ if (!group || !group._children) return; const mode = groupSortModes[group.hash] || SORT_OBSERVER; - if (mode === SORT_PATH_LENGTH) { + if (mode === SORT_CHRONO) { + group._children.sort((a, b) => { + const tA = a.timestamp || '', tB = b.timestamp || ''; + return tA < tB ? -1 : tA > tB ? 1 : 0; + }); + } else if (mode === SORT_PATH_LENGTH) { group._children.sort((a, b) => { const lenA = getPathHopCount(a), lenB = getPathHopCount(b); if (lenA !== lenB) return lenA - lenB;