From aed3154a521e38733dcbf3fdee2f4d5aec7efdc6 Mon Sep 17 00:00:00 2001 From: Youzini-afk <13153778771cx@gmail.com> Date: Mon, 13 Apr 2026 00:11:21 +0800 Subject: [PATCH] ui: add floor number search to memory browser (task + graph tabs) --- style.css | 6 ++++++ ui/panel.js | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/style.css b/style.css index 2882889..6e61810 100644 --- a/style.css +++ b/style.css @@ -1257,6 +1257,12 @@ flex: 0 0 auto; } +.bme-memory-list-filters .bme-floor-input { + max-width: 120px; + flex: 0 0 auto; + font-variant-numeric: tabular-nums; +} + .bme-memory-list-scroll { flex: 1; overflow-y: auto; diff --git a/ui/panel.js b/ui/panel.js index 9b3969b..0372879 100644 --- a/ui/panel.js +++ b/ui/panel.js @@ -1550,6 +1550,36 @@ function _getMemoryNodeTypeClass(type) { } } +function _parseFloorFilter(raw) { + const text = String(raw || "").trim(); + if (!text) return null; + const ranges = []; + for (const part of text.split(/[,,\s]+/)) { + const rangeParts = part.split(/[-~]/); + if (rangeParts.length === 2) { + const lo = parseInt(rangeParts[0], 10); + const hi = parseInt(rangeParts[1], 10); + if (!Number.isNaN(lo) && !Number.isNaN(hi)) { + ranges.push([Math.min(lo, hi), Math.max(lo, hi)]); + } + } else { + const n = parseInt(part, 10); + if (!Number.isNaN(n)) ranges.push([n, n]); + } + } + return ranges.length ? ranges : null; +} + +function _matchesFloorFilter(node, ranges) { + const seq = node.seq ?? -1; + const seqLo = node.seqRange?.[0] ?? seq; + const seqHi = node.seqRange?.[1] ?? seq; + for (const [lo, hi] of ranges) { + if (seqHi >= lo && seqLo <= hi) return true; + } + return false; +} + function _refreshTaskMemoryBrowser() { const el = document.getElementById("bme-task-memory"); if (!el) return; @@ -1565,6 +1595,7 @@ function _refreshTaskMemoryBrowser() { .trim() .toLowerCase(); const currentFilter = document.getElementById("bme-task-memory-filter")?.value || "all"; + const currentFloorQuery = String(document.getElementById("bme-task-memory-floor")?.value || "").trim(); let nodes = Array.isArray(graph.nodes) ? graph.nodes.filter((node) => !node?.archived) @@ -1587,6 +1618,13 @@ function _refreshTaskMemoryBrowser() { }); } + if (currentFloorQuery) { + const floorFilter = _parseFloorFilter(currentFloorQuery); + if (floorFilter) { + nodes = nodes.filter((node) => _matchesFloorFilter(node, floorFilter)); + } + } + const sorted = nodes.slice().sort((a, b) => { const importanceDiff = (b.importance || 5) - (a.importance || 5); if (importanceDiff !== 0) return importanceDiff; @@ -1624,6 +1662,7 @@ function _refreshTaskMemoryBrowser() {
+