Repository navigation
Type defineWidget over its component, so the check sees what a widget asks of Leaf - #7575
Merged
Merged
Conversation
… asks of Leaf
`defineWidget` took its component as `any`, so the runtime type check couldn't see a
widget that asks for a service Leaf doesn't provide, or `inputs` that miss or mistype a
prop. It now takes `Component.Component<string, Props, Model, Msg, …, Provided, …>`,
where `Provided` is what `leafServices` provides plus `Html.Host`. Effect UI's
requirement channel is covariant, so a component that needs any other service fails at
the `defineWidget` call. The mount inside needs no cast on its requirements any more.
The props check, in the types `defineWidget`'s options take:
- `inputs` returns the props as the `props` Schema types them, and may leave out only
optional ones, such as `state` and the `properties`. A required prop named only in
`properties`, which the page may never set, fails, as do union props of which
`inputs` returns only the keys every variant shares.
- A widget may leave `inputs` out only where every prop is optional.
- `properties` names props, and never `state`, whose setter Leaf's mount waits on.
- A member's `get` reads the Model, and its `set` returns a message.
- The props are a record, since the element spreads them into one.
The check doesn't see a prop that `inputs` returns and the component lacks, and it
trusts the component's own type for `state`. The effect-widget.ts header says so.
The check reads requirements off the component's type, and an `any` anywhere in a view
or update erased them. Before this change only 3 of the 9 widgets that use one of
Leaf's services had their requirements in their component's type. Now 8 do:
- `actionPress(h, …)` took `h: any`, so every view that used it had `any`
requirements. It now takes `Html.H<Msg>`, Effect UI's type for a shared view
function. lf-option's `KeyBadge` and `Reference` take the same.
- lf-toc's view and update took `$: any` and `h: any`, and its `head` helper took a node
as `any`. They now infer from `Html.component(...).make`. `head` became an
attributes object that the label and the toggle pass to `.attrs`.
- lf-draft's view took `h: any`. Removing it exposed a real gap: the `EditDraft` Mount's
stream had element type `unknown`, which `.onMount` rejects. It now streams
`DraftMessage`.
- lf-motion's update helpers took `$: any`. They now take Effect UI's `Update` type, and
`handle` returns `$` where a message changes nothing, so `keep` no longer narrows
with `Component.isStep`.
- lf-tally and lf-option have an empty Model (`Schema.Struct({})`) and returned
`$.model` in one branch and `$.run(...)` in the other. A step is a `{}`, so the union
reduced to `{}` and dropped the Command's requirement. They return `$` instead.
- lf-activity's `inputs` returned `targets` typed `(string | null)[]` against a
`readonly string[]` prop. A split filter narrows it.
lf-options.js is the one widget whose requirements the check still can't see: its
helpers take `any` throughout.
Returning `$` from an update gives Effect UI the same Model with no Commands, as
returning `$.model` does (`toNext`), and `.attrs` writes the attributes the chained
`.attr` calls wrote, in the same order. Nothing changes at run time.
The element's root was a hand-written copy of the part of `Renderer.Root` it uses. A type-only import of Effect UI's own type replaces it, as other runtime modules import @codemirror's types.
leaf-agent
approved these changes
Nov 29, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 29, 2026
#7575 typed `defineWidget` over its component. The shared mount takes that typing: `mountRoot` is now the Effect that mounts a typed component and gives back its `Renderer.Root<Model, Msg, Props>`, which the caller runs with the services the component's type still asks for and a Scope, so the check holds a chrome surface to its requirements as it holds a widget. Leaf's `Html.Host` is provided on each mount. The Page Map's component is typed throughout, with no `any`: its view functions take `Html.H<Msg>`, its props are declared Schemas, the search is a typed `wa-input` whose words reach the Model from its Mount's `input` listener (`asSearchField`, which `searchField` now shares), and status rows take a span ref of the rows' name. > _This was written by Claude Code on behalf of max-sixty_
This was referenced Nov 29, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 29, 2026
…ainst them Typing defineWidget over its component (#7575) read the services a component may ask for off `leafServices` as a Layer. This branch makes `leafServices` a plain provider, which builds no Layer on each mount, so that read found nothing and every widget asking for a service failed the type check. `LeafServices` now names the services, and `leafServices` takes an effect that asks for at most those and returns one that asks for nothing, so the type check refuses a provider that leaves one of them out. defineWidget provides the scheduler and scope first and Leaf's services last.
max-sixty
added a commit
that referenced
this pull request
Nov 29, 2026
…a part `defineWidget` now types its component (#7575), and the board's own `Step` type, whose `evolve` returned `any`, left the component requiring `unknown`; it is the component's `Component.Update` now. The grip stands in the card's shadow root, so the site's recipe for styling a control a widget builds, `lf-board .lf-grip`, reached nothing. The grip is the card's `grip` part, the recipe says `lf-card::part(grip)`, and the theme-package test checks it. Margin layout reads the target's own shadow tree for what a pin covers, so it now hears changes there too, as it hears those in the trees holding the target: a control revealed under a pin in a widget whose size stays put moves the pin. `cardHolding` finds the card through `shadowHost`, and module-widgets.md says when a Mount compares its args: on a draw that gives it new ones.
max-sixty
added a commit
that referenced
this pull request
Nov 29, 2026
…log (#7577) The Page Map is the first piece of Leaf's chrome drawn by Effect UI: one component draws everything inside the native dialog the runtime keeps, and the owner keeps the layer, inventory and contributions and hears row presses and Close as the component's events. The mount every Effect UI view stands on moves to one home, `host/effect-root.ts`, which `defineWidget` now shares, so a chrome surface mounts with no element or registry entry. `mountRoot` is the Effect that mounts a typed component and gives back its `Renderer.Root<Model, Msg, Props>`; the caller runs it with the services the component's type still asks for, so the type check holds a chrome surface to its requirements as #7575 holds a widget, and the Page Map's component carries no `any`. Focus and reveal after a draw are `HtmlCommand`s on refs; the owner's own refreshes hold focus and place with `afterDraw`; `browser/AGENTS.md` states the rule once for the next port. What to weigh: - Every page now loads Effect UI as it boots. Pages without an Effect UI widget (10 of 28 examples) load 584 KB more before they show the server's state and spend 19–27 ms more load CPU; pages that already hold one are unchanged. Every chrome component moves to Effect UI (`browser/AGENTS.md`, "Renderers"), so every page will load it once the floating panel ports, since the panel draws on every page as it boots. Max chose on the review page to count Effect UI's own load against that move, rather than build a deferred load and a first open that waits for it, which the panel's port would delete, and approved landing this there. - A contributor that hands the user to a Page Map row the map hasn't drawn yet, in the same script, now finds no control (the `features/contributions.ts` header says so). No contributor in the tree does this. - The dialog grew from 435 to 637 lines of code. Its opening and search-key logic is now under a Story test. Stills show 0 px difference. Tests: `test:runtime`, `pnpm run check`, and 32 named Page Map browser tests. One test now reads an immediate reorder after a frame instead of synchronously. > _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.
defineWidgettook its component asany, so the runtime type check couldn't see a widget that asks for a service Leaf doesn't provide, orinputsthat miss or mistype a prop. It now takes the component's own types: its requirements must be Leaf's services orHtml.Host,inputsmust return the props its Schema requires (and may be left out only where every prop is optional),propertiesmust name props other thanstate, props must be a record, and members are typed by the Model and message. No name joins the package interface, and nothing changes at run time.The check reads requirements off the component's type, and
anys in views erased them: only 3 of the 9 widgets that use a Leaf service carried their requirements before, and 8 do now. The fixes were typingactionPress'shasHtml.H<Msg>, removing the viewanys in lf-toc.ts and lf-draft.ts, typing lf-motion's update helpers, and returning$instead of$.modelin lf-tally and lf-option, whose empty Model swallowed the step's requirement. lf-options.js,anythroughout, is the one left. Removing lf-draft'sh: anyexposed a Mount stream typedunknown, fixed here.Codex reviewed it twice.
pnpm run checkpasses.