Skip to content

fix: Filter memory (filtering pt. 1) - #320

Open
ShrimpCryptid wants to merge 17 commits into
mainfrom
feat/filtering
Open

ShrimpCryptid wants to merge 17 commits into
mainfrom
feat/filtering

Conversation

@ShrimpCryptid

@ShrimpCryptid ShrimpCryptid commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Part 1 of #233, "filter by feature in CFE".

Previously, there was a single filterExclude array 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

  • Removed filterExclude value array and related selectors/actions/reducers.
    • Replaced with filters state value, which maps from feature keys to a FilterData type containing a set of excluded values or a value range.
    • Also added an activeFilters set, which is used to determine the current set of filters that should be applied.
  • Updated getFilteredCellData selector to apply filters via the new filtering system.
  • Fixed a bug where filtered values would persist some of the time, but could be accidentally cleared.
  • Removed unused references to excluded filter values.

Misc:

  • Fixed a bug where the intermediate state in the show/hide all checkbox was not visible.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Steps to Verify:

  1. Open PR preview: Link
  2. Click around on the checkboxes on the left hand panel. All filter should be applied as normal.
  3. Switch to another group by feature and switch back. Your previous selections will remain.

Screenshots (optional):

Video talk-through (🔊):

2026-10-30.16-06-07.mp4
2026-10-30.16-09-46.mp4

Keyfiles (delete if not relevant):

  1. selection/types.ts
  2. selection/selectors.ts
  3. selection/actions.ts
  4. ColorByMenu/index.ts -> main code logic that interacts with filters

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.6.3

🚀 View preview at
https://AllenCell.github.io/cell-feature-explorer/pr-preview/pr-320/

Built to branch gh-pages at 2026-11-02 21:45 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@ShrimpCryptid ShrimpCryptid added the bug Something isn't working label Oct 30, 2026
@ShrimpCryptid ShrimpCryptid changed the title refactor: Fix filtering memory (filtering pt. 1) refactor: Filtering memory (filtering pt. 1) Oct 30, 2026
@ShrimpCryptid ShrimpCryptid changed the title refactor: Filtering memory (filtering pt. 1) fix: Filtering memory (filtering pt. 1) Oct 30, 2026
@ShrimpCryptid ShrimpCryptid changed the title fix: Filtering memory (filtering pt. 1) fix: Filter memory (filtering pt. 1) Oct 30, 2026
@ShrimpCryptid
ShrimpCryptid requested a balanced review from Copilot October 30, 2026 23:20

Copilot AI 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.

🟡 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

Comment thread src/state/selection/selectors.ts Resolved
Comment thread src/state/util.ts Resolved
@ShrimpCryptid
ShrimpCryptid marked this pull request as ready for review November 2, 2026 20:08
@ShrimpCryptid
ShrimpCryptid requested a review from a team as a code owner November 2, 2026 20:08
@ShrimpCryptid
ShrimpCryptid requested review from frasercl and rugeli and removed request for a team November 2, 2026 20:08
@ShrimpCryptid
ShrimpCryptid marked this pull request as draft November 2, 2026 20:08
@ShrimpCryptid
ShrimpCryptid marked this pull request as ready for review November 2, 2026 20:51
Comment on lines +39 to +44
/* Make intermediate checkbox visible */
.interactive-legend-container
:global(.ant-checkbox.ant-checkbox-indeterminate)
> :global(.ant-checkbox-inner)::after {
background-color: var(--dimgray);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixes a bug where this checkbox was too low contrast and couldn't be seen.

@ShrimpCryptid
ShrimpCryptid requested review from interim17 and removed request for frasercl November 3, 2026 19:26
Comment on lines +72 to +79
[getGroupByFilter, getGroupingCategoryNames],
(groupByFilter, categoryNames: string[]): boolean => {
const excludedValues = groupByFilter?.excludedValues;
return (
excludedValues !== undefined &&
excludedValues.size > 0 &&
excludedValues.size !== categoryNames.length
);

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.

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

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.

I like it! It makes sense to me that we want map filterData so each feature has its own entry

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

LGTM! with two comments

const { groupByFilter, groupBy, handleSetFilter: handleSetFeatureFilter } = this.props;
const filter = this.getDiscreteFilterCopy(groupByFilter);
// Toggle whether the category is excluded from the filter
if (filter.discrete) {

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.

nit: when would filter.discrete be false? given line 114, looks like this if would always be true right?

Comment thread src/state/test/mocks.ts
selectedGroups: {},
selectedPoints: selectedCellFileInfo,
displayableGroups: displayableGroups,
filters: new Map<string, FilterData>(),

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.

non-blocking, just a question: would it be useful to mock activeFilters: Set<string>; too?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants