Skip to content

✨ ui: compose host layout and terminal rendering - #29

Closed
cowboyd wants to merge 1 commit into
tree-inputfrom
tree-ui
Closed

cowboyd wants to merge 1 commit into
tree-inputfrom
tree-ui

Conversation

@cowboyd

@cowboyd cowboyd commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The lower layers are deliberately modular, but users should not have to install every middleware subsystem and write a terminal loop before they can display an interface. createUI() becomes the composition root that owns the Host, built-in elements, focus and input routing, layout, render scheduling, terminal output, and terminal-mode lifecycle. Raw users receive a useful runtime immediately, while framework adapters remain responsible only for reconciliation.

Exposing the Host keeps the result composable: framework roots can mount at the UI root or any attached element, and multiple rendering approaches can coexist within one terminal session. Fullscreen and inline rendering remain internal policies, as do raw-mode input scanning and cleanup through explicit resource management. The initial renderer intentionally redraws the complete frame for every request, leaving coalescing and incremental rendering as future middleware improvements rather than requirements for the public API.

import { createUI } from '@clack/ui';

await using ui = await createUI({
	input: process.stdin,
	output: process.stdout,
});

const text = ui.host.createElement('text');
ui.host.insertBefore(text, ui.host.createLiteral('Hello!'));
ui.host.insertBefore(ui.host.element, text);

await ui.main();

This PR adds createUI(), the UI resource, the asynchronous input loop, and main(). It composes all Host subsystems with fullscreen or relative inline rendering and restores terminal settings when disposed. It also replaces the previous one-shot root/component helpers and updates the basic example to use the composed UI.

@cowboyd
cowboyd force-pushed the tree-ui branch 2 times, most recently from 29c6340 to db5a2b1 Compare August 7, 2026 06:47
@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

commit: f1d5f64

@socket-security

socket-security Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedvitest@​4.1.9 ⏵ 4.1.1198 +1100 +279 +198100
Updated@​types/​node@​22.20.0 ⏵ 22.20.4100 +110081 +196100
Addedtsx@​4.23.151001008195100

View full report

@cowboyd

cowboyd commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

closing out in favor of a DOM based substrate. See #37

@cowboyd cowboyd closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant