Skip to content

refactor(filters): one owner per filter concern - #552

Merged
Ardnived merged 15 commits into
mainfrom
refactor/filter-cleanup
Nov 28, 2026
Merged

Ardnived merged 15 commits into
mainfrom
refactor/filter-cleanup

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Follow-up to feat(filters): Where, When and Language buttons over the map on a computer #542 (the reviewer's call: a separate PR): each filter concern now has one owner.
  • Where the buttons show, the Where menu's props, how an answer is named, the widget width on a map: one place each.
  • Review asks: each component in its own folder with a story (FilterNotice, WhereFilter), FilterMenus reads the URL itself, clearer hook names.

Change outline

Components — one rule for where the filter buttons show

The rule was computed in DrawerStack, copied into a store flag for the map, and computed again more loosely for the Filters button and tags. Now one hook holds it and all three read it.

 useFilterMenusOnMap()                            src/hooks/use-filter-menus.ts
-  isWide && hasMap
+  isWide && hasMap && top !== 'filters' && !isCalendarFullWidth(top, isWide, view)
+    top = baseStackEntry(resolveStack(pathname), hasMap)   # the drawer's own base view
 DrawerStack                                      src/views/DrawerStack/DrawerStack.tsx
-  filterMenus = isWide && hasMap && !wide && top !== 'filters'
-  useEffect → useMapControls.setFilterMenus(filterMenus)
 MapControls                                      src/components/organisms/Mapbox/MapControls.tsx
-  useMapControls(s => s.filterMenus)
+  useFilterMenusOnMap()                          # filter buttons beside the column, find-me aside
 useMapControls                                   src/config/store.ts
-  filterMenus, setFilterMenus
 CalendarView → CalendarHeader                    src/views/CalendarView/CalendarView.tsx
-  isCalendarFullWidth(…) in the header and again in the view
+  fullWidth worked out once in the view, passed to the header

Components — one owner for the widget's width on a map

The map's controls sit outside DrawerStack, so they need the width too. The map controller already measured the same frame for the camera padding; it now provides that answer to the map and to DrawerStack, which measures its own box only map-less.

 FullInterface                                    src/views/FullInterface.tsx
   RealMapControllerProvider                      src/hooks/use-map-controller-real.tsx
     isWide = useIsWide(frameElement())
+    <WidgetWidthContext value={isWide}>          # read by MapControls and DrawerStack
     Mapbox → MapControls
     DrawerStack
-      isWide = useIsWide(container ?? frameElement())
+      isWide = provided ?? useIsWide(container ?? frameElement())   # measures only map-less
-      <WidgetWidthContext> around the map-mode drawer

Flow — one Where for the drawer and the buttons

Both surfaces built the same WhereFilter, and judged "offer Near me?" two different ways.

 useFilterEditor(surface)                         src/hooks/use-filter-editor.ts
+  page = drawer ? parentOf(pathname) : pathname  # the page the filters narrow, named once
+  where = { region, searchable: page !== '/calendar', onPlace, onClear }
 FilterView                                       src/views/Filters/FilterView.tsx
