Repository navigation
cli: Package terminal apps with nsh package --target tui - #4186
Conversation
The terminal host runs the bundle in an nsh directory next to its executable, so the package is the host (the app's own, with its Rust crates, or the prebuilt one) with the bundle beside it, as on Linux. Closes #4175 Agent: lead Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
✅ LGTM (direction approved by the owner): Reviewed head: b399d63 |
|
✅ LGTM: implementation fits the approved
Diff-only review at |
Closes #4175.
nsh run --target tuiruns an app with its Rust crates (such as Yoke'syoke/nativemodule), butnsh packagehad no terminal target, so apps built and shipped the executable themselves. This addsnsh package --target tui.What it makes
.nsh/out/<Name>/for this machine's OS and processor, and the same as<Name>.tar.gz:nsh.json"rust"or"root") gets its own terminal host, built optimized with its crates, the same hostnsh run --target tuibuilds; a TSX app gets the prebuilt one from thetuicomponent. A Rust app ("root") has no bundle and the host mounts its root.main_with_optionschecks fornsh/app.jsonnext to the canonical executable, so a symlink in~/.local/binstill works. When it finds one, it runs that package: it reads the bytecode as the app's own resource, as the Linux runner does, appliesdataDirandtui.pointsPerCell, and passes the command line to the app instead of parsing host flags. Development hosts never have that directory beside them, sonsh run/nsh testbehave as before. As with--bundle, an app error ends a packaged run.--runruns the package in the current terminal.--signis refused. No updater: the terminal host does not update itself.Public API
nshCLI:nsh package --target tui: packages a terminal app (above). This is the only public addition: no new flag and no newnsh.jsonkey.tui.pointsPerCellanddataDirare existing keys. Why it is needed: today a terminal app can only be shipped with a hand-made build of the host.nsh run --target tuialready builds this host, and the other desktop targets already have packages. It follows the precedent of cargo-dist and of Ratatui/Bubbletea apps, which ship one executable plus resources per platform as a.tar.gz.nsh-tui-host(Rust): no signature changes.Argsgains a private,#[arg(skip)]field (Argsis already#[non_exhaustive]).Tests
cargo test -p nsh-tui-host --lib package: readsapp.json(dataDir,pointsPerCell) and reports a package with neither a bundle nor a root.package::tests::tui_packages_for_this_machine(nsh-cli): parses the target and checks its asset target andapp.json.nsh package examples/counter --target tuimadeCounter/counterandCounter.tar.gz. Runningcounterwith no arguments in a pty (100×30) renderednsh counter Current value 0 −1 +1, and it exited 0 on SIGTERM.nsh package examples/rust-exports --target tui. This is a TSX app with a Rust crate, like Yoke. It built the app's terminal host in release mode, then madeRust Exports/rustexports(66 MB, unstripped) plusnsh/bundle.nshcandnsh/app.json. Running it in a pty rendered the Rust module's values (Ledger · a module Formatted at once: $1,234.50,Account · a class Savings: $120.00,Meter · a native component 25% of the budget spent), and it exited 0 on SIGTERM.Not tested: Linux and Windows terminals. The code path is the same, and on Windows the executable gets
.exe.🤖 Noop (lead) · Opus 5.5 acting for @huacnlee