Skip to content

Stack method chains in the Effect UI examples - #11389

Merged
effect-bot merged 2 commits into
mainfrom
agent/nelson-effect-bot/c0162ae1b3c2
Dec 3, 2026
Merged

effect-bot merged 2 commits into
mainfrom
agent/nelson-effect-bot/c0162ae1b3c2

Conversation

@effect-bot

@effect-bot effect-bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes EFF-5017

Adds a small dprint formatter for the Effect UI examples in examples/ui. In a chain with two or more method calls, the element (h.div) or other start of the chain stays on the first line and each method call goes on its own line below it, so a view reads as a tree. The script knows no names, so HTML, terminal and native views, kit parts and builders are all handled the same way.

The PR has two commits:

  1. Tooling: scripts/stack-chains.mjs, the dprint config, the rolldown dev dependency, a fixture test and a README note.
  2. Reformat: dprint fmt over examples/ui (76 files, +4,822 / -3,791). Nothing outside examples/ui changes.

Before and after (examples/ui/counter/src/Counter.ts)

// before
h.div.class(
  "min-h-screen bg-white flex flex-col items-center justify-center gap-6 p-6"
).children(
  h.p.class("text-6xl font-bold text-gray-800").children(
    String(model.count)
  ),
  h.div.class("flex flex-wrap justify-center gap-4").children(
    Button(h, { onPress: CounterMessage.ClickedDecrement() }).class(
      BUTTON_CLASS
    ).children("-"),
    ...

// after
h.div
  .class("min-h-screen bg-white flex flex-col items-center justify-center gap-6 p-6")
  .children(
    h.p
      .class("text-6xl font-bold text-gray-800")
      .children(String(model.count)),
    h.div
      .class("flex flex-wrap justify-center gap-4")
      .children(
        Button(h, { onPress: CounterMessage.ClickedDecrement() })
          .class(BUTTON_CLASS)
          .children("-"),
        ...

The rule

  1. The start of a chain stays on the first line. The start is a call (Button(h, ...)), a name with its properties (h.div, AppNavigation.Issue), or the first method call when the chain opens with one ($.evolve(...), Effect.gen(...), scene.fire(a)).
  2. A chain is stacked when two or more method calls follow its start. Each of them goes on its own line.
  3. A call that takes a stacked chain as an argument puts its arguments on their own lines.
  4. Inside a stacked chain, arguments that each fit on one line are joined back, and dprint wraps them again if needed. This removes leftovers such as .class(⏎ BUTTON_CLASS ⏎).

Chains with a single call after the start are left as written: h.header.children(...), expect(x).toBe(y), Effect.gen(...).pipe(...) and Html.component({...}).make({...}). Gaps that contain a comment are also left as written.

Review guide

  • dprint.json runs the exec plugin before the TypeScript plugin on **/examples/ui/**/*.{ts,tsx}. A path relative to the config (examples/ui/**) didn't match any files, so the pattern starts with **/. The TypeScript plugin needs explicit associations so that both plugins run on the same file. Test files (*.test.ts(x)) are excluded through the plugin-level associations, because a stacked .expect(a)⏎.toExist() splits each assertion in two. They keep ordinary dprint formatting. The exec plugin only accepts negated globs at the plugin level, not per command.
  • examples/ui/launch/dprint.json (line width 70) gets the same block, with cwd pointing at the repository root. It can't extends the root config, because dprint rejects the root's includes and incremental in a nested config.
  • incremental is now true, and cacheKeyFiles reformats everything when the script changes. CI starts cold, so it pays for one node process per example file (about 200).
  • rolldown@1.3.4 was already in the lockfile through Vite. The lockfile diff only adds the root importer entry.

Blame

Please rebase-merge this PR so the reformat stays its own commit. GitHub rewrites SHAs on merge, so the .git-blame-ignore-revs entry has to come in a follow-up that uses the reformat commit's SHA on main.

Verification

  • dprint check --incremental=false is clean right after dprint fmt, including launch.
  • The syntax trees of all 76 reformatted files match before and after.
  • oxlint and pnpm check pass.
  • pnpm vitest run --project 'examples/ui*' --project scripts: 51 files and 154 tests pass.

No changeset: the examples are private and nothing published changes.

@changeset-bot

changeset-bot Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2ef7b8d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@effect-janitor effect-janitor Bot added the 4.0 label Dec 2, 2026
@effect-bot
effect-bot force-pushed the agent/nelson-effect-bot/c0162ae1b3c2 branch 4 times, most recently from e15c1c1 to 606a78b Compare December 2, 2026 23:22
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.55 KB 40.55 KB 0.00 KB (0.00%)
basic.ts 6.80 KB 6.80 KB 0.00 KB (0.00%)
batching.ts 12.03 KB 12.03 KB 0.00 KB (0.00%)
brand.ts 7.03 KB 7.03 KB 0.00 KB (0.00%)
cache.ts 12.30 KB 12.30 KB 0.00 KB (0.00%)
config.ts 24.02 KB 24.02 KB 0.00 KB (0.00%)
differ.ts 22.88 KB 22.88 KB 0.00 KB (0.00%)
http-client.ts 29.03 KB 29.03 KB 0.00 KB (0.00%)
http-router.ts 39.70 KB 39.70 KB 0.00 KB (0.00%)
logger.ts 12.46 KB 12.46 KB 0.00 KB (0.00%)
metric.ts 10.29 KB 10.29 KB 0.00 KB (0.00%)
optic.ts 7.26 KB 7.26 KB 0.00 KB (0.00%)
pubsub.ts 17.02 KB 17.02 KB 0.00 KB (0.00%)
queue.ts 13.83 KB 13.83 KB 0.00 KB (0.00%)
schedule.ts 12.59 KB 12.59 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.62 KB 14.62 KB 0.00 KB (0.00%)
schema-binary.ts 43.61 KB 43.61 KB 0.00 KB (0.00%)
schema-class.ts 22.61 KB 22.61 KB 0.00 KB (0.00%)
schema-codegen.ts 33.98 KB 33.98 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 31.06 KB 31.06 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.80 KB 28.80 KB 0.00 KB (0.00%)
schema-string-transformation.ts 16.39 KB 16.39 KB 0.00 KB (0.00%)
schema-string.ts 12.89 KB 12.89 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.99 KB 16.99 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 40.12 KB 40.12 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.77 KB 21.77 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.93 KB 21.93 KB 0.00 KB (0.00%)
schema-toFormatter.ts 22.04 KB 22.04 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 27.05 KB 27.05 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 22.08 KB 22.08 KB 0.00 KB (0.00%)
schema.ts 21.73 KB 21.73 KB 0.00 KB (0.00%)
stm.ts 15.08 KB 15.08 KB 0.00 KB (0.00%)
stream.ts 10.83 KB 10.83 KB 0.00 KB (0.00%)
supervisor.ts 12.27 KB 12.27 KB 0.00 KB (0.00%)

UI Bundle Size

Vite 8.4.0/Rolldown, production, default Oxc minification, es2023, ES modules, gzip level 9 per chunk. effect 4.2.0, Node v26.12.1. Effect-only client: 27528 B gzip (Δ 0 B vs base).

App Chunks Raw bytes Gzip bytes Added gzip B Δ raw bytes Δ gzip bytes
counter 1 176280 60862 33334 0 0
features 1 185934 64361 36833 0 0
menu 1 290721 99073 71545 0 0

@effect-bot
effect-bot force-pushed the agent/nelson-effect-bot/c0162ae1b3c2 branch 2 times, most recently from 4826018 to 18fcc74 Compare December 3, 2026 01:38
@effect-bot
effect-bot force-pushed the agent/nelson-effect-bot/c0162ae1b3c2 branch from 18fcc74 to 2ef7b8d Compare December 3, 2026 14:16
@effect-bot
effect-bot merged commit f649b6d into main Dec 3, 2026
25 checks passed
@effect-bot
effect-bot deleted the agent/nelson-effect-bot/c0162ae1b3c2 branch December 3, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant