Skip to content

chore(cli-rs): pin OpenTUI 0.9.8 and share one syntax theme across views - #65901

Merged
simonklee merged 3 commits into
devfrom
native-opentui-098
Nov 23, 2026
Merged

simonklee merged 3 commits into
devfrom
native-opentui-098

Conversation

@simonklee

Copy link
Copy Markdown
Member

What it does

  • Pins OpenTUI 0.9.8 (opentui, opentui-sys; the native library table row for the v0.9.8 release, all eight
    platform zips checked).
  • Shares one syntax theme per app theme across views. 0.9.8 lets Markdown, Code, Diff and Textarea take an
    Arc<SyntaxTheme>. The client now builds one per theme and hands clones to every view (transcript, run theme,
    plugins, dialogs, prompt chips) instead of each view building its own.
  • Regenerates plugin.luau from the protocol's new request-parameter descriptions (doc comments only).

What it buys

Fewer allocations wherever views are built, from bun run perf (5 runs each), with instruction counts down too:

Scenario Allocations Bytes Instructions
mini replay −31.4% −20.9% −6.0%
page back −20.1% −2.8% −5.6%
jump Home/End −19.8% −2.9% −4.7%
open a long session −19.0% −9.8% −5.2%
scroll −18.9% −3.2% −3.8%
scroll the whole session −3.8% −2.0% −1.7%
stream −0.1% = =

stream builds one Markdown view and streams into it, so the per-view saving barely shows there. No scenario rose.

Behaviour changes in 0.9.8, checked against this client

  • ScrollBox::sticky(true) now re-sticks only from the edge, as Core does. The transcript, shell output, mini's
    footer and plugin scrolls all turn it on at the edge, so nothing changes for them.
  • A box laid out at 0 rows keeps its scroll target. Nothing here relied on the old "the end".
  • Typing at a line start goes after leading zero-width text. The prompt inserts none, and its extmarks start at
    visible text.
  • Host::release() reads the terminal size before resuming, which fixes a resize while suspended.

None needed a code change.

Checks

fmt, clippy, the TUI, store, plugin, UI and mini test suites, and the full parity suites (P-APP, P-TUI, P-CLI, P-PTY,
ACP), all green on the integration branch.

OpenTUI 0.9.8 takes `syntax_theme(impl Into<Arc<SyntaxTheme>>)`, so a
view can keep a shared theme instead of its own copy of about 90 styles.
`code::syntax_theme` now returns an `Arc`, one per equal theme (the last
four kept, as page and dialog surfaces differ), and every view, the
transcript's `Paint` and mini's `RunTheme` pass clones of it.

Mini's `recolor` is gone: it only ran on the one-style theme already in
the entry color, so it changed nothing.

@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.

I couldn't build this: the review environment has no Rust toolchain, so I couldn't run cargo, the test suites or bun run perf. This is a code read only, and I found nothing that blocks a merge.

What I checked:

  • Theme cache: the cache in opencode_ui::code::syntax_theme is keyed on Theme's PartialEq. That covers everything styles() reads: the surface tokens, accent() and categorical().
  • Callers: none of the existing callers mutates the shared Arc. Mini copies it out with Arc::unwrap_or_clone before quantizing.
  • Removed recolor: in mini/src/scrollback.rs it only ever ran on the one-color fallback theme, so removing it changes no output.

One small note, not blocking: the cache drops the oldest entry, not the least recently used. A theme switch on all three surfaces (page, dialog, dialog footer) can therefore push out entries still in use, and the views would build their own syntax themes again. That only costs the allocation saving; it can't paint wrong colors.

Public API: unchanged. plugin.luau only gains two doc comments on existing types, and the Rust signature changes (&SyntaxTheme → &Arc<SyntaxTheme>) are internal to the cli-rs crates.

@simonklee
simonklee merged commit 340b422 into dev Nov 23, 2026
11 checks passed
@simonklee
simonklee deleted the native-opentui-098 branch November 23, 2026 22:07
beyondChang pushed a commit to beyondChang/opencode that referenced this pull request Nov 24, 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