Skip to content

Release v0.9.10

Latest

Choose a tag to compare

@github-actions github-actions released this 30 Nov 09:16
v0.9.10
2f7ff2a

Suppose a prompt has a footer, and the footer has a status line. One plugin adds a clock to the status line. Another plugin replaces the whole footer. Where does the clock go? The slot registry cannot answer that question. It gives each slot one flat name, and its slots do not contain each other.

OpenTUI 0.9.10 adds a slot tree to @opentui/core. A slot path is names joined by dots, and a path contains every path that extends it at a dot: prompt.footer contains prompt.footer.status, but not prompt.footerbar. The host mounts paths. Each plugin is an owner that claims a place before, after, or inside a path, or that replaces it. In Solid and React, createTreeSlot binds a tree to a Slot component:

type Slots = { "prompt.footer": { user: string }; "prompt.footer.status": {} }

const tree = new SlotTree<JSX.Element, Slots>()
const Slot = createTreeSlot(tree)

export function Footer(props: { user: string }) {
  return (
    <Slot path="prompt.footer" input={{ user: props.user }}>
      <Slot path="prompt.footer.status">
        <text>ready</text>
      </Slot>
    </Slot>
  )
}

const stage = tree.owner("clock").stage()
stage.claim({ append: "prompt.footer.status", render: () => <text> 12:00</text> })
stage.commit()

Two rules answer the question about the clock. First, the last replace on a path wins and suppresses every claim inside that path, so a plugin that replaces prompt.footer also hides the clock. Second, an added claim on a path that is not mounted goes to the end of the nearest mounted ancestor. If the host never mounts prompt.footer.status, the clock shows at the end of prompt.footer. tree.resolution() lists the suppressed claims, each with the claim that won, and the claims that moved to an ancestor. A host can use that list to explain why a plugin's content does not show.

A stage holds a plugin's claims until commit(), so a plugin that fails during setup shows nothing: call stage.dispose() and its claims never show. Each claim renders in its own error boundary. A claim that throws calls the tree's onError and shows the placeholder. The other claims in the slot still render. The slot registry, SlotRenderable, and the existing Slot components do not change. Rust apps get the same tree as opentui::slot. The Rust crate and Core check the same table of expected results.

Added

  • core: SlotTree holds plugin claims on nested slot paths, such as prompt.footer and prompt.footer.status. resolveSlotClaims() resolves claims without a tree, and slotPathContains() tells if one path contains another. See Load plugins and modules at runtime. (#2204)
  • react: createTreeSlot(tree, options) returns a Slot component for a SlotTree. Each claim renders in its own error boundary, and options.placeholder shows instead of a claim that fails. See Load plugins and modules at runtime. (#2204)
  • solid: createTreeSlot(tree, options) returns a Slot component for a SlotTree. Each claim renders in its own error boundary, and options.placeholder shows instead of a claim that fails. See Load plugins and modules at runtime. (#2204)
  • native: The Rust crate adds opentui::slot, a slot tree that resolves claims as Core does. Tree::mount returns a Slot widget, and a plugin claim with an empty name in its path returns MountError::InvalidPath. See Widgets and layout. (#2205)
  • native: The Rust crate adds Fragment, a container with no box of its own. Its children lay out, draw, take focus, and receive clicks as children of the fragment's parent. See Widgets and layout. (#2201)

Fixed

  • native: With the Kitty keyboard protocol, the parser now reads a key report that a slow link splits before its first ;. Before, ESC [97, a pause, and then ;2u typed ;2u instead of Shift+A. See Keyboard input. (#2207)
  • core: If a renderBlock function renders code blocks, MarkdownRenderable no longer shows a code block in a list item twice. The extra copy appeared after a theme change or after a change to fg, bg, conceal, the table options, or streaming. See Markdown. (#2208)
  • native: In the Rust crate, Markdown quotes now draw as in Core. Code and table text in a quote use the text color, an empty quote (>) draws its bar, and list markers use only the list style. See Code, Markdown, and highlighting. (#2210)
  • native: On Linux, the native library no longer adds a 256 kB Zig signal stack to each thread of the process. An idle thread now uses 12 kB of RSS instead of 268 kB, and a thread with a stack of 256 kB or less can start. See Native rendering. (#2218)

API changes and documentation: https://opentui.com/docs/releases/0.9.10

What's Changed

  • rust: add Fragment, a container with no box of its own by @simonklee in #2201
  • core, rust, native: share input vectors and check parser properties by @simonklee in #2206
  • native: keep a Kitty key cut before its first ; waiting by @simonklee in #2207
  • core: show a renderer's code block once when a list restyles by @simonklee in #2208
  • rust: run the shared text corpus; keep the width map in JSON by @simonklee in #2212
  • core: give two models the inputs their bugs needed by @simonklee in #2209
  • rust, core: draw Markdown quotes as Core does; share frame rows by @simonklee in #2210
  • core: check Kitty keys cut before their first ; in the timeout property by @simonklee in #2214
  • core, solid, react: add a hierarchical slot tree by @simonklee in #2204
  • rust: add the slot tree as opentui::slot by @simonklee in #2205
  • web: update OpenMono to 1.001 by @iamdavidhill in #2217
  • native: drop Zig's per-thread signal stack from the library by @simonklee in #2218

Full Changelog: v0.9.9...v0.9.10