Repository navigation
fix: Filter memory (filtering pt. 1) - #320
ShrimpCryptid wants to merge 17 commits into
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
Missing-category exclusions leave cells and annotations visible, while unfiltered Group by changes unnecessarily copy feature arrays and cell metadata, adding costly main-thread work for large datasets.
2 open issues
What changed in this PR
This PR preserves categorical filter selections per feature in Cell Feature Explorer, laying the groundwork for multi-feature filtering in #233.
Changes:
- Replaces the shared exclusion list with feature-keyed filters and an active-filter set.
- Updates legend controls, plot filtering, and annotations to use the new model; clears filters when changing datasets.
- Makes the Show/Hide all checkbox’s indeterminate state visible.
| File | Description |
|---|---|
src/state/util.ts |
Adds numeric filter conversion and evaluation helpers. |
src/state/test/mocks.ts |
Migrates mock state to feature-keyed filters. |
src/state/selection/types.ts |
Defines filter data, state, and action types. |
src/state/selection/selectors.ts |
Resolves active filters and filters plot data. |
src/state/selection/reducer.ts |
Handles filter updates, activation, and clearing. |
src/state/selection/logics.ts |
Clears filters when changing datasets. |
src/state/selection/constants.ts |
Defines the new filter action constants. |
src/state/selection/actions.ts |
Adds filter management action creators. |
src/containers/MainPlotContainer/test/selectors.test.ts |
Updates the annotation filtering test fixture. |
src/containers/MainPlotContainer/selectors.ts |
Applies numeric filters to annotations. |
src/containers/MainPlotContainer/index.tsx |
Removes obsolete exclusion-list references. |
src/containers/ColorByMenu/style.module.css |
Makes the indeterminate checkbox indicator visible. |
src/containers/ColorByMenu/selectors.ts |
Derives legend state from the current feature’s filter. |
src/containers/ColorByMenu/index.tsx |
Updates checkbox handlers to persist filters per feature. |
Review effort: Balanced
…rExclude state, linting
1aec484 to
de2da36
Compare
| /* Make intermediate checkbox visible */ | ||
| .interactive-legend-container | ||
| :global(.ant-checkbox.ant-checkbox-indeterminate) | ||
| > :global(.ant-checkbox-inner)::after { | ||
| background-color: var(--dimgray); | ||
| } |
There was a problem hiding this comment.
Fixes a bug where this checkbox was too low contrast and couldn't be seen.
| [getGroupByFilter, getGroupingCategoryNames], | ||
| (groupByFilter, categoryNames: string[]): boolean => { | ||
| const excludedValues = groupByFilter?.excludedValues; | ||
| return ( | ||
| excludedValues !== undefined && | ||
| excludedValues.size > 0 && | ||
| excludedValues.size !== categoryNames.length | ||
| ); |
There was a problem hiding this comment.
I think there may be a tiny bug here where unselecting all options except N/A shows the checkbox in as unchecked instead of indeterminate.
I think #322 addresses it and we can resolve merge conflicts as one or the other branch goes through, don't consider it blocking.
| csvUrl: string; | ||
| downloadConfig: DownloadConfig; | ||
| filterExclude: string[]; | ||
| filters: Map<string, FilterData>; |
There was a problem hiding this comment.
I like it! It makes sense to me that we want map filterData so each feature has its own entry
| const { groupByFilter, groupBy, handleSetFilter: handleSetFeatureFilter } = this.props; | ||
| const filter = this.getDiscreteFilterCopy(groupByFilter); | ||
| // Toggle whether the category is excluded from the filter | ||
| if (filter.discrete) { |
There was a problem hiding this comment.
nit: when would filter.discrete be false? given line 114, looks like this if would always be true right?
| selectedGroups: {}, | ||
| selectedPoints: selectedCellFileInfo, | ||
| displayableGroups: displayableGroups, | ||
| filters: new Map<string, FilterData>(), |
There was a problem hiding this comment.
non-blocking, just a question: would it be useful to mock activeFilters: Set<string>; too?

Problem
Part 1 of #233, "filter by feature in CFE".
Previously, there was a single
filterExcludearray that held all categorical values intended to be excluded. Because it was never cleared when switching between features, it gave the impression that CFE was persisting excluded values per categorical feature, when, in fact, certain actions could cause the whole list to be cleared.This change fixes that bug by storing filters in a map keyed by the feature name. It also sets up support for filtering on multiple features simultaneously that I plan to build a UI around in the next PR in this series.
Estimated review size: large, 40 minutes
Solution
filterExcludevalue array and related selectors/actions/reducers.filtersstate value, which maps from feature keys to aFilterDatatype containing a set of excluded values or a value range.activeFiltersset, which is used to determine the current set of filters that should be applied.getFilteredCellDataselector to apply filters via the new filtering system.Misc:
Type of change
Steps to Verify:
Screenshots (optional):
Video talk-through (🔊):
2026-10-30.16-06-07.mp4
2026-10-30.16-09-46.mp4
Keyfiles (delete if not relevant):
selection/types.tsselection/selectors.tsselection/actions.tsColorByMenu/index.ts-> main code logic that interacts with filters