Simon Klee 78ca1edb70 native: grow the object handle table instead of failing at object_capacity (#1622)
A Context's native object table had a fixed size of `object_capacity`
slots, and a renderer creates its Context with 65,536. Every Markdown
table cell holds a text buffer and a view, so a long document or chat
transcript failed after about 32,500 cells with
`ot_text_buffer_view_create failed: ObjectLimit`, whether it was set at
once or streamed. Plain renderables hit the same limit at 65,534.

The table now starts at `object_capacity` and doubles when it is full,
up to 4,194,304 slots, or `object_capacity` if that is larger. Past
that, creation still returns `ObjectLimit`. Handles keep their slot
index and generation, so existing handles stay valid, and no code holds
a pointer into the slot array across an insert. The cap comes from
memory, not the handle format: a slot is 32 bytes, so the cap is 128
MiB, and each live slot owns a much larger native object. There is no
ABI change. The comments in `opentui.h` and the docs now call
`object_capacity` the initial size. A clipboard start that fails to grow
the table reports out of memory instead of limit exceeded.

The handle-table model test starts at 2 slots and checks growth to 4 and
5, old handles, stale handles, and `ObjectLimit` at the maximum. A
Markdown test renders a table that needs more objects than a 64-slot
renderer, and it fails on main with the issue's error. Tests that check
cleanup at `ObjectLimit` now pin the maximum. Reverting growth, the
doubling, the clamp, the `>=` maximum check, or growth inside `insert`
each fails a test.

Fixes #1611
2026-10-10 15:00:57 +02:00
2025-07-21 17:47:38 +02:00
2026-03-23 15:59:52 +01:00
2025-08-12 12:01:55 +02:00

OpenTUI logo

npm version Core build status

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 https://opentui.com --skill opentui

Add -g to install the skill globally. The skill matches the latest release, and npx skills update moves it to each new release. Install from https://opentui.com/docs/next to follow the main branch. A skill installed with npx skills add anomalyco/opentui follows the main branch; run the command above to switch it to releases.

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.

S
Description
No description provided
Readme MIT
75 MiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 63.1%
Zig 27.8%
MDX 6.1%
C 1%
Astro 0.8%
Other 1.1%