Skip to content

cli: export the terminal display-width measure as CliOutput.displayWidth - #8982

Merged
tim-smart merged 3 commits into
Effect-TS:mainfrom
Yi-111-a:eff-8863
Oct 10, 2026
Merged

tim-smart merged 3 commits into
Effect-TS:mainfrom
Yi-111-a:eff-8863

Conversation

@Yi-111-a

@Yi-111-a Yi-111-a commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #8863.
Closes EFF-1925.

What

visualLength in CliOutput.ts — the measure #7572 introduced so CLI help aligns on terminal cells instead of UTF-16 code units — was never exported. Anything drawing next to the built-in output (a custom CliOutput.Formatter, a banner, a table, a prompt built on Prompt.Custom) has to measure by the same rules to line up with it, and today the only options are copying that grapheme/East Asian Width logic into the application or depending on string-width. Either way the application's measure can disagree with the one the built-in help uses, so the two drift.

This exports the existing function unchanged as CliOutput.displayWidth:

import { CliOutput } from "effect/cli"

CliOutput.displayWidth("ファイル") // 8
CliOutput.displayWidth("é")   // 1
CliOutput.displayWidth("1️⃣") // 2

No new logic. pad and renderTable now call the exported name, so it is the same function the built-in help renders with by construction. The issue also floated "a home in effect/String instead of effect/cli" as acceptable; I kept it in effect/cli since that is where the built-in output lives and where the callers are, but happy to move it if you'd prefer.

Notes

  • Strips ANSI styling first, so styled and unstyled text measure the same — unchanged behavior.
  • @stability unstable / @category measuring, matching the rest of the module. Current version is 4.0.2, so the changeset is a patch; @since is set to 4.0.3 — correct me if the next release lands elsewhere.
  • Fixed a stale @internal doc comment on graphemeSegmenter (it described the width measure, not the segmenter).

Tests

One focused CliOutput.displayWidth test in the existing packages/effect/test/cli/Help.test.ts covers empty/ASCII input, wide characters, combining marks, emoji presentation and ANSI styling. Existing help tests already cover wide-grapheme and zero-width flag-name alignment; the redundant one-off test file has been removed.

Validated during takeover:

  • nix develop -c pnpm lint-fix — clean.
  • nix develop -c pnpm test --run packages/effect/test/cli/Help.test.ts — 27 tests passed.
  • nix develop -c pnpm check — passed.

This takeover pass changes tests and the PR description only; implementation review and comment/changeset cleanup remain for subsequent passes.

The measure that #7572 introduced for CLI help alignment stayed internal
(visualLength in CliOutput.ts), so anything drawing next to the built-in
output has to copy the grapheme and East Asian Width logic to line up
with it, and the copy can drift.

Export it unchanged as CliOutput.displayWidth with a doc comment. The
function keeps stripping ANSI styling first, so styled and unstyled text
measure alike.

Refs #8863
@changeset-bot

changeset-bot Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 92cf9b8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

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

