Skip to content

refactor(events): remove event.selections and read state.selections - #115

Merged
jvdd merged 4 commits into
mainfrom
refactor/event-selections-from-state
Sep 29, 2026
Merged

jvdd merged 4 commits into
mainfrom
refactor/event-selections-from-state

Conversation

@jvdd

@jvdd jvdd commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #86.

Change

Impact

  • The selections travel once per request. Before, they travelled in both state.selections and event.selections.
  • Every caller sent the same list in both places, except in one race: the second request of a restore and a cross-filter mode switch captured the list before an await. If the user changed the selections during that await, the old code filtered by the stale list while the spec carried the new one. Now the server filters by the state it receives.
  • An old client that still sends event.selections gets no error. The server ignores the field (the model does not forbid extra fields). A spec of version 0.6 is refused, as for every other version change.

Tests

  • New test_state_selections_filter_the_request (tests/test_integration.py): a request without event.selections is filtered by state.selections, and a stale event.selections is ignored. Both cases fail on main.
  • New test_remove_selection_posts_type_matching_state[plotly|echarts] (tests/test_browser.py): removing one of two selections posts selection with one left; removing the last posts deselect with state.selections == []. It passes before and after the refactor.
  • test_bar_deselect_clears_filter now sends the deselect with a selection still in the state, so the deselect guard is tested.
  • Engine, server, integration, cube and browser tests pass the selections through the state instead of the event. The 4 removed assertions have equal replacements.
  • Mutation check: with the server passing [] instead of state.selections, 25 tests fail.
  • pytest tests flexviz_polars/tests: 2427 passed, 2 skipped.
  • pytest benchmarks: 31 passed.
  • pytest -m browser tests: 341 passed, 15 skipped (before the last commit, which splits one if line and removes a source-text test). Local browser runs afterwards were unstable with page-load timeouts on main too; CI is the reference.

@codspeed

codspeed Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing refactor/event-selections-from-state (e3a5194) with main (d03f887)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (e3a5194) during the generation of this report, so d03f887 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@jvdd
jvdd force-pushed the refactor/event-selections-from-state branch from 2f3a3b3 to e3a5194 Compare September 29, 2026 07:56
@jvdd
jvdd merged commit 1ebe415 into main Sep 29, 2026
17 checks passed
@jvdd
jvdd deleted the refactor/event-selections-from-state branch September 29, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove event.selections and read state.selections on the server

1 participant