Skip to content

Opentui 0.9.0 - #63989

Open
simonklee wants to merge 25 commits into
devfrom
opentui-0.9.0
Open

simonklee wants to merge 25 commits into
devfrom
opentui-0.9.0

Conversation

@simonklee

@simonklee simonklee commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Added by the opencode bot (AI-generated).

Public API: plugin markdown code-block renderers now receive OpenTUI's MarkdownCodeBlock instead of marked's Tokens.Code; OpenTUI peer dependencies change to >=0.9.0 (breaking for plugins that use token.raw or pin 0.8.x)

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upgrade looks sound. I ran a simulated reply with Markdown reasoning, a list, a code fence and a table on the base and with this PR, then expanded the thought. Both screens look the same (screenshots below). Tests pass in packages/tui, packages/latex and the merman markdown test, apart from the dialog-shell-output timeout test, which fails on the base too. tsc -b is clean for tui and latex.

Public API: the plugin API changes in a way that breaks existing renderers.

  • ctx.markdown.registerCodeBlockRenderer(language, render): render is OpenTUI's MarkdownCodeBlockRenderer. Its first argument changes from marked's Tokens.Code (raw, text, lang, …) to OpenTUI's MarkdownCodeBlock (text, lang, info, closed; no raw). A plugin renderer that reads token.raw, or parses the fence itself as the latex renderer used to, has to switch to block.text / block.closed.
  • @opencode/plugin peer dependencies change from @opentui/core/@opentui/solid >=0.8.4 to >=0.9.0, so plugins pinned to 0.8.x will no longer resolve.

A short note for plugin authors in the release notes would help. Nothing else is blocking.

Before

After

OpenTUI 0.9 parses Markdown natively and drops marked, coalesced mode
and the renderable's internals. Session links rewrite the parser's
spans with inlineHook (only blocks holding "ses_"), answer clicks with
targetAt and rerun the hook for renamed sessions; scrollback commits
committedBlockCount blocks with the gap above each; mono mode maps
prose through a hook and markers through their text; renderNode is
renderBlock, and LaTeX reads a fence's closed flag.
A Markdown answer reaches scrollback one committed block at a time. Each
commit left the terminal on the block's last row, so the next commit's
blank gap row continued that line instead of making a blank row: on the
terminal "# Findings\n\n- stable" read "Findings\n- stable". A commit
of finished blocks now ends its last row; the entry's final commit
keeps the caller's line ending.
A fence that rendered a formula and then stopped parsing once its
closing line arrived lost its fallback: OpenTUI handed the renderer a
destroyed default and the fence went blank. OpenTUI keeps the default
now; this pins the sequence with the real renderer.
Each committed Markdown block ended its line, so when an entry finished
with complete(false) and its last block was already written, the line
was ended anyway: a continuation showed "A\n!" instead of "A!". A
committed block is now written once another block follows it; the
last one waits for completion, which ends it as the caller asks.
Select-dialog titles and the indented Read "Loaded" and execute error
lines set paddingLeft={3} on <text>. OpenTUI took that padding out of
the text's width but never painted it, so titles lined up with their
headers and the tool lines sat 3 cells in, from their parent box.

OpenTUI #2054 (2812326b0) paints text inside its padding. With it, every
select dialog's titles start 3 cells right of their header ("?    Title"
instead of "? Title") and the tool lines are indented 6 cells instead of 3.
Drop the props so the screen keeps today's look on both OpenTUI versions.
On 2812326b0, dialog-open's attention-icon test passes again, and the
headless Drive session's settled screens match those on the pinned 0.8.4.
createAnimatable drove every tween from one module-global 16 ms
setInterval, and the tab title marquee scrolled on its own 80 ms
setInterval. Neither shared frames with the renderer's other
animations, and both woke the process on wall-clock timers.

