Skip to content

ref(opt): compile out Clay's unused debug-tools UI - #89

Merged
natemoo-re merged 1 commit into
mainfrom
ref/clay-debug-tools
Aug 27, 2026
Merged

ref(opt): compile out Clay's unused debug-tools UI#89
natemoo-re merged 1 commit into
mainfrom
ref/clay-debug-tools

Conversation

@natemoo-re

@natemoo-re natemoo-re commented Jun 6, 2026

Copy link
Copy Markdown
Member

Clay's built-in debug inspector is gated behind if (context->debugModeEnabled), but tty doesn't benefit from this code path at all.

This PR patches Clay to add a CLAY_DEBUG_MODE_ENABLED macro (defaults to 1), which allows us to strip out the unused code. Good candidate for an upstream PR!

Makefile has also been updated with a generic patch mechanism, with patches/*.patch applied in order against the latest upstream base.

Net result size is reduced by 18.8 KB (down to 100.0 KB unpacked)

@pkg-pr-new

pkg-pr-new Bot commented Jun 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/tty@89

commit: 0a1e0a8

@natemoo-re
natemoo-re marked this pull request as draft June 6, 2026 16:46
@codspeed-hq

codspeed-hq Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 10 untouched benchmarks


Comparing ref/clay-debug-tools (0a1e0a8) with main (facb4f6)

Open in CodSpeed

@github-actions

Copy link
Copy Markdown

Size Reduced — -18.8 KB

100.0 KB unpacked

Clay's debug inspector (Clay__RenderDebugView, ~700 lines + ~150 UI strings) is reachable from the exported Clay_EndLayout behind runtime debugModeEnabled branches, so --gc-sections can't drop it; at -O2 clang inlines it into the layout monolith. clayterm never enables debug mode, so it's dead weight.

Adds an upstream-compatible CLAY_DEBUG_MODE_ENABLED value macro (default 1; patches/clay-debug-mode-enabled.patch), named to match the runtime context->debugModeEnabled selector. Generated against the submodule's recorded commit (938967a) and covering all four debugModeEnabled sites; opted out via -DCLAY_DEBUG_MODE_ENABLED=0.

The Makefile now applies Clay patches generically: every patches/*.patch is applied (in sorted order) after resetting clay/clay.h to pristine, so the applied set always matches the directory exactly and future patches (e.g. #115's grow-minDimensions fix) need no per-patch Makefile wiring. Reverted by make clean. Drop individual patches as they ship upstream.

raw wasm 155,877 -> 101,208 (-35.1%); brotli 44,141 -> 29,133. Cold path only (debugModeEnabled always false at runtime); deno task test test/ passes (19 files, 227 steps).
@natemoo-re
natemoo-re force-pushed the ref/clay-debug-tools branch from fe0f62d to 0a1e0a8 Compare August 27, 2026 10:08
@natemoo-re
natemoo-re marked this pull request as ready for review August 27, 2026 10:17

@cowboyd cowboyd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

@natemoo-re
natemoo-re merged commit 2ebc906 into main Aug 27, 2026
12 checks passed
@natemoo-re
natemoo-re deleted the ref/clay-debug-tools branch August 27, 2026 15:15
@cowboyd

cowboyd commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

🎉

natemoo-re added a commit that referenced this pull request Sep 1, 2026
Cover everything landed since v0.8.0 that affects the published package;
resolves to a 0.9.0 minor bump.

- #116 border sides reserve layout space (minor, breaking within 0.x)
- #103 hardware cursor via text() caret (minor)
- #89 compile out Clay debug-tools, ~35% smaller wasm (patch)
- #49 correct width for non-printable/surrogate codepoints, Unicode 17 (patch)

Dependabot/CI bumps, the 2048 example, and docs-only commits get no
changeset.
natemoo-re added a commit that referenced this pull request Sep 1, 2026
* feat: adopt changesets for versioning and releases

Replace the tag-triggered publish workflow with a changesets-driven
flow and seed the historical changelog so future releases build on it.

- package.json becomes the version source of truth (0.8.0, private);
  the publishable artifact remains build/npm produced by dnt.
- .changeset config uses @changesets/changelog-github against
  bombshell-dev/tty.
- release.yml runs changesets/action on main: it opens a "Version
  Packages" PR from pending changesets, and on merge runs the publish
  command (npm run release).
- tasks/release.ts wraps the Deno/dnt flow: build:npm, publish
  build/npm, then tag v<version> and push. It no-ops when the version
  is already on npm, because changesets/action runs the publish command
  on every changeset-less push to main. Tags keep the existing
  v<version> format for continuity with v0.0.0..v0.8.0.
- CHANGELOG.md seeds all 14 releases in changelog-github format, with
  PRs attributed by the tag range their merge commit falls in and
  authors credited.
- deno.json fmt excludes CHANGELOG.md/.changeset so deno fmt does not
  rewrap changesets output.

* build(changeset): upgrade to changesets v3

Bump @changesets/cli ^2.29.7 -> ^3.0.1 and @changesets/changelog-github
^0.5.1 -> ^1.0.0, tracking the transitive @changesets/config@4.0.0 in the
config schema URL.

v3 stops versioning private packages by default. @bomb.sh/tty is
`private: true` (root is a build source; publish happens from build/npm via
tasks/release.ts), so opt back in with privatePackages.version. Leave
privatePackages.tag off because release.ts owns git tagging.

* chore(changeset): backfill changesets for unreleased main changes

Cover everything landed since v0.8.0 that affects the published package;
resolves to a 0.9.0 minor bump.

- #116 border sides reserve layout space (minor, breaking within 0.x)
- #103 hardware cursor via text() caret (minor)
- #89 compile out Clay debug-tools, ~35% smaller wasm (patch)
- #49 correct width for non-printable/surrogate codepoints, Unicode 17 (patch)

Dependabot/CI bumps, the 2048 example, and docs-only commits get no
changeset.

* docs(changeset): retrofit CHANGELOG to Astro conventions

Rework the backfilled history to match the changeset message style used
for new entries:

- Third-person present verbs throughout (Adds/Fixes/Renames), so future
  changeset-generated entries read consistently against the history.
- Reframe entries toward user-visible impact, dropping wire-format and
  build-mechanism detail that consumers can't act on.
- Drop non-user-facing entries (CI, tooling, tests, benchmarks, examples,
  internal docs); keep LICENSE since it ships in the package.
- Hoist the breaking Op->directive/name->id rename to the top of its
  Patch section (bump stays patch; it already shipped).

* build(changeset): refresh deno.lock for changesets v3

* fix(release): tag before publish and backfill missing tags

* fix(release): use changesets action v2.1.1 input names

* fix(release): disable action GH releases, drop hardcoded pkg name

* fix(release): keep publish.yml filename to preserve npm trusted publisher

* chore(changeset): tighten backfilled messages to match detail scale

Trim to the level of detail each bump warrants: patches to a single
sentence, the caret minor to one paragraph. The breaking border change
keeps its two paragraphs plus migration diff.

* fix(release): parse npm view --json for publish check

Rely on structured --json output instead of plain-text stdout when
checking whether the version is already on npm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants