fix: remove active annotation filter

This commit is contained in:
Your Name 2026-07-05 18:20:29 -04:00
parent 649e36c14c
commit 28f441f172
6 changed files with 21 additions and 39 deletions

View file

@ -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);

View file

@ -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

View file

@ -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]

View file

@ -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.

View file

@ -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?)
(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"])])))
"Clear"]])])))
(defn toolbar []
;; NB: subscribe the coarse ::at-start?/::at-end? edges, not the raw playhead —

View file

@ -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"}))))