Repository navigation
Take event-name constants and contributionEntry out of the package API - #6941
Conversation
One step of the package-interface redesign. Nine names leave the package API. `PAGE_INTERFACE`, `PRESENTATION`, `LAYOUT` and `PREVIEW_ENDED` only named events Leaf already sends, so packages write `lf-page-interface`, `lf-presentation`, `lf-layout` and `lf-preview-ended`. `contributionEntry` normalized an entry that `registerContribution` and `presentContributionEntry` already normalize, so callers pass plain objects. Nothing outside the runtime used `clockValue`, `matchesWhen`, `partOver` or `contributionItemKey`. The runtime keeps each function it uses; `clockValue` joins check-api.js for the three browser tests that drive a clock-tracked draw.
leaf-agent
left a comment
There was a problem hiding this comment.
Of the nine names, clockValue is the one whose removal leaves package authors with a gap the references no longer cover. The "Time readings" section of module-state.md used to give a widget one way to act on a time condition, such as marking data stale after a limit or grouping by day, and it told authors to "keep no clock of your own" so the result could never disagree with an ago drawn next to it. With that paragraph removed, the section covers only ago. A widget that needs a stale badge will now reach for Date.now() and its own timer. That timer reads the browser's clock rather than the server time ago uses, and nothing redraws the widget when the condition flips.
The PR body already lists this under "To weigh", and per AGENTS.md, "The maintainer decides", taking a feature away is Max's call. The redesign approval doesn't cover it while he hasn't read the diff. So I'm leaving the verdict to him rather than approving. Everything else here only removes wrappers, and it checks out: pnpm run test:browser and pnpm run test:runtime both pass on the merged tree. If clockValue goes, say in "Time readings" what a widget should do for a time condition instead. If it stays, keep the export and the paragraph.
A package that redraws on a time condition reads it from Leaf's server clock through clockValue, as an age beside it does; without it the widget keeps a clock of its own. Its removal is a feature's, which the maintainer decides.
leaf-agent
left a comment
There was a problem hiding this comment.
Keeping clockValue resolves what I raised last round: the export and the "Time readings" paragraph now match main exactly.
My earlier review was wrong to call everything else a wrapper removal. The PR body itself says partOver and matchesWhen take a capability away. Both are documented package API on main, in module-reading.md (the matchesWhen(element, when) sentence and the partOver(node) paragraph). The first lets a widget evaluate a {when} declaration such as an awaits's. The second gives a widget the part of the page On Me groups an item under, so a package can group or label by the same rule. No package calls either one. But per AGENTS.md, "Regular maintenance", that doesn't show they're unused, since the maintainer builds features ahead of their use. Per "The maintainer decides", taking a feature away is Max's call, and the body says he hasn't read this diff. Approving would merge it under yolo, so I'm leaving the verdict to him. If both go, the rest of the PR is ready. If either stays, restore its export and its paragraph, the same way clockValue came back.
Each gives a package a rule of Leaf's own, the part On Me groups an item under and whether a declared when holds, so removing it takes a feature away, which the maintainer decides.
One step of the package-interface redesign: names that only name an event Leaf already sends, or that only rebuild what Leaf already does with a plain object, leave the package API. Six go, 183 names to 177. Packages write
lf-page-interface,lf-presentation,lf-layoutandlf-preview-endedin place ofPAGE_INTERFACE,PRESENTATION,LAYOUTandPREVIEW_ENDED.registerContributionandpresentContributionEntryalready normalize a plain entry, socontributionEntrygoes and callers pass the object.contributionItemKeyonly joined an item'sownerandid, whichmodule-annotations.mdnow tells aconsumeAnnotationscaller to key rows by.To weigh: nothing a user sees should change, and no lint rule or test watch changed. Left in:
clockValue,partOverandmatchesWhen, which nothing outside the runtime calls but which each give a package a rule of Leaf's own, so removing them is a feature's removal for Max to decide; andPendingTaskEvent, since #6936 made it how a widget announces preparation and five packages build it, so it belongs in the library. The shared-contribution-actions eval now passes plain entries.Max approved the redesign and asked for small steps. He hasn't read this diff. A fresh agent reviewed it.
Ran: pre-commit,
pnpm run check, 20 browser tests by node id.