StatifierUI.Kino (StatifierUI v0.2.0)

Copy Markdown View Source

The Livebook inspector: inspect/3 composes the four panes - configuration diagram, datamodel explorer, event injection, event log - over one shared StatifierUI.Trace.Subscriber, attached with catch-up (statifier ADR-0049), inside one Kino.Layout.

Compiled only when the optional :kino dependency is present (ADR-0004); a host without it gets a stub whose inspect/3 raises with instructions. Nothing else in this package touches Kino.

Lifecycle

Every process this module starts - the subscriber and the updater - goes through Kino.start_child/1, so re-evaluating the cell terminates them with it. The session notices the dead subscriber through its own monitor and drops it from its subscriber set: that is the clean detach, with nothing to unsubscribe by hand. The session itself is not owned here - it keeps running across cell re-evaluations, which is exactly what makes catch-up worth having.

Catch-up needs record: true

Start the session with record: true (and trace: true) for the inspector to reconstruct everything it missed. Without it the subscriber falls back to live delivery and the status header labels the panes Live-only - a partial stream is never presented as whole. Replay cost grows with run length (it re-runs the recording in the attaching process), so expect cell evaluation on a very long-lived session to take correspondingly longer.

Summary

Functions

Builds the inspector for session and returns the composed Kino.Layout for the cell to render.

Renders every bundle a palette discovery found, one panel after another, as a single Kino.Markdown widget.

Renders one fragment's fixture bundle as its "test this step" panel - its truth table plus its expectation results (sui-13q) - as a Kino.Markdown widget.

Renders fixtures' truth table - every expression evaluated across every dataset (ADR-0006) - as a Kino.Markdown widget.

Functions

inspect(session, fixtures \\ nil, opts \\ [])

@spec inspect(pid(), StatifierUI.Fixtures.t() | nil, keyword()) :: Kino.Layout.t()

Builds the inspector for session and returns the composed Kino.Layout for the cell to render.

fixtures is a StatifierUI.Fixtures.t/0 (or nil): it feeds the injection palette's per-event buttons. opts:

  • :source - the SCXML text, forwarded to the subscriber for the session.start manifest.
  • :capacity - the subscriber's buffer capacity (default 1000).

palette_panel(discovery, opts \\ [])

Renders every bundle a palette discovery found, one panel after another, as a single Kino.Markdown widget.

discovery is what StatifierUI.Fixtures.Bundle.discover/2 or discover_dir/2 returned.

test_panel(bundle, opts \\ [])

@spec test_panel(
  StatifierUI.Fixtures.Bundle.t(),
  keyword()
) :: Kino.Markdown.t()

Renders one fragment's fixture bundle as its "test this step" panel - its truth table plus its expectation results (sui-13q) - as a Kino.Markdown widget.

Like truth_table/2, independent of inspect/3 and of any session: a bundle is a fact about one palette entry's examples, so this needs no running chart. opts go to StatifierUI.Fixtures.Bundle.Markdown.render/2, which forwards each one to the layer that owns it.

truth_table(fixtures, opts \\ [])

@spec truth_table(
  StatifierUI.Fixtures.t(),
  keyword()
) :: Kino.Markdown.t()

Renders fixtures' truth table - every expression evaluated across every dataset (ADR-0006) - as a Kino.Markdown widget.

Independent of inspect/3 and of any session: a truth table is a fact about expressions and datasets, so this needs no running chart and no Phoenix. opts are split by owner - :expressions, :datasets, :functions, and :providers go to StatifierUI.TruthTable.build/2, and the rest to StatifierUI.TruthTable.Markdown.render/2.