Skip to content

Read lf-trace's Lit nodes through refs and let #paint read its own inputs - #2514

Merged
max-sixty merged 1 commit into
mainfrom
lit-trace-refs
Oct 12, 2026
Merged

max-sixty merged 1 commit into
mainfrom
lit-trace-refs

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Follow-up to #2346, from the review of the Lit survey PRs (item 36 in that review's numbering, not a GitHub issue). It finishes the Lit conversion of lf-trace, whose lifecycle already moved to whileConnected/frameFor in #2503.

Review item 36: lf-trace reads its Lit nodes through refs

  • Selector table removed. After each render, a 22-entry table queried the Lit output and stored nodes as public element properties (trace.play, trace.next, trace.body, ...). The template now binds each node the widget reads to a private createRef(). No test, widget or tool outside the widget read those properties. Only the table read the six transport classes lf-trace-first, -previous, -next, -zoom-in, -zoom-out and -zoom-fit, so they are gone from the markup.
  • #viewState() removed. It built a bag of eleven values that #paint() then unpacked. #paint now reads scope, extent, choices, origin and moments itself. #draw passes only the selected point, its saved tree and the tree rows, which it also uses for projection.
  • Other lookups after render. The missing-image note, input badge and point, and playback image are private fields. One helper now builds the playback image, which #placePlayback used to build a second time. Each capture figure keeps its canvas, image and status nodes, so #drawPicture no longer queries the figure by class. Three images.find calls now use #imageById. A Moment that targets a saved element finds its row in the part inventory instead of through a data-lf-datum query.
  • Hand-written labels. The position, selection and image-zoom labels are still written directly. A comment on #drawTime now says why: they change on every playback frame or pinch step, and #draw re-renders and re-projects.
  • Resize. The window resize listener the review saw beside the ResizeObserver was already removed in Draw the recording timeline on one time scale and remove Vis Timeline #2429, so the observer is the only thing that calls #resize.

Behaviour that changed: none visible to the user.

hand-written source tests
Item 36 (lf-trace.js) −20 (+210 −230) 0

Validation

  • These cases in tests/test_render_playwright_trace.py pass: comments restoring an exact image, bookmarks, comparison pairing, transport and playback, inspection through playback gaps and scope changes (it includes the saved-tree place checks), zoom and pan, the hidden recording, capture replacement, frames keeping saved elements, the play press, images at their capture times, and idle presentation.
  • Prettier and eslint pass.

This was written by Claude Code on behalf of max-sixty

…puts

Finishes the Lit conversion of lf-trace (#2346), review issue #36.

- The 22-entry selector table that queried the rendered view and stored
  nodes as public element properties (`trace.play`, `trace.next`,
  `trace.body`, ...) is gone. The template binds each node the widget
  reads to a private `createRef()`. Nothing outside the widget read those
  properties. The six transport classes only the table read
  (`lf-trace-first`, `-previous`, `-next`, `-zoom-in`, `-zoom-out`,
  `-zoom-fit`) are dropped from the markup.
- `#viewState()` built a bag of eleven values that `#paint()` unpacked.
  `#paint` now reads scope, extent, choices, origin and moments itself;
  `#draw` passes only the selected point, its saved tree and rows, which
  it also uses for projection.
- The overlays built beside Viewer (missing-image note, input badge and
  point, playback image) are private fields. The playback image's
  construction, which `#placePlayback` repeated, has one helper.
- Each capture figure keeps its canvas, image and status nodes, so
  `#drawPicture` no longer queries the figure by class. Three image
  lookups use `#imageById`, and a Moment that targets a saved element
  finds its row in the part inventory instead of querying `data-lf-datum`.
- The position, selection and image zoom labels stay hand-written; a
  comment on `#drawTime` now says why: they change on every playback
  frame or pinch step, and `#draw` re-renders and re-projects.

The window `resize` listener the review mentions beside the
ResizeObserver was removed in #2429; the observer is the only feed.

No user-visible behaviour changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 378aade into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the lit-trace-refs branch October 12, 2026 06:48
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.

2 participants