Tweens now hold one 60 fps subscription on the renderer's shared
animation clock while any of them runs, so createAnimatable takes the
renderer from context. The marquee waits on the renderer clock and
scrolls by the clock's tick count at 12.5 fps; its first step lands on
the clock's 80 ms grid, up to one step after the 600 ms delay.
The shimmer spinner's glyph and the sequenced one-cell spinner each ran
a private setInterval, so they never shared frames with the other
spinners and kept the process waking on their own phase.

Both now tick through onAnimationTick at their old rates (12.5 fps; the
one-cell spinner at 1000 / its step, 30 fps for the work spinners), and
advance by the tick count, so a late frame catches up instead of
dropping steps. Unmounting or turning animations off ends the
subscription.
RetryProvider's fade held the renderer live with requestLive and a frame
callback, and GoUpsellArt was a live renderable. Both kept the renderer
in its full-rate loop and blocked renderer.idle() while they ran.

RetryProvider now subscribes at 60 fps on the shared clock for the
length of a transition; the clock's first tick measures from the
subscription, so the "fresh" flag that skipped idle time goes. The Go
art sets animationFps to 30, the rate its dialog's live loop ran at, so
it ticks only while drawn and stops on hide or destroy.
ShimmerText was live for its whole life, and FadeInText and
TitleShimmer were live while they animated. Each held the renderer in
its full-rate loop, so renderer.idle() never resolved while one showed,
and they advanced their sweep by the frame's deltaTime in paint.

They now set animationFps to 60, the app's frame rate, and advance
their time in onAnimationTick. They tick only while drawn, stop when
hidden or destroyed, and FadeInText stops when its sweep ends.
TitleShimmer's "fresh" flag goes: the clock's first tick measures from
the subscription.
The Solid onAnimationTick hook and createAnimatable's clock are bound to
no node, so a view hidden with visible={false} keeps ticking. Core keeps
a node's draw state private, so binding them needs a Core API; until
then the call sites mount these views under <Show>.
The frame-rate rows counted frames and tickers, so an animation whose
time stopped still passed: the clock kept requesting frames. Each row
now samples the picture and needs it to change, and the Go art needs
six different pictures in 3 s. A late frame must land the one-cell
spinner and the tab marquee where steady frames do. A renamed title
must stop ticking once its wipe ends, and two tweens must share one
subscription that ends with the last of them.

Each new check fails on the break it targets (frozen shimmer, Go
art, title phase, one-cell spinner and tween; one step per tick in the
one-cell spinner and the marquee; no changed() after a title tick; a
subscription per tween).
The thought body is Markdown in a code block that paints nothing until the tree-sitter worker answers. That answer is not tied to frames, so three quiet frames after the click can pass while the box is still blank. OpenTUI 0.9.0's first highlight in a process lands later than 0.8.4's, and on a loaded runner the test failed every time.

Wait with waitForHighlightedFrame, as the other session tests do.
Deleting a file, agent or skill chip and undoing it brought the chip back styled, but its part was gone, so the prompt went out with the mention as plain text and no attachment. OpenTUI's undo restores a mark with its id and data, but these chips carried no data and the composer had already dropped the id from its map.

Each chip now stores its part in the mark's data, as pasted text already did, and sync rebinds a restored mark from it. The mini footer does the same.
The web composer stores mention ranges as string indexes and the TUI stores display cells, and the server keeps either. After a tab or a wide character before a mention, reverting or forking a prompt sent from the web put its chip on the wrong text: in "\t中 @f x" the web range 3..5 marked "中 ".

