Skip to content

[codevoyager] fix: persist legend track visibility state across configuration changes#498

Open
codevoyager-ai-dev wants to merge 1 commit into
vgteam:masterfrom
codevoyager-ai-dev:codevoyager-1784311353
Open

[codevoyager] fix: persist legend track visibility state across configuration changes#498
codevoyager-ai-dev wants to merge 1 commit into
vgteam:masterfrom
codevoyager-ai-dev:codevoyager-1784311353

Conversation

@codevoyager-ai-dev

Copy link
Copy Markdown

Issue

When viewing genome graphs with many tracks (e.g., from Cactus which generates 'fake' ancestral genomes), unchecking unwanted tracks in the Legend was tedious because the checked/unchecked state was lost whenever the configuration changed (switching reference, region, removing variants, or node sequences).

Closes #464

Solution

The checked/unchecked state of haplotype tracks in the Legend is now persisted in React state (App.js visOptions.hiddenTracks) and flows through the component hierarchy to the D3 tubemap rendering engine.

Key changes:

  1. src/util/tubemap.js

    • Added hiddenTrackIds (Set) and visibilityChangedCallback to the module config
    • Exported setHiddenTrackIds(), getHiddenTrackIds(), setVisibilityChangedCallback()
    • create() now applies persisted hidden tracks to inputTracks after deep copy
    • changeTrackVisibility() and changeAllTracksVisibility() update the hidden state and notify React via callback
    • drawLegend() now iterates over inputTracks (all tracks, not just the filtered subset) and sets checkbox state based on hiddenTrackIds
  2. src/App.js

    • Added hiddenTracks: [] to visOptions state (persists across viewTarget changes)
    • Added handleTrackVisibilityChanged to update hiddenTracks when the user toggles tracks
  3. src/components/TubeMap.js / TubeMapContainer.js

    • Added onTrackVisibilityChanged prop chain
    • TubeMap sets up the visibility callback and calls setHiddenTrackIds() on every render
  4. src/util/tubemap.test.js

    • Added 9 new tests covering setHiddenTrackIds, getHiddenTrackIds, and setVisibilityChangedCallback

Testing

  • All 28 tubemap tests pass (including 9 new)
  • All existing component tests pass
  • Pre-existing failures in scripts.test.js and end-to-end.test.js are environment-related and unchanged

…guration changes

The issue was that unchecked tracks in the Legend would reset to checked
whenever the configuration changed (reference, region, etc.). This happened
because the hidden state was stored only in module-level variables in
tubemap.js that were lost when the visualization was recreated.

Changes:
- Added hiddenTrackIds and visibilityChangedCallback to tubemap.js config
- Added setHiddenTrackIds/getHiddenTrackIds/setVisibilityChangedCallback exports
- Modified create() to apply persisted hidden tracks and set track types
- Modified changeTrackVisibility/changeAllTracksVisibility to update hidden state
- Modified drawLegend() to use inputTracks and reflect actual hidden state
- Added hiddenTracks to visOptions in App.js for React-level persistence
- Added onTrackVisibilityChanged callback chain: App -> TubeMapContainer -> TubeMap
- TubeMap component sets the visibility callback and hidden track IDs on the tubemap

Closes vgteam#464
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.

Legend state / samples checked not stored when modifying configuration

1 participant