Fix selection clearing round-trip in multi-component state sync#89
Conversation
The frontend now round-trips a cleared selection as null/None (so deselecting an amino acid or switching proteoform propagates across the component iframes). update/filter use the "key not in selection_store" convention, so drop None-valued keys before computing data, while still echoing the full state (incl. nulls) back to the frontend so it can clear those fields everywhere. - src/render/render.py: pass an active_state without None values to update_data/filter_data; keep echoing the full state in selection_store. - tests/test_selection_clear.py: pin the StateTracker round-trip invariants (cleared field echoed as None but absent for the data computation). - js-component/dist: rebuilt Vue bundle including the matching frontend fix. https://claude.ai/code/session_01TWkpASnLwnhMAQRxuYFpNs
|
Warning Review limit reached
More reviews will be available in 8 minutes and 5 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes a bug where clearing a selection (e.g., deselecting an amino acid or switching proteoforms) in one FLASHViewer component would not propagate to other components. The issue occurred because cleared fields were being dropped from the state payload entirely, preventing the merge-only StateTracker from learning about the deselection.
Changes
src/render/render.py: Modified
render_component()to handle cleared selections properly:Noneinstead of being dropped from the payloadNone-valued keys before passing state toupdate_data()andfilter_data(), preserving the "key not in selection_store" convention used by update/filter logicNonevalues) is still echoed back to the frontend so all component instances can clear their local fieldstests/test_selection_clear.py: Added comprehensive test suite documenting the fix:
test_selecting_a_value_round_trips()— verifies normal selection flowtest_clearing_a_selection_round_trips_as_none()— validates the two invariants: (1) cleared fields echo back asNone, (2)Nonevalues are stripped for data computationtest_dropped_key_keeps_stale_value_regression()— documents the original bug and confirms the fix prevents itjs-component/dist/: Updated built assets (index-3e659711.js, index.html) to reflect frontend changes
Implementation Details
The fix relies on two key invariants:
None(App.vue mapsundefined → nullfor JSON serialization), and thisNoneis echoed back in the state so every component instance can clear the field locallyactive_statedict (withNonevalues filtered out) is passed to data computation functions, maintaining backward compatibility with existing update/filter logic that uses the "key not in selection_store" conventionThis approach allows the StateTracker to properly track state changes via round-tripping while preserving the existing data-computation semantics.
https://claude.ai/code/session_01TWkpASnLwnhMAQRxuYFpNs