A restored range that covers its text as string indexes but not as cells is now converted to cells, as the edit buffer's stringIndexToCellOffset() would.
pasteAttachment ended the chip at the label's string length, but edit buffer offsets count cells. A pasted image that reuses an existing label with wide characters, such as "[图片 1]", got a chip two cells short, and the prompt sent a mention that missed the end of its label. The chip is now measured like pasted text and other mentions.
The compaction summary's Markdown stayed streaming after the compaction completed. A streaming document holds back a last line that can still change kind, such as a possible table row or a heading underline, so a finished summary ending in one never showed it. Streaming now follows the compaction's status, as assistant text already does.
A plugin append and an inline paste waited a tick to invalidate the prompt's intrinsic size and render again, and the cursor color was set again on a timer after mount. The prompt now grows in the frame that inserts the text, and the cursorColor prop already follows the disabled state, so the timers only delayed the cursor move to the end of an append by a frame. A test checks that both inserts show every line in their first frame.
The Go upsell dialog set the renderer's target and max fps to 30 while its art played. The art now ticks itself at 30 fps on the animation clock, so the cap no longer paced the art; it only slowed every other frame, such as typing and toasts, while the dialog was open, and it overwrote renderer-wide settings.
OpenTUI ends a palette query at the DA1 reply. An OSC 4/10/11 reply that arrives later, as over SSH or tmux, revises the renderer's palette and emits a palette event, but the full TUI only read the query's result, so the system theme kept the first, possibly default, colors until the next manual refresh. The theme now applies every palette event, as the mini footer already does; the query's own result goes through the same path.
Completions found the row and column of a range by moving the cursor to each end and reading it back. Each move fired a cursor-changed event, which reran the prompt's cursor-dependent keymap layers, and in OpenTUI 0.9.0 the cursor setter snaps to the edge of a chip, so a move could read a position other than the one asked for. The positions now come from the edit buffer's offsetToPosition(). deleteRange() already leaves the cursor at the start of the range, as the moves did.
Every content change rebuilt the prompt's files, agents, skills and pasted lists and assigned them to the store, even with no chips in the prompt, so each keystroke notified every reader of those lists. A list is now replaced only when its parts changed.
The transcript is one column of rows, and while an answer streams only its last row changes. As a flex column, every frame ran Yoga's flex pass over every mounted row. A list lays out only the row that changed and reuses the others' sizes. Transcript rows never grow or shrink, so the layout is the same.
OpenTUI 0.9.0 draws Markdown prose natively, so answers no longer start the tree-sitter worker. The first thought or code fence then paid the whole cold start (worker, parser init, markdown grammars and queries) on the frame that showed it. The TUI now starts the worker and preloads the markdown and markdown_inline parsers once the first frame is out, and skips the rest if it is closing.

On a loaded machine, the first expanded thought after startup now highlights in 93 ms instead of 184 (median of 10 fresh starts) and the first TypeScript fence in 171 instead of 203, for about 40 ms of worker CPU once. With the worker warm, the backfill test's original quiet-frames wait passes again, also pinned to one busy CPU, so it goes back to that wait.
Reasoning was drawn as highlighted Markdown source in a code view, with markers concealed in rendered mode. With session.markdown set to rendered, thoughts now use OpenTUI's native Markdown, as answers do: tables are grids, headings and lists render, and fences show their code without the markers. None of the reasoning text goes to the highlighter, which re-highlighted the whole thought on every delta. The thought keeps its muted reasoning colours, and it stops streaming when the part completes, so a last line that could still change kind shows once the thought is done.

In source mode nothing changes: the code view and its props are the same. The mini footer follows the same setting for reasoning in scrollback and in the subagent view.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new push is a rebase onto a newer dev. The PR's 25 commits are identical patch for patch, so my earlier review still applies and I have nothing new to add. I didn't get type-check or test results on the rebased head before reporting.

Public API: unchanged since the last review. Plugin code-block renderers registered with ctx.markdown.registerCodeBlockRenderer now receive OpenTUI's MarkdownCodeBlock (text, lang, info, closed) instead of marked's Tokens.Code, so raw is gone. The @opentui/core/@opentui/solid peer dependencies move from >=0.8.4 to >=0.9.0. Both changes break existing plugins.

This branch has not been deployed

No deployments
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