[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay
5

Configure Feed

Select the types of activity you want to include in your feed.

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

Clay's debug inspector (Clay__RenderDebugView, ~700 lines + ~150 UI strings) is reachable from the exported Clay_EndLayout behind a runtime debugModeEnabled branch, 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_DISABLE_DEBUG_TOOLS guard (patches/clay-disable-debug-tools.patch) applied to the clay submodule at build time and opted in via -DCLAY_DISABLE_DEBUG_TOOLS.

raw wasm 155,934 -> 111,234 (-28.7%); brotli 41,809 -> 30,417; npm esm/wasm.js 53,143 -> 38,903 (-13.9 KB unpacked). Cold path only (debugModeEnabled always false at runtime); deno task test passes.

Nate Moore (Jun 6, 2026, 12:12 PM -0500) d08642c0 48ff4bbc

+44 -1
+10 -1
Makefile
··· 1 1 CC = clang 2 2 TARGET = clayterm.wasm 3 3 SRC = src/module.c 4 + CLAY_PATCH = patches/clay-disable-debug-tools.patch 4 5 5 6 CFLAGS = --target=wasm32 -nostdlib -O2 \ 6 7 -ffunction-sections -fdata-sections \ 7 8 -mbulk-memory \ 8 9 -DCLAY_IMPLEMENTATION -DCLAY_WASM \ 10 + -DCLAY_DISABLE_DEBUG_TOOLS \ 9 11 -Isrc -I. 10 12 11 13 EXPORTS = \ ··· 46 48 47 49 DEPS = $(wildcard src/*.c src/*.h) 48 50 49 - $(TARGET): $(DEPS) 51 + # Gate out Clay's unused debug-tools UI (upstream-compatible #ifndef guards), 52 + # opted in via -DCLAY_DISABLE_DEBUG_TOOLS. Idempotent (skips if the guard is 53 + # already present) and verified (fails the build if it didn't apply). 54 + # Drop once Clay ships the flag upstream. 55 + $(TARGET): $(DEPS) $(CLAY_PATCH) 56 + @grep -q CLAY_DISABLE_DEBUG_TOOLS clay/clay.h || git -C clay apply ../$(CLAY_PATCH) 57 + @grep -q CLAY_DISABLE_DEBUG_TOOLS clay/clay.h || { echo "ERROR: failed to apply $(CLAY_PATCH) to clay/clay.h" >&2; exit 1; } 50 58 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(SRC) 51 59 52 60 wasm.ts: $(TARGET) ··· 54 62 55 63 clean: 56 64 rm -f $(TARGET) wasm.ts 65 + -git -C clay checkout -- clay.h 57 66 58 67 .PHONY: all clean
+34
patches/clay-disable-debug-tools.patch
··· 1 + diff --git a/clay.h b/clay.h 2 + index 80d8393..8bf723b 100644 3 + --- a/clay.h 4 + +++ b/clay.h 5 + @@ -3145,6 +3145,7 @@ CLAY_DLL_EXPORT Clay_ElementIdArray Clay_GetPointerOverIds(void) { 6 + return Clay_GetCurrentContext()->pointerOverIds; 7 + } 8 + 9 + +#ifndef CLAY_DISABLE_DEBUG_TOOLS 10 + #pragma region DebugTools 11 + Clay_Color CLAY__DEBUGVIEW_COLOR_1 = {58, 56, 52, 255}; 12 + Clay_Color CLAY__DEBUGVIEW_COLOR_2 = {62, 60, 58, 255}; 13 + @@ -3842,6 +3843,7 @@ void Clay__RenderDebugView(void) { 14 + } 15 + } 16 + #pragma endregion 17 + +#endif // CLAY_DISABLE_DEBUG_TOOLS 18 + 19 + uint32_t Clay__debugViewWidth = 400; 20 + Clay_Color Clay__debugViewHighlightColor = { 168, 66, 28, 100 }; 21 + @@ -4237,11 +4239,13 @@ Clay_RenderCommandArray Clay_EndLayout(void) { 22 + Clay_Context* context = Clay_GetCurrentContext(); 23 + Clay__CloseElement(); 24 + bool elementsExceededBeforeDebugView = context->booleanWarnings.maxElementsExceeded; 25 + +#ifndef CLAY_DISABLE_DEBUG_TOOLS 26 + if (context->debugModeEnabled && !elementsExceededBeforeDebugView) { 27 + context->warningsEnabled = false; 28 + Clay__RenderDebugView(); 29 + context->warningsEnabled = true; 30 + } 31 + +#endif // CLAY_DISABLE_DEBUG_TOOLS 32 + if (context->booleanWarnings.maxElementsExceeded) { 33 + Clay_String message; 34 + if (!elementsExceededBeforeDebugView) {