Repository navigation
Description
A URL can't name a part of a widget. Threads and navigateToDatum reach a widget's parts through its keys, but fragmentTarget reads only element ids. navigateToDatum also writes the widget's own id into the URL, so reloading or sharing the URL after it lands at the top of the widget, not on the part.
I ran into this while writing a widget that draws one item at a time and fetches each item when it's picked. I wanted a copy-link control on each part of an item, and there was no URL for it to copy.
What happens
Take a widget <x-items id="items"> whose module answers keys such as b/3, meaning part 3 of item b:
lfRevealDatum("b/3")picks itemb, draws it, and returns a promise that resolves once it's drawn.lfElementsFor("b/3")returns the drawn part.
Then:
- Another widget that refers to
itemsthroughx-referscallsnavigateToDatum(this, "for", "b/3"). Leaf picksb, lands on part 3 and focuses it. The URL now ends in#items. - Reloading that URL lands at the top of
items, on whichever item it draws first. - No fragment names part 3 of item
b, so a copy-link control on the part has nothing to copy, and a reply can't link to the part.
The parts can't carry element ids of their own. They aren't in the page until their item is picked, and every item's parts use the same ids.
Expected
One fragment spelling for a widget id plus a key, resolved by the step anchor-resolution.js already shares between threads and navigateToDatum: revealAddressed, then addressedElements. The comment on revealAddressed says every travel to a part of a widget asks it, "so neither route reaches a part the other cannot". The URL is the one route that doesn't.
A possible shape:
- The fragment resolves to an element id first, as now. Otherwise it's read as a widget id and a key, and resolves to the widget, so the code that only needs the element lands on the widget as it does today.
followFragment,returnToFragmentand the fresh-load landing then reveal the key and land on the part. At load, the reveal's promise could count as adeferredArrival, which the landing already waits for.navigateToDatumwrites that spelling instead of the widget's id, so its URL reloads and shares to the same part.- The widget API builds the URL for a widget and a key, so a module's copy-link control doesn't spell the format itself. The check that a reply's fragment link is live accepts the same form.
A widget that already answers lfRevealDatum or lfElementsFor would then get links to its parts with no new hook.
Seen on leaf b88915a, installed 2026-11-01T10:36:05-08:00.
This was written by Claude Code on behalf of max-sixty
Activity