Commit ef50267
fix(filters): project filters — OR-within/AND-across tags + filtered facets + stage row
User report: clicking any filter chip "selected them all" and toggling
any after that flipped the whole tab on/off without changing results.
Root cause: the SPA's FacetEntry type expected `{ handle, slug, … }` but
the API has always emitted `{ tag, title, count }` per the spec. With
neither `handle` nor `slug` on the wire, FacetSidebar's fallback
produced `handle = "topic."` for every chip in the Topic tab (and
similarly per other namespaces). Every chip shared the same toggle
key → clicking any flipped the whole tab.
Pre-existing bug since the SPA's first feature drop (2f0a62c / 427c2bf),
not a recent regression. No test exercised the click → URL → fetch
path against real-shaped data so it stayed dormant.
Bug fix piggybacks three UX upgrades worth the same review pass:
**Tag filter semantics**: OR within namespace, AND across namespaces.
Spec previously said "AND across repeats" — the new pattern matches
the conventional faceted-search behavior (within a facet group users
widen; across groups they narrow). `?tag=topic.transit&tag=topic.mapping`
now returns projects tagged with either, and adding `tech.python` narrows
to that AND (transit OR mapping).
**Facet counts**: filtered with self-namespace exclusion (replaces
"unfiltered corpus"). Each tag-namespace facet is counted over the
project set filtered by every active criterion except tag filters in
that same namespace — so the user can widen their selection in a
namespace without losing track. Selected tags get pinned with count 0
when no other project in the filtered set carries them.
**Stage facet hoisted out of the sidebar** into a horizontal pill row
above the search box. Stages are a 7-value fixed enum and benefit from
being visible at a glance; tabs hide them behind a click. New
StageFilterRow component; sidebar tabs reduce to Topics/Tech/Events.
API: ProjectService.list builds a predicate factory with optional
exclusions and runs 5 filter passes (main listing + 4 facet self-
exclusions). Per-request, no caching — at civic scale this is ~1-2ms.
The previously-cached `getProjectFacets` is replaced by per-request
`computeProjectFacets`; `getPeopleFacets` left as-is (out of scope).
Tests: 9 new API tests (project-filters.test.ts) drive ProjectService
directly. 4 new SPA tests (ProjectsIndex.test.tsx) cover the click →
URL → fetch path that would have caught the original bug. read-api's
"facets reflect unfiltered corpus" assertion reframed for the new
contract. Full sweep: api 397/397, web 73/73, shared 75/75. Type-check
+ lint clean.
Spec changes: specs/api/projects.md (tag + facet semantics rewritten),
specs/screens/projects-index.md (stage-row section above results;
sidebar tabs reduced to Topics/Tech/Events).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 741aa2c commit ef50267
11 files changed
Lines changed: 831 additions & 238 deletions
File tree
- apps
- api
- src
- services
- store/memory
- tests
- web
- src
- components
- lib
- screens
- tests
- specs
- api
- screens
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
86 | 85 | | |
87 | | - | |
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
91 | 89 | | |
92 | 90 | | |
93 | 91 | | |
94 | | - | |
95 | 92 | | |
96 | 93 | | |
97 | 94 | | |
98 | | - | |
99 | | - | |
100 | | - | |
| 95 | + | |
101 | 96 | | |
102 | 97 | | |
103 | | - | |
104 | 98 | | |
105 | 99 | | |
106 | 100 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | 101 | | |
111 | 102 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
116 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
117 | 112 | | |
118 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
153 | 137 | | |
154 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
155 | 187 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
165 | 201 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
175 | 214 | | |
176 | | - | |
177 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
178 | 218 | | |
179 | | - | |
180 | | - | |
| 219 | + | |
181 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
182 | 225 | | |
183 | 226 | | |
184 | | - | |
185 | 227 | | |
186 | 228 | | |
187 | 229 | | |
188 | | - | |
189 | 230 | | |
190 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
191 | 244 | | |
192 | 245 | | |
193 | 246 | | |
| |||
0 commit comments