feat(view): composable, URL-syncable dashboard config - #6
Merged
Conversation
Make the dashboard config the complete, JSON-serializable, composable source of truth, bound bidirectionally to the view, with optional URL persistence. Additive and backward compatible for the view API. Config mirrors the panel composition: - Component configs: TreeConfig (compact selected-keys, not the full Wunderbaum source), PlotControlsConfig, DownsampleConfig. - Each view owns its config class via config_cls; the concrete view configs (DataToolViewConfig, ProcessObjectViewConfig, DataToolPlotControlsConfig) live next to their view. Base BaseViewConfig has extra="allow" + validate_assignment so subclass/unknown fields and field mutation survive round-trips. Binding (BaseDataView): get_config / set_config / on_config_change, an overridable _apply_config hook, an _applying_config reentrancy guard, and _coerce_config so a base config passed to a concrete view is upgraded. The JSON editor is removed - every PlotControlsConfig field now has a native widget. User edits write through into the config and emit a change; set_config applies a config back to the widgets. URL sync: a generic UrlConfig[T] (Pydantic <-> pn.state.location) with three modes - PLAIN_KEYS, JSON and COMPRESSED_BASE64 (default). Opt-in per view via url_sync / url_mode; a host can URL-sync one aggregate parent config instead. Generic datetime/unit helpers moved to _channel_utils. Examples: datatool/process use COMPRESSED, downsample JSON, and a new composed_dashboard.py shows the host composition pattern (one AppConfig aggregating per-view sub-configs + active tab, URL-synced in PLAIN_KEYS) in a Panelini shell. Screenshots re-rendered with a synthetic address bar so the URL-synced state is visible. Tests: config round-trip (incl extra field), UrlConfig all three modes, view set/get_config apply, write-through + on_config_change, a full URL<->UI browser round-trip, and the aggregate-config composition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the dashboard config the complete, JSON-serializable, composable source of truth, bound bidirectionally to the view, with optional URL persistence. Additive/backward-compatible for the view API (
LiveDataToolViewunaffected at the view level).Config mirrors the panel composition
TreeConfig(compact selected-keys, not the full Wunderbaum source),PlotControlsConfig,DownsampleConfig.config_cls; the concrete view configs (DataToolViewConfig,ProcessObjectViewConfig,DataToolPlotControlsConfig) live next to their view.BaseViewConfighasextra="allow"+validate_assignmentso subclass/unknown fields and field mutation survive round-trips.Bidirectional binding (
BaseDataView)get_config/set_config/on_config_change, an overridable_apply_confighook, an_applying_configreentrancy guard, and_coerce_config(a base config passed to a concrete view is upgraded). The JSON editor is removed - everyPlotControlsConfigfield now has a native widget (grouping, cache, downsampling group, ...). User edits write through into the config and emit a change;set_configapplies a config back to the widgets.URL sync
Generic
UrlConfig[T](Pydantic <->pn.state.location) with three modes: PLAIN_KEYS (readable dot-flattened, JSON-encoded leaves), JSON (readable single param), COMPRESSED_BASE64 (default). Opt-in per view (url_sync/url_mode); a host can URL-sync one aggregate parent config instead.Examples
datatool/processuse COMPRESSED,downsampleJSON, and a newcomposed_dashboard.pyshows the host composition pattern - oneAppConfigaggregating per-view sub-configs + active tab, URL-synced in PLAIN_KEYS - in a Panelini shell. Screenshots re-rendered with a synthetic address bar so the URL-synced state is visible.Tests
Config round-trip (incl.
extrafield),UrlConfigall three modes, viewset/get_configapply, write-through +on_config_change, a full URL<->UI browser round-trip, and the aggregate-config composition. Full offline suite + browser tests green; flake8 clean.Note
Removes
LiveDashboardConfig/LiveConfigfrom base (the Live view lives inopensemantic.lab). A follow-up lab PR defines its ownLiveConfig/LiveDataToolViewConfigand adaptsLiveDataToolViewto the new binding.