Skip to content

Widget: general Jsonable widget, support pre / post slots in all widgets - #71

Open
hon-gyu wants to merge 16 commits into
mainfrom
hy/260729-cl-lib-enh
Open

Widget: general Jsonable widget, support pre / post slots in all widgets#71
hon-gyu wants to merge 16 commits into
mainfrom
hy/260729-cl-lib-enh

Conversation

@hon-gyu

@hon-gyu hon-gyu commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

::: ai-generated
Overview:

Replaces the old "empty result → text/plain fallback" mechanism with a compositional one:

  • New JsonableWidget — Python renders any JSONValue to YAML (yaml_utils.to_yaml_str) and syncs the string; the front end (src/jsonable/{fold,highlight,view,style}.ts) recovers fold structure from indentation alone and hand-rolls YAML highlighting, plus a toolbar (expand/collapse all, copy, line count).
  • pre / post slots on TasksWidget / RegionDecompWidget, stacked by src/common/stack.ts. Their native data traitlets become nullable: null drops the native panel entirely, [] still draws it with its own "No tasks." / "No regions."
  • nb_hooks now dumps the whole result into pre as YAML when the native panel would be empty, instead of text/plain.

:::

hon-gyu added 16 commits July 29, 2026 11:37
- fold: require whitespace after the `:`/`-` introducing a block scalar,
so a
  plain scalar merely ending in `-|` / `->` no longer swallows the keys
that
  follow it into an opaque block body
- fold: close a block-header node once its body is consumed, so a
trailing
  blank line lands after the fold rather than inside it
- nb_hooks: key a region decomposition's `pre` off `errors` as well as
off an
  empty panel -- a result can report errors *and* lay out region groups,
and
  those errors were going unreported
- nb_hooks: `# type: ignore` the nullable-traitlet assignments (stubs do
not
  model `allow_none`), keeping ty and pyright clean
- adapters: note that `nb_hooks` never sends `[]`, so the empty-array
path is
  reachable only for a directly constructed widget
Kept diffable, unlike the built bundles: pydantic2ts output is readable
and the
change is worth reviewing when a model changes.
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.

1 participant