WIP: feat(vscode): live preview — per-step diagrams synced to cursor (#42) #53

Closed
toph wants to merge 18 commits from vscode-preview into main
Owner

Third VSCode subsystem, on the foundation (#44) + highlighting (#48): a cursor-synced live preview. Two phases in one vertical.

Phase 1 — evaluator, closes the first stages of #42. The evaluator now snapshots its folded state at each step boundary, and fold_emit emits one self-contained foldedForm frame per step (baseline + one per panel), each tagged beloch:step. Exact (Num), float only at the FOLD boundary. Multi-step programs like cube-root.bel now emit 4 frames with face counts growing 1→2→4→8; through.bel (no steps) stays 1 frame.

Phase 2 — renderer + webview. fold2svg gains data-step/data-construction hooks + a --step selector, and overlays only auxiliary named constructions (not the ones already drawn as creases/corners). The webview is a dumb SVG display: the host renders CP + per-step folded SVGs via resolveBeloch() + fold2svg, and the webview drives all controls by CSS/DOM — CP/folded toggle, sync on/off (off = step manually), construction selector, current-step highlight. No fold geometry client-side; re-render only on document change.

No animation in this slice — all interpolation / rigid-fold rotation / per-face isometries (#31) / 3D are deferred to a future 3D-viewer slice (see #30, ADR 0015).

Built and reviewed task-by-task (each task + fix has an adversarial review in the trail).

WIP — not ready to merge:

  • Task 6 (dogfood packaging: .vsix script + F5 launch config + README documenting both dev-host and install paths + manual smoke-test) still landing.
  • The branch currently carries a few interleaved design-doc commits (ADR 0014, #31 spec/plan) that belong on main separately; needs a cleanup rebase before merge.

For #42. Groundwork relates to #31.

Third VSCode subsystem, on the foundation (#44) + highlighting (#48): a cursor-synced live preview. Two phases in one vertical. **Phase 1 — evaluator, closes the first stages of #42.** The evaluator now snapshots its folded state at each `step` boundary, and `fold_emit` emits one self-contained `foldedForm` frame per step (baseline + one per panel), each tagged `beloch:step`. Exact (`Num`), float only at the FOLD boundary. Multi-step programs like `cube-root.bel` now emit 4 frames with face counts growing 1→2→4→8; `through.bel` (no steps) stays 1 frame. **Phase 2 — renderer + webview.** `fold2svg` gains `data-step`/`data-construction` hooks + a `--step` selector, and overlays only *auxiliary* named constructions (not the ones already drawn as creases/corners). The webview is a dumb SVG display: the host renders CP + per-step folded SVGs via `resolveBeloch()` + `fold2svg`, and the webview drives all controls by CSS/DOM — CP/folded toggle, sync on/off (off = step manually), construction selector, current-step highlight. No fold geometry client-side; re-render only on document change. No animation in this slice — all interpolation / rigid-fold rotation / per-face isometries (#31) / 3D are deferred to a future 3D-viewer slice (see #30, ADR 0015). Built and reviewed task-by-task (each task + fix has an adversarial review in the trail). **WIP — not ready to merge:** - Task 6 (dogfood packaging: `.vsix` script + F5 launch config + README documenting both dev-host and install paths + manual smoke-test) still landing. - The branch currently carries a few interleaved design-doc commits (ADR 0014, #31 spec/plan) that belong on `main` separately; needs a cleanup rebase before merge. For #42. Groundwork relates to #31.
toph added 14 commits 2026-07-03 20:08:52 +00:00
Records the durable decision that a crease name denotes a bundle of material
segments (not a line), with the singleton-target rule and the at/pinch
mechanisms deferred to a later slice. Supersedes #28's #(...) escape hatch.
Adds an Appendix B forward-pointer in the spec.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dj7AUAseHeFtET11b86S4y
Each crease element now carries class="crease-M/V/U" and data-step (from
beloch:edges provenance) so a webview can style/select by CSS/DOM. Named
constructions (beloch:named_points/named_lines) are wrapped in
<g class="construction" data-construction="name">, rendered by default for
every name (--constructions, if given, narrows the set) — the webview
toggles visibility itself rather than asking the renderer to omit entries.

Add --step <id> to pick which file_frames entry the folded view renders,
matching on its beloch:step tag; unmatched/omitted falls back to the last
frame. foldedFrame(fold, step) gains the same optional step arg and now
defaults to the LAST frame instead of frames[0] — the correct default now
that file_frames holds one frame per step (Phase 1, #42); existing
single-frame fixtures are unaffected since frame 0 === the last frame there.

New fixtures tools/test/fixtures/{x-midpoint,cube-root}.fold (generated via
`beloch fold`) exercise the hooks and multi-step selection.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016FYbXyypfVm4RdPLGBdWYw
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016FYbXyypfVm4RdPLGBdWYw
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Stacked on #53 — base is `vscode-preview`.

Emits each folded face's paper→table isometry as `beloch:faces_matrix` and declares the named-line frame (`beloch:named_lines_frame: "creasePattern"`). Ports `fold2svg` to consume the isometry and deletes the float-vertex-pair reconstruction (`applyIso` plus its shoelace reflection detection) — the renderer no longer re-derives, in JS floats, a transform the exact core already holds in `face.iso`. Topology (vertex coincidence, layer order) is already decided exactly upstream and carried as integers, so float coefficients are sufficient here.

Also fixes a pre-existing clip bug the port surfaced: the folded overlay clipped named lines against the final crease pattern's vertices even for intermediate `--step` frames, whose face indices belong to a different dedup pass. It now pulls each line into the face's own table frame (`lineToFace`) and clips against that frame's polygon, dropping the crease-pattern index dependence.

Exact coordinates stay out of scope — rendering lands on float regardless and nothing verifies exactness yet; the reasoning is in #31. The golden-regen tool lives at `tools/regen.ml`.

Follow-up: #54 (integration fixture for the folded named-line overlay).

For #31.

---

`cube-root.bel` folded top view — creases placed on each folded face via the emitted isometry:

![cube-root folded](https://git.toph.so/attachments/a5d7a64e-147f-4ccc-8257-84f6940f600a)

Reviewed-on: #55
toph closed this pull request 2026-07-04 18:46:22 +00:00
Author
Owner

Superseded by #60 — same work, cleanly rebased onto current main (interleaved design-doc / #55 commits dropped). Merged there.

Superseded by #60 — same work, cleanly rebased onto current main (interleaved design-doc / #55 commits dropped). Merged there.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
toph/beloch!53
No description provided.