app.state
Centralized application state for Phylo.
All shared mutable state lives in defonce atoms so it survives shadow-cljs hot reloads. Components access state through a single React context (app-context) provided by AppStateProvider, and read it via the use-app-state convenience hook.
State atoms: - !newick-str - the current Newick tree string - !parsed-tree - pre-parsed tree map (e.g. from Nextstrain import) - !metadata-rows - parsed metadata rows (vector of maps) - !active-cols - column header configs for metadata display - !x-mult - horizontal zoom multiplier - !y-mult - vertical tip spacing (pixels) - !show-internal-markers - whether to show markers on internal nodes - !show-scale-gridlines - whether to show scale (distance) gridlines - !show-distance-from-origin - whether to show internal node distance labels - !show-distance-from-node - whether to show distances from the ctrl-clicked reference node - !align-leaf-labels - whether to align leaf labels to a common right edge - !scale-origin - scale origin for labels (:tips or :root) - !branch-length-mult - multiplier applied to branch lengths for display (e.g. number of core SNP sites) - !scale-units-label - label string for scale units (e.g. “SNPs”) - !show-pixel-grid - whether to show pixel-coordinate debug grid - !col-spacing - extra horizontal spacing between metadata columns - !left-shift-px - horizontal shift applied to tree + metadata overlay - !tree-metadata-gap-px - extra spacing between tree and metadata table - !metadata-panel-collapsed - whether the metadata grid panel is collapsed - !metadata-panel-height - current height of the metadata grid panel - !metadata-panel-last-drag-height - last height set via drag - !highlight-color - CSS color string used as the current brush color - !selected-ids - set of leaf IDs selected in the AG-Grid - !highlights - map of {leaf-id -> color} for persistent highlights - !legend-pos - top-left legend position in SVG user space - !legend-collapsed? - whether the legend is collapsed - !legend-labels - map of {color-hex -> label} for custom colors - !legend-visible? - whether the legend is visible
!active-cols
!active-reference-node-id
!align-leaf-labels
!branch-length-mult
!col-spacing
!color-by-enabled?
!color-by-field
!color-by-palette
!color-by-type-override
!highlight-color
!highlights
!left-shift-px
!legend-collapsed?
!legend-labels
!legend-pos
!legend-visible?
!metadata-panel-collapsed
!metadata-panel-height
!metadata-panel-last-drag-height
!metadata-rows
!newick-str
!parsed-tree
!positioned-tree
!scale-origin
!scale-units-label
!selected-ids
!show-distance-from-node
!show-distance-from-origin
!show-internal-markers
!show-pixel-grid
!show-scale-gridlines
!tree-metadata-gap-px
!x-mult
!y-mult
app-context
React context carrying the app state map. Provided by AppStateProvider, consumed via use-app-state.
apply-export-state!
(apply-export-state! payload)Applies an exported state payload into the live atoms.
Missing keys fall back to defaults so exports remain forward-compatible.
AppStateProvider
(AppStateProvider props__5701__auto__)Wraps children with the app state context.
Subscribes to all state atoms via uix/use-atom so that any atom change triggers a re-render of consumers. Setter functions are wrapped in use-callback with empty deps for stable identity (atoms are module-level defonce). The context value map is memoized via use-memo so its object identity only changes when an atom value actually changes.
default-tree
Initial value for the Newick tree string. nil means no tree loaded; the UI shows a placeholder.
export-state
(export-state)Returns a versioned, EDN-serializable snapshot of app state.
Intended for embedding into standalone HTML exports.
use-app-state
(use-app-state)Convenience hook returning the app state map from context.
Must be called inside a component wrapped by AppStateProvider. Returns a map with all state values and setter functions — see AppStateProvider for the full key listing.