@effect-janitor effect-janitor Bot added the 4.0 label Oct 10, 2026
@github-actions

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 38.84 KB 38.84 KB 0.00 KB (0.00%)
basic.ts 7.07 KB 7.07 KB 0.00 KB (0.00%)
batching.ts 10.15 KB 10.15 KB 0.00 KB (0.00%)
brand.ts 6.73 KB 6.73 KB 0.00 KB (0.00%)
cache.ts 10.92 KB 10.92 KB 0.00 KB (0.00%)
config.ts 22.32 KB 22.32 KB 0.00 KB (0.00%)
differ.ts 21.35 KB 21.35 KB 0.00 KB (0.00%)
http-client.ts 22.71 KB 22.71 KB 0.00 KB (0.00%)
http-router.ts 34.15 KB 34.15 KB 0.00 KB (0.00%)
logger.ts 11.25 KB 11.25 KB 0.00 KB (0.00%)
metric.ts 9.04 KB 9.04 KB 0.00 KB (0.00%)
optic.ts 6.96 KB 6.96 KB 0.00 KB (0.00%)
pubsub.ts 15.24 KB 15.24 KB 0.00 KB (0.00%)
queue.ts 12.16 KB 12.16 KB 0.00 KB (0.00%)
schedule.ts 11.27 KB 11.27 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.78 KB 13.78 KB 0.00 KB (0.00%)
schema-binary.ts 40.03 KB 40.03 KB 0.00 KB (0.00%)
schema-class.ts 21.11 KB 21.11 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 32.16 KB 32.16 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.33 KB 27.33 KB 0.00 KB (0.00%)
schema-string-transformation.ts 14.54 KB 14.54 KB 0.00 KB (0.00%)
schema-string.ts 12.04 KB 12.04 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.11 KB 16.11 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.37 KB 38.37 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 25.32 KB 25.32 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.28 KB 20.28 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.49 KB 20.49 KB 0.00 KB (0.00%)
schema-toFormatter.ts 20.59 KB 20.59 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 25.06 KB 25.06 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 20.57 KB 20.57 KB 0.00 KB (0.00%)
schema.ts 20.33 KB 20.33 KB 0.00 KB (0.00%)
stm.ts 13.29 KB 13.29 KB 0.00 KB (0.00%)
stream.ts 10.00 KB 10.00 KB 0.00 KB (0.00%)

@tim-smart
tim-smart merged commit b8d6e7a into Effect-TS:main Oct 10, 2026
8 of 10 checks passed
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Oct 15, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `@inlang/plugin-message-format` | 4.5.0 | 4.5.2 | patch |
| `@tanstack/react-query` | 5.104.1 | 5.104.2 | patch |
| `effect` | 4.0.2 | 4.0.3 | patch |

## Release Notes

<details>
<summary><b>@<!---->tanstack/react-query</b> (5.104.1 →
5.104.2)</summary>

### Patch Changes

- Updated dependencies
[[`03e8c39`](TanStack/query@03e8c39)]:
  - @<!---->tanstack/[email protected]

</details>

<details>
<summary><b>effect</b> (4.0.2 → 4.0.3)</summary>

### Patch Changes

- [#8977](Effect-TS/effect#8977)
[`b4e5af8`](Effect-TS/effect@b4e5af8)
Thanks @<!---->kitlangton! - Prevent crashes and premature interruption
when `Effect.cached`, `Effect.cachedWithTTL`, and
`Effect.cachedInvalidateWithTTL` are synchronously re-entered.

- [#8982](Effect-TS/effect#8982)
[`b8d6e7a`](Effect-TS/effect@b8d6e7a)
Thanks @<!---->Yi-111-a! - Export `CliOutput.displayWidth` to measure
terminal-cell widths using the same logic as built-in CLI help and
tables.

- [#8933](Effect-TS/effect#8933)
[`89d5c88`](Effect-TS/effect@89d5c88)
Thanks @<!---->tim-smart! - Respect `NO_COLOR` in CLI prompts and the
command wizard, suppressing color and style escapes while preserving
cursor and redraw controls.

- [#8941](Effect-TS/effect#8941)
[`66257d2`](Effect-TS/effect@66257d2)
Thanks @<!---->Tanner-Scadden! - Hand cluster shards off one at a time
when `Sharding` shuts down, after their entities and singletons have
stopped, so live runners can take them over sooner. The handoff is best
effort: its wait is bounded, and if it times out, `releaseAll` attempts
to release the remaining locks. A runner that is shutting down no longer
acquires new shards, and releasing a shard no longer waits forever on an
entity whose id is also active on another shard.

- [#8940](Effect-TS/effect#8940)
[`cd2ab19`](Effect-TS/effect@cd2ab19)
Thanks @<!---->Tanner-Scadden! - Fix cluster shard handoffs. Interrupts
and stream acknowledgements now reach requests still draining on the
previous owner, and `RpcServer` accepts acknowledgements for active
streams after a client's EOF. Volatile requests sent duri

…[full
notes](https://github.com/Effect-TS/effect/releases/tag/effect%404.0.3)

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

This branch had an error being deployed

1 failed deployment
fork — 92cf9b88 Deployed Oct 10, 2026 by effect-bot via approval-gate #18789
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.

cli: export the terminal display-width measure

3 participants