Skip to content

Fix selection clearing round-trip in multi-component state sync#89

Merged
t0mdavid-m merged 1 commit into
developfrom
claude/peaceful-keller-CGKm2
May 29, 2026
Merged

Fix selection clearing round-trip in multi-component state sync#89
t0mdavid-m merged 1 commit into
developfrom
claude/peaceful-keller-CGKm2

Conversation

@t0mdavid-m
Copy link
Copy Markdown
Member

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:

    • Cleared selections now arrive as None instead of being dropped from the payload
    • Added filtering logic to strip None-valued keys before passing state to update_data() and filter_data(), preserving the "key not in selection_store" convention used by update/filter logic
    • Full state (including None values) is still echoed back to the frontend so all component instances can clear their local fields
    • Fixed trailing whitespace
  • tests/test_selection_clear.py: Added comprehensive test suite documenting the fix:

    • test_selecting_a_value_round_trips() — verifies normal selection flow
    • test_clearing_a_selection_round_trips_as_none() — validates the two invariants: (1) cleared fields echo back as None, (2) None values are stripped for data computation
    • test_dropped_key_keeps_stale_value_regression() — documents the original bug and confirms the fix prevents it
  • js-component/dist/: Updated built assets (index-3e659711.js, index.html) to reflect frontend changes

Implementation Details

The fix relies on two key invariants:

  1. When a selection is cleared, the frontend sends None (App.vue maps undefined → null for JSON serialization), and this None is echoed back in the state so every component instance can clear the field locally
  2. The active_state dict (with None values filtered out) is passed to data computation functions, maintaining backward compatibility with existing update/filter logic that uses the "key not in selection_store" convention

This 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

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
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

Warning

Review limit reached

@t0mdavid-m, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b64b9815-dfa6-4751-86de-866508fa5c4d

📥 Commits

Reviewing files that changed from the base of the PR and between d0028fa and c684255.

⛔ Files ignored due to path filters (2)
  • js-component/dist/assets/index-3e659711.js is excluded by !**/dist/**
  • js-component/dist/index.html is excluded by !**/dist/**
📒 Files selected for processing (2)
  • src/render/render.py
  • tests/test_selection_clear.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/peaceful-keller-CGKm2

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@t0mdavid-m t0mdavid-m merged commit a89427d into develop May 29, 2026
7 checks passed
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.

2 participants