fix(icon): correct ordering of dedup + cap in add-used-item!

Pipeline ran (take 24) BEFORE (filter should-keep?), so an existing
duplicate at position 24+ in the recents list was truncated unfiltered
instead of caught by the dedup. Then (cons normalized) prepended the
new pick, producing 25 items — both violating the 24-item cap and
failing to actually move the dup to the front.

Reorder: filter across the whole existing list, cons the new pick,
THEN cap at 24. REPL-verified on a 27-item list with the duplicate at
index 24: old pipeline stored 25 items (cap violated), new pipeline
stored 24 (cap honored, dup correctly displaced by the cons).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
scheinriese
2026-05-19 13:55:25 +02:00
parent 3b80bce2ea
commit 1ebbf1ddf4

View File

@@ -2260,10 +2260,13 @@
(not= (:type item) new-type)
;; Remove exact duplicates for other types
(not= normalized item)))
;; Filter dupes across the WHOLE existing list, not just the first 24
;; — otherwise an existing duplicate beyond position 24 stays in storage
;; on the next call. Then cons the new pick and cap at 24.
s (some->> (or (get-used-items) [])
(take 24)
(filter should-keep?)
(cons normalized))]
(cons normalized)
(take 24))]
(storage/set :ui/ls-icons-used-v2 s)))
(defn derive-initials