Preview: make the cursor sync line-aware (what each line creates/uses) + editor feedback #59

Open
opened 2026-07-04 18:28:12 +00:00 by toph · 0 comments
Owner

Dogfooding the live preview (#53): it loads and roughly follows the cursor, but the sync feels coarse and semantically thin. Three related gaps, all pointing at the same missing capability — a line-aware preview that knows what the current source line does.

What's off

  1. Step-granular, jumps. Sync maps the cursor line to the step panel it sits in (stepAtLine over beloch:edges[].span). Moving within a step does nothing; it only changes at step boundaries, so it feels like it jumps. Fine for the MVP, but coarse.

  2. No editor-side feedback. You only see the active step in the preview panel, not in the editor. A gutter marker / line decoration for the step (or construction) the preview is currently showing would close the loop.

  3. The preview doesn't show what the current line creates or uses. This is the big one. On a line like ._pq1 = cross --(.d ._mb) --(.a .c) the preview gives no hint that this line creates ._pq1 and uses ._mb. The construction selector is a single global list, and for cube-root.bel it lists only .s — because:

    • temp points (._mb, ._pq1, ._pq2, ._rs1, ._rs2, ._mb, ._mt) are filtered out of beloch:named_points by fold_emit (is_temp);
    • named lines pq/vm/rs are all also creases, so the auxiliary-only overlay filter (correctly, for rendering) drops them;
    • corners a/b/c/d are corners, also dropped.
      So the one surviving auxiliary construction is .s. The auxiliary-only filter is right for what to draw (avoid double-drawing creases/corners), but "what does this line build/reference" is a different concern that should include temps, creases, and corners with their roles.

Desired

A cursor-aware, line-level preview:

  • Given the current source line, surface the constructions it creates (its LHS binding) and uses (the operands on its RHS), highlighting them in the rendered diagram.
  • Editor feedback for the active step/line (decoration or gutter).
  • Optionally finer-than-step granularity (highlight just the current line's crease/points rather than snapping to the whole step frame).

What it needs

  • A provenance mapping from a source line to the named entities it creates/uses. The evaluator already carries most of this: beloch:edges[] have .span, .sources, .name; named bindings have spans. A per-line "creates/uses" index could be emitted (or derived).
  • Surfacing temps when relevant (they're currently invisible in the FOLD's named sets).
  • A UI that reacts to the cursor line, not just the step.

Deferred polish/enhancement, captured from the first dogfooding session. Relates to the live-preview slice (#53).

Dogfooding the live preview (#53): it loads and roughly follows the cursor, but the sync feels coarse and semantically thin. Three related gaps, all pointing at the same missing capability — a **line-aware preview** that knows what the current source line does. ## What's off 1. **Step-granular, jumps.** Sync maps the cursor line to the `step` panel it sits in (`stepAtLine` over `beloch:edges[].span`). Moving *within* a step does nothing; it only changes at step boundaries, so it feels like it jumps. Fine for the MVP, but coarse. 2. **No editor-side feedback.** You only see the active step in the preview panel, not in the editor. A gutter marker / line decoration for the step (or construction) the preview is currently showing would close the loop. 3. **The preview doesn't show what the current line creates or uses.** This is the big one. On a line like `._pq1 = cross --(.d ._mb) --(.a .c)` the preview gives no hint that this line *creates* `._pq1` and *uses* `._mb`. The construction selector is a single global list, and for `cube-root.bel` it lists only `.s` — because: - temp points (`._mb`, `._pq1`, `._pq2`, `._rs1`, `._rs2`, `._mb`, `._mt`) are filtered out of `beloch:named_points` by `fold_emit` (`is_temp`); - named lines `pq`/`vm`/`rs` are all also creases, so the auxiliary-only overlay filter (correctly, for *rendering*) drops them; - corners `a`/`b`/`c`/`d` are corners, also dropped. So the one surviving auxiliary construction is `.s`. The auxiliary-only filter is right for *what to draw* (avoid double-drawing creases/corners), but "what does this line build/reference" is a different concern that should include temps, creases, and corners with their roles. ## Desired A cursor-aware, line-level preview: - Given the current source line, surface the constructions it **creates** (its LHS binding) and **uses** (the operands on its RHS), highlighting them in the rendered diagram. - Editor feedback for the active step/line (decoration or gutter). - Optionally finer-than-step granularity (highlight just the current line's crease/points rather than snapping to the whole step frame). ## What it needs - A provenance mapping from a source **line** to the named entities it creates/uses. The evaluator already carries most of this: `beloch:edges[]` have `.span`, `.sources`, `.name`; named bindings have spans. A per-line "creates/uses" index could be emitted (or derived). - Surfacing temps when relevant (they're currently invisible in the FOLD's named sets). - A UI that reacts to the cursor line, not just the step. Deferred polish/enhancement, captured from the first dogfooding session. Relates to the live-preview slice (#53).
Sign in to join this conversation.
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#59
No description provided.