Skip to content

Encode every spec as a DashboardSpec and decode only that form #83

Closed as not planned

Description

@jvdd

Problem

The spec codec accepts two root forms: a DashboardSpec and a single-figure VisualizationSpec. No public path makes an encoded VisualizationSpec:

  • Figure.show wraps its spec into a one-figure DashboardSpec before it renders.
  • The page always holds a DashboardSpec, and the Share button posts that spec.
  • Dashboard.share_url encodes a DashboardSpec.
  • encode_spec, decode_spec and VisualizationSpec are not exported from flexviz/__init__.py and are not in the docs.

But four decode sites unwrap the single-figure form: _render_spec_html in server.py, _state_url in history.py, report.py, and _state_only in cli.py. parse_spec also dispatches on the "figures" key.

VisualizationSpec.state has no effect on the Figure path: Figure.to_spec writes an empty state, and Figure.from_spec does not read it.

Fix direction

  • encode_spec wraps a VisualizationSpec into a one-figure DashboardSpec.
  • decode_spec returns only a DashboardSpec.
  • Delete the "figures" dispatch in parse_spec and the four unwrap branches.
  • Keep a guard: a dict without "figures" must raise. Without the dispatch, DashboardSpec ignores the extra keys and defaults figures to []. A single-figure dict posted to /share, or an old encoded URL, then becomes an empty dashboard with no error. Make figures required, or reject a dict without it.
  • About 10 tests assert that a decoded spec is a VisualizationSpec: test_integration::TestShareAndView::test_share_returns_url, several tests in test_spec.py, and TestEncodeDecodeFullState. Update them.
  • Update the Figure.from_spec docstring (it says the input can come from decode_spec) and the codec text in Architecture.md.
  • Consider whether VisualizationSpec needs a state field at all.

Activity

  1. added
    enhancement
    on Sep 24, 2026
  2. jvdd commented on Sep 29, 2026

    @jvdd
    ContributorAuthor

    Superseded by #87 (decision 2026-09-29): the standalone Figure path is removed, so the codec has only the DashboardSpec form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions