Skip to content

web/bugc-react: curated example selector for the docs BugPlayground#243

Merged
gnidan merged 1 commit into
transform-contextfrom
ui-bugplayground-examples
Jul 3, 2026
Merged

web/bugc-react: curated example selector for the docs BugPlayground#243
gnidan merged 1 commit into
transform-contextfrom
ui-bugplayground-examples

Conversation

@gnidan

@gnidan gnidan commented Jul 3, 2026

Copy link
Copy Markdown
Member

Ports a lean program selector into the docs BugPlayground widget (gnidan feature #33). The docs widget only ever showed a single program; the example picker previously lived only in the standalone packages/playground app. Not a regression — the docs widget never had one. Targets transform-context; additive, doesn't touch the tracer or #227.

Changes

bugc-react (reusable, testable home):

  • New bugExamples export — a curated trio: Counter, Function calls, Arrays & loops. Sources are distilled from packages/bugc/examples and stripped of the /*@test*/ behavioral-annotation blocks the raw files carry, so they read cleanly in an editor.
  • examples.test.ts asserts the set's shape and that each example compiles to bytecode without errors (guards against a typo in an inlined source).
  • Adds the missing vitest.config.ts so the package's already-declared test script runs (mirrors programs-react's).

web BugPlayground:

  • Optional examples prop (defaults to bugExamples) + an Example dropdown in the header controls.
  • Selector shows only when no initialCode is passed — so the bare playground page (<BugPlayground/>) gains it, while inline single-example doc embeds stay unchanged.
  • Selecting an example loads its source and recompiles (compile refactored to take an explicit source so a switch compiles the just-selected program, not stale state).

Design

Curated inline sources rather than a glob import: Docusaurus is webpack (the playground's import.meta.glob is Vite-only), and inlining keeps the widget self-contained and lets us curate clean, annotation-free sources. Decisions approved by team-lead/gnidan (third example = arrays/loops; home = bugc-react; visibility = no-initialCode).

Verification

  • TDD: 6 bugc-react tests green (structure + compile-checks for all three examples).
  • Build + lint clean; no type errors in the changed files.
  • UI wiring mirrors the existing optimizer selector; the deploy-preview renders the dropdown for eyeball confirmation.

Placement on the #227 Explore page is being coordinated with docs; the bare embed auto-gains the selector with no MDX change.

The docs BugPlayground only ever showed one program; the example
picker lived in the standalone packages/playground app. Port a lean
version into the docs widget (gnidan #33).

- bugc-react: add a curated `bugExamples` set (Counter, Function calls,
  Arrays & loops) as a reusable export. Sources are distilled from
  packages/bugc/examples and stripped of the `/*@test*/` behavioral
  annotations the raw files carry, so they read cleanly in an editor.
  examples.test.ts asserts each compiles to bytecode without errors
  (guards against a typo in an inlined source); adds the missing
  vitest.config.ts so the package's test script runs.
- web BugPlayground: add an optional `examples` prop (defaults to
  bugExamples) and an Example dropdown in the header controls. The
  selector shows only when no `initialCode` is passed — so the bare
  playground page gains it while inline single-example doc embeds stay
  unchanged. Selecting an example loads its source and recompiles.

Additive; does not affect the tracer or #227. Example sources verified
to compile via the new tests; UI wiring mirrors the existing optimizer
selector.
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-03 21:58 UTC

@gnidan gnidan merged commit a30fd19 into transform-context Jul 3, 2026
4 checks passed
@gnidan gnidan deleted the ui-bugplayground-examples branch July 3, 2026 21:54
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