From 28f441f172122a58e98513ba79d4dfd5a3afa55d Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 5 Jul 2026 18:20:29 -0400 Subject: [PATCH] fix: remove active annotation filter --- tl/resources/public/css/app.css | 5 ++++- tl/src/tl/events.cljs | 7 ++----- tl/src/tl/filter.cljs | 4 +--- tl/src/tl/subs.cljs | 16 ++++------------ tl/src/tl/views.cljs | 19 ++++++++++--------- tl/test/tl/filter_test.cljs | 9 --------- 6 files changed, 21 insertions(+), 39 deletions(-) diff --git a/tl/resources/public/css/app.css b/tl/resources/public/css/app.css index 3c1a902..e34fcc0 100644 --- a/tl/resources/public/css/app.css +++ b/tl/resources/public/css/app.css @@ -375,7 +375,10 @@ body { overflow: hidden; background: var(--desktop); background-size: 4px 4px; border-radius: 0; padding: 5px 7px; font-family: var(--geneva); font-size: 12px; } .annotation-filter .filter-btn { border-radius: 0; } -.annotation-filter .filter-btn.clear { margin-left: auto; } +.filter-summary { + margin-left: auto; display: inline-flex; align-items: center; gap: 6px; + font-size: 11px; color: var(--mute); +} .form-hint { font-size: 11px; color: var(--mute); } .form-check { display: flex; align-items: center; gap: 6px; font-family: var(--chicago); diff --git a/tl/src/tl/events.cljs b/tl/src/tl/events.cljs index e1afab9..cb95aa5 100644 --- a/tl/src/tl/events.cljs +++ b/tl/src/tl/events.cljs @@ -333,7 +333,7 @@ (assoc-in db [:view :hidden-notes] (if (contains? s gid) (disj s gid) (conj s gid)))))) ;; annotation-pane filters are inclusive: selected tags narrow the list to -;; matching annotations; active-only narrows to annotations under the playhead. +;; matching annotations. (rf/reg-event-db ::set-annotation-search (fn [db [_ q]] (assoc-in db [:view :annotation-filter :query] q))) (rf/reg-event-db ::toggle-annotation-tag-filter @@ -341,12 +341,9 @@ (let [s (get-in db [:view :annotation-filter :tags] #{})] (assoc-in db [:view :annotation-filter :tags] (if (contains? s tag) (disj s tag) (conj s tag)))))) -(rf/reg-event-db ::toggle-active-annotations-filter - (fn [db _] - (update-in db [:view :annotation-filter :active-only?] not))) (rf/reg-event-db ::clear-annotation-filter (fn [db _] (assoc-in db [:view :annotation-filter] - {:query "" :tags #{} :active-only? false}))) + {:query "" :tags #{}}))) ;; click a highlight on the page → activate its note and focus that region's row ;; in the right pane diff --git a/tl/src/tl/filter.cljs b/tl/src/tl/filter.cljs index 8733921..3426206 100644 --- a/tl/src/tl/filter.cljs +++ b/tl/src/tl/filter.cljs @@ -32,10 +32,9 @@ (and (contains? selected :untagged) (empty? tags)))))) (defn annotation-matches? - [{:keys [query tags active-only? active-ids]} ann] + [{:keys [query tags]} ann] (let [{:keys [scope term]} (parse-query query) selected-tags (set tags) - active-ids (set active-ids) fields {:timeline [(:name ann) (:content ann)] :script (:script ann) :clip (:clips ann) @@ -47,7 +46,6 @@ :tag (:tag fields) (mapcat fields [:timeline :script :clip :tag]))] (and (tag-match? selected-tags (:tags ann)) - (or (not active-only?) (contains? active-ids (:id ann))) (includes-term? haystack term)))) (defn filter-annotations [anns filters] diff --git a/tl/src/tl/subs.cljs b/tl/src/tl/subs.cljs index c22ffe1..98524be 100644 --- a/tl/src/tl/subs.cljs +++ b/tl/src/tl/subs.cljs @@ -26,7 +26,7 @@ (rf/reg-sub ::note-target (fn [db] (get-in db [:view :note-target]))) (rf/reg-sub ::hidden-notes (fn [db] (get-in db [:view :hidden-notes] #{}))) (rf/reg-sub ::annotation-filter - (fn [db] (merge {:query "" :tags #{} :active-only? false} + (fn [db] (merge {:query "" :tags #{}} (get-in db [:view :annotation-filter])))) (rf/reg-sub ::region-focus (fn [db] (get-in db [:view :region-focus]))) (rf/reg-sub ::linking (fn [db] (get-in db [:view :linking]))) @@ -171,19 +171,11 @@ (sort-by (juxt :broken :start)) ; broken annotations sink to the bottom vec)))) -(rf/reg-sub - ::active-annotations-unfiltered - :<- [::all-annotations] :<- [::playhead] - (fn [[anns ph] _] - (into #{} (keep (fn [a] (when (in-bars? (:bars a) ph) - (:id a))) - anns)))) - (rf/reg-sub ::annotations - :<- [::all-annotations] :<- [::annotation-filter] :<- [::active-annotations-unfiltered] - (fn [[anns filters active] _] - (filter/filter-annotations anns (assoc filters :active-ids active)))) + :<- [::all-annotations] :<- [::annotation-filter] + (fn [[anns filters] _] + (filter/filter-annotations anns filters))) ;; every distinct tag used by any annotation in the project — feeds both the tag ;; adder's autocomplete and the timeline tag filter. diff --git a/tl/src/tl/views.cljs b/tl/src/tl/views.cljs index 871d8b7..b4e216a 100644 --- a/tl/src/tl/views.cljs +++ b/tl/src/tl/views.cljs @@ -1682,7 +1682,10 @@ (defn- annotation-filter [] (r/with-let [open? (r/atom false)] (let [project-tags @(rf/subscribe [::subs/project-tags]) - {:keys [query tags active-only?]} @(rf/subscribe [::subs/annotation-filter]) + {:keys [query tags]} @(rf/subscribe [::subs/annotation-filter]) + total (count @(rf/subscribe [::subs/all-annotations])) + shown (count @(rf/subscribe [::subs/annotations])) + filtered (- total shown) chosen (set tags) key-of #(if (= % untagged-label) :untagged %)] [:div.annotation-filter @@ -1691,10 +1694,6 @@ :value query :on-change #(rf/dispatch [::events/set-annotation-search (.. % -target -value)])}] - [:button.filter-btn {:class (when active-only? "active") - :title "Only show annotations active at the playhead" - :on-click #(rf/dispatch [::events/toggle-active-annotations-filter])} - "Active"] (when (seq project-tags) [:span.tag-filter [:button.filter-btn {:class (when (seq chosen) "active") @@ -1709,10 +1708,12 @@ :placeholder "include tags…" :clear-on-choose? false :auto-focus? true :on-choose #(rf/dispatch [::events/toggle-annotation-tag-filter (key-of %)]) :item-suffix (fn [t] [:span.tag-eye (if (contains? chosen (key-of t)) "✓" "")])}]]])]) - (when (or (seq query) (seq chosen) active-only?) - [:button.filter-btn.clear {:title "Clear filters" - :on-click #(rf/dispatch [::events/clear-annotation-filter])} - "Clear"])]))) + (when (or (seq query) (seq chosen)) + [:span.filter-summary + (when (pos? filtered) (str filtered " others filtered")) + [:button.filter-btn.clear {:title "Clear filters" + :on-click #(rf/dispatch [::events/clear-annotation-filter])} + "Clear"]])]))) (defn toolbar [] ;; NB: subscribe the coarse ::at-start?/::at-end? edges, not the raw playhead — diff --git a/tl/test/tl/filter_test.cljs b/tl/test/tl/filter_test.cljs index ce81837..d6a3c48 100644 --- a/tl/test/tl/filter_test.cljs +++ b/tl/test/tl/filter_test.cljs @@ -32,15 +32,6 @@ (testing "untagged is an explicit include bucket" (is (= [:c] (mapv :id (f/filter-annotations anns {:tags #{:untagged}})))))) -(deftest active-only-intersects-other-filters - (testing "active-only shows only currently active annotations" - (is (= [:b] (mapv :id (f/filter-annotations anns {:active-only? true - :active-ids #{:b :z}}))))) - (testing "active-only intersects with selected tags" - (is (= [] (mapv :id (f/filter-annotations anns {:tags #{"beat"} - :active-only? true - :active-ids #{:b}})))))) - (deftest search-scopes (testing "plain text searches title/content/tags/script/clips" (is (= [:a] (mapv :id (f/filter-annotations anns {:query "breakfast"}))))