Repository navigation
Take a comment on the point an lf-chart's reader is on, named by its datum - #6371
Merged
Merged
Conversation
An `lf-chart` was one comment target, so ⌥ over a chart aimed the whole
drawing. A comment now takes the point the chart's own aim is on: a dot,
a line's vertex or a bin, picked by Plot's pointer rule as the preview
already is.
- ⌥ and a click take the point the pointer reads, or after Escape or a
press put its reading away, the point it rests on. Leaf's aim strokes
a mark round the chart's ring, and the comment box is named by what
the preview says: "§ chart · week 6, offline sessions 8,412".
- A modifier alone no longer puts a pointer's preview away, as the key
dispatcher already reads a lone modifier as half a press. Without
that, ⌥ held after the reading showed took the reading and its ring
away, so the aim stood on an unmarked point.
- With the chart focused, `c` comments on the point the arrow keys
reached. On touch, the target picker takes a tapped point.
- The comment's anchor is `{section: <chart>, visual: "point:…"}`. The
id is the identity chart-points already kept to hold the reader on
their datum across redraws, written as one readable token, the mark's
place and each channel's value: `point:0;x=6;y=8412`. So an agent
reading the comment reads the datum.
- After a reload or a redraw the chart draws a mark round each point a
comment names, which Leaf strokes while the comment is in play and
travels to. A comment whose datum the drawing lacks stands on the
whole chart, named by its values, as one in a shut tab does until the
tab opens and the chart draws.
`registerVisualParts` takes two more lookups for a visual too large to
list. `find(id)` returns one part by its id, where Leaf searched
`read()`. `at(node)` names the part a hit stands for where the walk up
from the hit finds no registered element, since a line draws no
element per datum; focus on the visual asks it of the visual itself
(`focusTargetAt`), so the picker's reading of the chart stays whole. A
part `find` doesn't find stands on the whole visual, as an undrawn part
of a revealing visual does. The chart's `read()` lists no point, so the
picker's hints and a screen reader's proxies offer the chart alone, and
the work grows with the comments, not the data. A mark Leaf finds stays
until the next drawing, so one stands, unseen, at each point the keys
reach, as the resting comment bar asks for each.
Measured on a 100,000-dot chart, against main:
- ⌥ keydown: 1.0 ms here, 189 ms on main, where the whole-chart aim
restyled every dot (1.4 ms and 3.9 ms at 1,000 dots).
- Load to presentation: 1,491-1,904 ms here and 1,703-1,793 ms on main
over three runs each, on a loaded host; the chart registers no point
until a comment names one.
- A comment's first lookup in a drawing files the drawing's points by
where they stand, one pass: 14 ms for 100,000 dots and 28 ms for a
100,000-point two-series line, in Node. Each lookup then reads the
points at one place, under 0.2 ms.
A datum's id holds every channel value, so a comment on a datum whose
measure changes, or on a stacked segment whose neighbours change, falls
back to the whole chart.
Tests: browser tests for the ⌥, keyboard, reload, resize, travel and
shut-tab routes, in Chromium and Firefox for the aims; runtime tests for
`find`, `at`, the focus route and the datum token. A `chart-point-aim`
state shows the aim in `leaf-dev stills`.
A drawing filed its points by the first channel they stand at, so each lookup scanned every point sharing that value: a chart whose points share x scanned the whole drawing for each comment. The first lookup now names every point once and each lookup after it is one map read, whatever the data's shape. Measured in Node on 100,000 dots: the first lookup takes 65 ms here against 27 ms filed by place, and five more take 0.01 ms here against 0.03 ms where x is spread and 31 ms where five values of x hold them all.
…in's outline Review of the point comments found three things wrong in use. - A point's thread belonged to focus anywhere on its chart. A thread on a part of a picture stands at the picture, so `threadIdsAt` found it for focus on the chart wherever the keys stood, and `c` on any other point, or on the whole chart after Escape, wrote a reply to it. A thread on a part is now at a node inside that part, or at the picture where focus there stands on that part (`focusTargetAt`). And `c` continues a thread naming the very target the user stands on, as a chart's keys standing on its commented point do, though the point's mark is not the element focus holds. - Leaving a comment box on a point put focus on the point's mark, an invisible shape inside the chart's image. A stop is no longer lent inside an image or a hidden subtree, where a screen reader can't stand; the box hands a part's user back to the drawing ahead of its proxy; and the chart keeps the point the keys left it on, so the reader lands on the point they commented on. Closing a sent thread's card still lets go onto the page beside the chart, as it does for a comment on the whole chart and on any other target. - A bin's mark was a 7 px ring at the bar's middle, near invisible on the bar. A point whose shape fills a box along both axes, a bar, a bin or a cell, is marked and aimed by an outline of that box (`extentOf`); a dot's and a line vertex's stay rings, drawn by one rounded rect. A commented point at rest and under its margin entry's pointer shows what a commented diagram node does on main: nothing at rest, a trace round the whole picture, and the entry named for the picture. Tests: a browser test for `c` on another point, on the whole chart and on the commented point, and for the return to the point, in Chromium and Firefox; the reload test checks a bin's mark outlines its bar; a runtime test reads a bar's and a bin's box against Plot's shape.
…s Plot drew it Review of 90d9a96 found five things wrong. - Leaving a comment made with ⌥ on a point put focus on the chart at its first point, since the chart picked up whichever point it last read. And the rule that lent no focus stop inside an image left focus on a link to an authored shape in a picture, and on any travel to a chart point, where main had moved it. The rule is gone; focus.js is as on main. A visual part now names the element Leaf puts the user on for it (`focus`, defaulting to the part's element), and Leaf asks the visual to `reveal` the part first. The chart names itself and, on `reveal`, settles its next focus on the point, whatever the pointer read since. Travel to a thread on a part, a link to a part's key, and the hand back from a comment on a part all go through it (`addressedFocus`). - A thread on the whole chart came ahead of the thread on the point the keys stand on, so `c` started a second thread on the point. A thread on the part focus stands on now outranks one on the whole picture, as a pointed row does. - `threadIdsAt` asked a node inside a diagram's part what part it stands on, which read the diagram's whole inventory. Only focus on the visual itself asks it (`focusedVisualPart`); a node inside another part is about that part. - A bin's outline was guessed from the scales and missed insets, ringed a bar with no categorical axis and boxed a dot on two. The chart now marks a bar, bin or cell on the very `<rect>` Plot drew for the datum, read from what each mark drew (`shapeOf`), and rings a dot or a line's vertex. Decided: `focus` on the part rather than more meaning in `reveal`. `reveal` already says the visual settles on the part, which choosing the point is, but where focus lands is a different fact: a diagram's node takes focus itself, a chart's mark can't. A part names that element, and the visual settles before Leaf focuses it. Changed beyond the chart: closing a comment box on any visual part now reveals the part first, as travel to it does, so a timeline or film shows the part's state again before focus returns. Tests: browser tests for the hand back after an ⌥ comment, a link to a chart point and to a shape in an authored image, and `c` beside a whole-chart thread, in Chromium and Firefox; the reload test finds a bin's comment on Plot's bar; runtime tests for a part thread's rank and the inventory it leaves unread, and for the shape Plot drew.
…acet A comment's mark and Leaf's aim stood on the bar, bin or cell a mark drew for the datum, found by its position among the mark's children. That position is not the datum's: a mark repeated in every facet (`facet: false`) drew the same index in each, so a point in the second facet took the first facet's rect; a render transform that drew its index in another order gave datum 0 datum 1's rect; a linked bar sits in an `<a>`, a clipped mark's group in another `<g>`, and a bar with rounded corners is a `<path>`, so each fell back to a ring; and a transform that draws its mark again, as Plot's pointer does, left the lookup holding the rect it replaced. `shapeOf` now reads, for the point's mark and facet (`index.fi`, kept on the point's drawing), the `<rect>` or `<path>` that Plot's join bound to the datum's index (d3's `__data__`), anywhere under what the mark drew for that facet. It reads only marks that fill a box per datum (bar, cell, rect). Where two shapes hold the datum, or the root the mark drew has since been replaced, it names none and the chart rings the point, so it never names another datum's shape. The cost stays one pass over a facet's shapes on the first ask of a drawing, then one lookup per ask. The chart asks again for a comment's point whose shape the drawing no longer holds. Tests: four runtime cases in chart-points.test.mjs, one per drawing above, each failing on 9ba0491.
Leaving a comment box called the visual's `reveal` while working out where the user lands, so the chart could note the point its next focus should land on. `reveal` is the call travel makes to show a part, and other visuals show it by changing what they draw: putting away a comment box on a timeline's first event, from step 6, moved the timeline to step 1, and on a recording it paused playback and moved the selection. It ran on every put-away and let-go, used or not. And the chart applied the noted point in its focus listener, which a chart already holding focus never hears, so a link to another of its points left it reading the old one. A registration now names `focus(id)`, which Leaf asks only as it puts the user on a part, travelling to it or handing them back from a comment on it: the visual settles on the part and returns the node of it to focus, and a visual that names none gets its part's element, as before. The chart moves its reading to the point at once and returns itself, whether or not it holds focus. The hand-back asks it as the user lands rather than while the bar is read, so leaving a comment box calls no `reveal`. This replaces the parts' `focus` field, the chart's `reveal` and its `#landing`, which are gone. `fabReturnPlaces` now returns the places to name as the user lands, so a reaction asks the drawing then too. The contract moves to visual-parts.js, the registry's `visual` key and module-annotations.md, "Visual parts". Tests, each failing on 9ba0491, in both engines: a link to another point moves a focused chart's reading; Escape from a comment on a timeline's earlier event keeps the timeline at its step.
…doesn't number Two ways the bar a chart marks for a point could still be another datum's: - A render transform that joins other data to the shapes it drew, reusing the nodes as a d3 update join does, left the cached shape for datum 0 bound to datum 1. `shapeOf` now checks that the shape it finds still holds its datum, and reads the facet's shapes again where it doesn't. The chart's own cache of the part it gave Leaf asks `shapeOf` again for a bar, so it follows; a ring stays its point's. - The facet a mark drew in is keyed by Plot's `index.fi`, which Plot's types don't declare. Had a Plot release dropped it, every facet would have written the one undefined key and points would resolve to the last facet's bars. A mark drawn twice under one key now names no shape there, so the chart rings the point. The cost is unchanged while bindings hold: one pass over a facet's shapes on the first ask, one lookup per ask, and a pass again after a rejoin. Tests, failing on de0c643: a transform that rejoins its shapes to the index reversed, and a two-panel chart whose renders carry no `fi`.
A visual's `focus(id)` ran wherever Leaf named the destination, and
travel names it each time `arrive` resolves, before and after it awaits
the scroll stop: one landing called it four times, a cancelled one moved
a chart's reading to a point the user never reached, and Back or Forward
to a hidden fragment, which places no focus, called it too. The hand-back
called it before testing whether the visual could take focus, so falling
back past a chart still moved its reading.
Focus placement now takes a destination its owner settles as the user
lands, `{element, settle}` (focus.js, `FocusDestination`), and
`focusDestination` calls `settle` inside the placement and nowhere else.
`handBack` passes such a destination by, unsettled, when its element
can't take focus. A visual part's destination is the visual itself,
settled by its `focus(id)` (visual-parts.js, `visualPartFocus`), so the
hook returns nothing: a visual with the hook takes focus for its parts
itself. Naming a destination changes nothing, so `returnPlaces` reads it
before the bar goes, as it reads the others, and `fabReturnPlaces` returns
the places again rather than a function that names them.
Travel reads the destination's element where it scrolls to it, and the
panel's clearing and the margin's reveal read it where they need one.
Tests, failing on de0c643: naming a plot's point as a destination
settles nothing, a hand-back past the plot leaves it unsettled, and
placing focus settles it once.
… as an element A review of b720ca7 found two ways placing focus on a destination still went wrong: - `focusDestination` called a destination's `settle` before native focus ran, so travel to a chart inside an inert region moved the chart's reading to the point though focus never reached it. It now settles only where the element is drawn (`drawn`, the test `handBack` applies), as focus is placed. - It told a `{element, settle}` destination from an element with `instanceof Element`. An element of a same-origin frame, which a playground's range control puts focus back on, belongs to its own window's `Element`, so it was read as a destination and its missing `settle` threw. Both checks now read the node type (`isElement`). Tests, failing on b720ca7: placing focus on an inert plot settles nothing, and a placement takes an element that is no instance of the page's `Element`.
leaf-agent
approved these changes
Nov 18, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 18, 2026
… traced by the part (#6417) A thread on one part of a picture, such as an `lf-chart` point or an `lf-diagram` node, now has a margin entry of its own instead of joining the picture's. The entry and its Page Map group are named by the label the part registers, as the comment box names it ("chart · week 3, sessions 8,412"). The entry stands level with its part, its card opens beside the part, and hovering or focusing it traces the part on its registered surface rather than the whole picture. This applies to any visual that calls `registerVisualParts`. A part the picture hasn't drawn yet keeps its own named entry at the picture's top, and a saved draft on a part behaves the same way. | Pointer on the week 2 entry: before | After | | --- | --- | | <img width="420" src="https://gist.githubusercontent.com/max-sixty/cb0cd2b18d4f4718c5603b1ae50a92d7/raw/b16526e85538211708004649bc347ecd2ae4e716/p-dots-hover-firefox-base.png"> | <img width="420" src="https://gist.githubusercontent.com/max-sixty/cb0cd2b18d4f4718c5603b1ae50a92d7/raw/b16526e85538211708004649bc347ecd2ae4e716/p-dots-hover-firefox-head.png"> | `resolveAnchor` now carries a part's `label` with its element and surface, so the margin names a part from the lookup that placed it. Anchor placement places saved drafts as it places threads (`savedAt`), which replaces the inventory's own draft-placement reading and keeps a draft on a part in step when the picture redraws. The margin's ResizeObserver no longer watches boxes a visual draws, since `lf-chart` redraws inside a size delivery and raised a ResizeObserver loop error; a visual already reports its parts' moves through `update()`, and `module-annotations.md` now says so. Calls to weigh: - On a picture wider than the column, entries are pins at its right edge, so two nodes on one line of a left-to-right diagram stack there and read apart only on hover or in Page Map (below, the pointer on "Start request"). - The trace on a diagram node is the quiet grey contour, not the brackets the whole picture got. - Two commented dots list in Page Map in comment order, not data order. <img width="640" src="https://gist.githubusercontent.com/max-sixty/cb0cd2b18d4f4718c5603b1ae50a92d7/raw/b16526e85538211708004649bc347ecd2ae4e716/flow-hover-firefox-head.png"> This follows #6371, which the user asked for, and Codex reviewed it three times. Tests: runtime suite (1,047), `check:browser`, and the focused browser tests on part entries, chart points and saved-draft entries; each new assertion fails with its fix reverted. > _This was written by Claude Code on behalf of max-sixty_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A comment aimed at an
lf-chartnow lands on the point the chart's aim is on, a dot, a line's vertex or a bin, rather than on the whole chart. ⌥ aims at the point the chart rings, andcwith the chart focused comments on the point the arrow keys reached. The anchor stores the datum, asanchor.visual = "point:0;x=6;y=8412", so the comment stays on that datum across redraws, resizes and reloads, and an agent reading it reads the values. A bar, bin or cell is marked on the shape Plot bound to its datum (d3's__data__) in its own facet; a dot or vertex, or a bar the chart can't be sure of, gets a ring.registerVisualPartsgainsfind(id)andat(node)for a visual with too many parts to list, so the cost grows with the comments rather than the data: on a 100,000-dot chart the ⌥ keydown takes 1.0 ms here against 189 ms on main, where aiming at the whole chart restyled every dot. It also gainsfocus(id)for a visual whose parts can't take focus: travel to a part, and leaving a comment box on one, put focus on the visual itself, andfocus(id)runs only as that focus is placed, so the chart moves its reading to the point. To say that,focusDestinationandhandBacktake a destination{element, settle}besides an element.Worth weighing:
lf-diagram's parts too.renderto see what it drew per facet, keyed by Plot'sindex.fi, which Plot's types don't declare; without it, the chart rings the point.The maintainer asked for this on a Leaf page and hasn't read the diff yet. Four Codex reviews and a fresh look at stills found the problems the later commits fix. Tests: browser tests in Chromium and Firefox for the ⌥, keyboard, reload, resize, travel, link, hand-back and closed-tab routes,
cbeside other threads on the chart, and a timeline left at its step; runtime tests forfind,at,focus, a part thread's rank, the datum token and the shape Plot drew.