-  <WhereFilter region searchable={origin !== '/calendar'} onClear onPlace … />
+  <WhereFilter {...where} counts onSearchInstead={dismiss into the list's search} />
 FilterMenuBar                                    src/views/Filters/FilterMenuBar.tsx
-  searchable = pathname !== '/calendar'; <WhereFilter region searchable onClear onPlace … />
+  <WhereFilter {...where} counts onSearchInstead={focus the list's search} />

Components — one way to name an answer, and one way out

The filter buttons, the filter tags and the removal each turned answers into words with the same keys. The removal's detection and wording is now a hook that each surface draws its own way, and the list's two lines are one organism every list renders.

+useFilterLabels(filters, width?) → { format, days, time, cadence, languages, dates }   src/hooks/use-filter-labels.ts
+useFilterRecovery(filters, recovery, apply) → { label: "Remove Monday (3 classes)", apply }   src/hooks/use-filter-recovery.ts
 FilterMenus                                      # button summaries ("Tue · Evening")
 ActiveFilterChips                                # format, cadence, days, languages; keeps its hours and date range
 FilterView footer                                # useFilterRecovery → its own solid Button
-RecoveryButton (organisms/SearchFilters)
-NoFilterMatches, HiddenByFilters                 # EventsList/FilterNotes.tsx, exported from EventsList
+FilterNotice kind="no-match" | "hidden"          src/components/organisms/FilterNotice/ (+ story)
   DynamicEventsList, RegionView, OnlineView, CountriesView, CalendarView's WeekList

Components — FilterMenus reads the URL itself

The connector view only read the URL and named the place, so the organism does it, as DynamicEventsList reads its data. WhereFilter, shared by the drawer and the Where menu, gets its own folder.

-FilterMenuBar (view)                             src/views/Filters/FilterMenuBar.tsx
-  FilterMenus value onChange onClear where={{ place, placeAnswered, always, menu }}
+FilterMenus variant?                             src/components/organisms/FilterMenus/FilterMenus.tsx
+  useFilterEditor('buttons') → value, write, clear, where
+  place: Near me, the searched place's first part, or the place page's name
+  Where menu → <WhereFilter {...where} />         src/components/organisms/WhereFilter/ (+ story)
 FullInterface → <Mapbox filterMenus={<FilterMenus variant="floating" />} />
 CalendarHeader → fullWidth ? <FilterMenus /> : <FilterButton />
-src/views/Filters/{FilterView, FilterMenuBar, WhereFilter}
+src/views/FilterView/FilterView.tsx              # the drawer alone again
+src/components/ladle/StoryAddress.tsx            # a story section at its own address, live

Files — names

-useAnswerLabels                use-answer-labels.ts
+useFilterLabels                use-filter-labels.ts
-useFilterFacets                use-filter-facets.ts
+useFilterCounts                use-filter-counts.ts
-useFilterMenusOnMap            use-filter-menus.ts
+useFilterButtonsShown          use-filter-buttons.ts
-RealMapControllerProvider      use-map-controller-real.tsx
+MapboxControllerProvider       use-map-controller-mapbox.tsx

Files — tidy-ups

 src/lib/shape/facets.ts
+  scopeOffers(filters, events)                   # the closed buttons' Where/Language check, beside shownGroups
 src/components/organisms/FilterMenus/FilterMenus.tsx
-  inline row: ms-auto                            # the calendar header's justify-between places it

Preview

Preview pending: the Cloudflare branch aliases appear once the build reports.

Test results

  • Lean gate (.claude/skills/pr-prep/check.sh): lint, typecheck and test:run (2775) passed.
  • Browser lane (pnpm test:browser): 39 passed, after the folding of FilterMenuBar.
  • New specs: use-filter-editor.test.tsx (watched failing with the drawer judged by its own path), use-filter-labels.test.tsx (its long-day case watched failing on the short names), scopeOffers cases in facets.test.ts.
  • Build: left to CI.

Manual verification

  1. 1440px, the first screen: Where, When and Language over the map, no find-me, no Filters button.
  2. A contained embed resized across 768px: the panel and the map's buttons change together.
  3. The calendar's Month: the row in its header; its Week: the row back over the map.
  4. An empty filtered list with a day filter: the link reads "Remove Monday (N classes)".

Notes for reviewer

  • Built after the adversarial review: the day names in the removal link stay full
    (useAnswerLabels(filters, 'long')), the new hook's useMemo is gone, the fullWidth JSDoc is
    gone, and the docblock says why the full form's own fields keep their own vocabulary.
  • Self-review (/code-review medium beside /simplify) findings dismissed:
    • "The inline row loses its right alignment": the calendar header row is justify-between, so it already ends on the right (checked in Ladle).
    • "Two width measurements can disagree": no longer two; the map controller is the one owner on a map.
    • "The Filters button and tags reappear over the filters drawer or the full-width calendar": neither renders them there.
    • "Memoise the labels": no consumer compares them between renders.

🤖 Generated with Claude Code

Ardnived and others added 6 commits November 27, 2026 18:20
useFilterMenusOnMap holds the whole rule (beside the panel, over a map,
not under the full-width calendar or the filters' drawer), and the map's
controls, the Filters button and the filter tags all read it. The map
controller provides the widget width to the map's controls, so the store
flag and DrawerStack's effect go. The calendar reads its full width once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
useFilterEditor returns the Where menu's place half, including whether
it offers Near me, judged by the page the filters narrow. Both surfaces
spread it into WhereFilter and add only their own 'search instead'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
useAnswerLabels names each answered question once, and the filter
buttons, the filter tags and the removal under an empty list all read
it. The removal now names days as the buttons and tags do ("Mon").

Co-Authored-By: Claude Opus 5.5 <[email protected]>
scopeOffers answers shownGroups' Where and Language questions from the
scope without counting it, with a spec that the two agree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ment and stale comments

RecoveryButton is a molecule (the filter drawer and the list both use
it). The inline filter row no longer pushes itself right; the toolbar it
sits in places it. Comments naming FilterView's long-gone Apply and draft
now name the drawer and buttons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- One owner for the widget's width on a map: the map controller
  measures the frame and provides it; DrawerStack reads it and measures
  its own box only map-less. The comments naming DrawerStack as the sole
  owner say so.
- useFilterEditor names the page the filters narrow once.
- useAnswerLabels takes t from useLocale, and its docblock says the tags
  keep their own times and dates; ActiveFilterChips reads its answers
  from it.
- Dead test scaffolding, an unused barrel export and type name, a
  narrower summarize type, and a stale 'draft' comment.
- scopeOffers says, and a spec pins, that a loading scope offers
  neither question.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-dispatcher

sydevs-dispatcher Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 01:51Z address-review · attempt 1 · session · done
  • 01:51Z address-review · attempt 1 · session
  • 01:42Z review-pr · attempt 1 · session · done
  • 01:42Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 280f5ad Nov 28 2026, 03:12 AM

@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 28, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 28, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The diff matches its title: four concerns, one owner each, nothing unrelated smuggled in. I traced both moved rules for drift and found none. useFilterMenusOnMap now computes main's filterMenus expression exactly, and on the two newly-tightened paths — top === 'filters' and the full-width calendar — every consumer was already guarded, so this unifies the rule without changing what a visitor sees. No contract surface is touched, and the docs moved with the code, including two already stale.

Findings

  • should-fix — Streamline: the new hook's useMemo earns nothing. use-answer-labels.ts:16
  • should-fix — Streamline: the fullWidth JSDoc restates its one call site. CalendarView.tsx:85
  • should-fix — the outline's reason for dropping ms-auto names a toolbar that never renders this variant. FilterMenus.tsx:223
  • consider — a fourth site names the same answer and stayed outside the new owner. use-answer-labels.ts:26
  • consider — the removal link's day names got shorter. use-answer-labels.ts:20

What was checked

Rule equivalence walked through isFilterOverlay, baseStackEntry and isCalendarFullWidth at /search/filters, /calendar/filters, /calendar in both views, /gb and /. WidgetWidthContext providers enumerated on both refs: two on main, one kept on DrawerStack's map-less return, one added above the map, and NoopMapControllerProvider adds none. scopeOffers and whenCount match main's inline versions, scope undefined included. filter-blocks.tsx, shared.tsx and ListToolbar read as unchanged consumers; findings 3 and 4 come from them. Ladder walked on four new pieces: the streamliner kept summarize and scopeOffers, the latter after testing the fold against useFilterScope's cheap-read contract. Every path the body names resolves on the branch.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/hooks/use-answer-labels.ts Resolved
Comment thread src/hooks/use-filter-labels.ts Resolved
Comment thread src/hooks/use-filter-labels.ts Resolved
Comment thread src/views/CalendarView/CalendarView.tsx Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 28, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 28, 2026
weekdayNames is Info.weekdays, which Luxon caches per locale, and the
object around it is new on every render, so the memo held nothing.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYqstrJevNu2rNZBG8
"Remove Monday (3 classes)" is prose, where the buttons and tags are
chips with no room. The width is the caller's, short by default.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYqstrJevNu2rNZBG8
Its one call site already carries the same fact, beside the branch it
explains.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYqstrJevNu2rNZBG8
LanguageChoices names languages identically today, so the next reader
needs to know the fields were left out on purpose.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYqstrJevNu2rNZBG8
@sydevs-bot

Copy link
Copy Markdown
Contributor

Built and resolved every thread from the review.

Adopted:

Answered:

Lean gate green at 2777 tests. Browser lane 39 passed.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 28, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 28, 2026

@sydevs-dispatcher sydevs-dispatcher Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. Enable auto-merge when you want it merged: the queue tests it against its base. 🤖 Written by the sydevs autonomous loop — see what this is

@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 28, 2026
Ardnived and others added 5 commits November 27, 2026 19:59
useAnswerLabels → useFilterLabels, useFilterFacets → useFilterCounts,
useFilterMenusOnMap → useFilterButtonsShown, and the Mapbox-backed map
controller is MapboxControllerProvider (use-map-controller-mapbox.tsx)
rather than 'Real'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…yButton and FilterNotes

The removal's detection and words are one hook, useFilterRecovery, which
the phone filters draw as their footer button and FilterNotice as a link.
FilterNotice is its own organism (kind no-match | hidden) with a story,
used by every list, instead of two components exported from EventsList.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts own organism

FilterMenus reads and writes the URL through useFilterEditor and names
the place in scope, so the FilterMenuBar connector goes. WhereFilter,
shared by the phone filters and the Where menu, moves to its own
organism folder with a story; views/FilterView holds only the drawer
again. StoryAddress gives each story section an address of its own, so
the FilterMenus and WhereFilter stories show every state side by side,
each live.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/components/molecules/RecoveryButton/RecoveryButton.tsx
#	src/hooks/use-filter-labels.test.tsx
#	src/hooks/use-filter-labels.ts
@Ardnived
Ardnived added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 59042d7 Nov 28, 2026
14 checks passed
@Ardnived
Ardnived deleted the refactor/filter-cleanup branch November 28, 2026 03:44
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 28, 2026
Ardnived added a commit that referenced this pull request Nov 28, 2026
Brings in #552 (one owner per filter concern), and adopts its approaches:
- `useFilterButtonsShown` is the one rule; it now also holds inline, where the toolbar carries
  the buttons, and steps aside on a class and its sign-up. The store flag and DrawerStack's
  copy of the rule are gone, as on main.
- `FilterMenus` reads the URL itself, so the inline toolbar and the full map's corner render it
  directly; `FilterMenuBar` is gone.
- `MapboxControllerProvider` provides the frame's width on a map; inline it provides none, so
  `DrawerStack` keeps measuring the inline column.
- The calendar's header takes `fullWidth` from its view, which inline is never full width.
- The MapControls story shows the inline toolbar with the live `FilterMenus`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants