Rope nodes live in the text buffer's arena and are never freed one at a time. setText and setTextFromMemId cleared the rope and built the new document in the same arena without resetting it, so every call kept the whole previous rope. A 2000-line text grew RSS by about 1.24 MB per call; 2000 calls reached 2.5 GB. EditBuffer.setText leaked the same way even though it clears undo history first. setStyledText did not leak because it reset the arena itself. clear() now resets the arena when the rope has no undo or redo history, so nothing can reference the old nodes. With history it still clears in place. The arena keeps its capacity, as setStyledText's reset did, so a document of similar size reuses the same pages. After the reset the rope points at a static empty document, so the release never allocates and running out of memory cannot leave the rope dangling. reset() and setStyledText use the same release instead of resetting the arena and rebuilding a rope that could fail after the old one was freed. loadFile stored the file bytes in the rope arena while the memory registry pointed at them, so a reset would hand those bytes to the next rope. The registry now owns them. #1543
OpenTUI is a library to build terminal user interfaces.
- It is written in Zig.
- You write TypeScript directly or through React and Solid.
- You arrange boxes and text with flexbox.
- You add selects, inputs, and scroll boxes with keyboard and mouse controls.
- You can play sounds, show images, and render 3D graphics.
OpenCode uses OpenTUI in production for millions of users.
Website | Documentation | Packages
Packages
@opentui/core- Native terminal UI library with TypeScript bindings.@opentui/react- React renderer for building terminal user interfaces with OpenTUI Core.@opentui/solid- Solid renderer for building terminal user interfaces with OpenTUI Core.@opentui/keymap- Key binding and command routing library for terminal and browser applications.@opentui/qrcode- QR code encoder and renderable with React and Solid surfaces.@opentui/three- Three.js WebGPU renderer for OpenTUI.@opentui/ssh- SSH server integration for OpenTUI applications.
Private packages
@opentui/native- Private workspace with the Zig implementation, native tests, and benchmarks.@opentui/examples- Private workspace with example applications and a standalone examples executable.@opentui/web- Private workspace with the documentation website and the AI agent skill.
AI agent skill
Install the OpenTUI documentation as a skill for your AI coding assistant with npx skills:
npx skills add anomalyco/opentui --skill opentui
Add -g to install the skill globally.
Development
Development requires Bun 1.4.1 or later and Zig 0.16.0.
See AGENTS.md for engineering, tooling, and verification conventions.
bun install
Run package scripts from their package directory. Run bun run build from the repository root after you change
native code or cross-package build outputs. Ordinary TypeScript changes do not require a root build.
Run repository tests and static checks from the repository root:
bun run test
bun run fmt:check
bun run lint
To link the source packages into a Bun-managed project, install that project's dependencies, then run
./scripts/link-opentui-dev.sh /path/to/project from the repository root. Add --react or --solid when needed.
Contributing
OpenTUI is open for contributions.
License
OpenTUI is licensed under the MIT License.