Repository navigation
refactor: extract the ox-tui crate - #454
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
hakula139
force-pushed
the
refactor/ox-tui-crate
branch
from
October 20, 2026 11:55
0d8722d to
bcc16b2
Compare
The terminal UI and the slash commands lived in the `ox` binary crate, so the binary linked ratatui, crossterm, and the other TUI-only crates, and an ACP frontend in `ox` would share a crate with the TUI internals. Move `tui` into the `ox-tui` library crate, flattened so `tui::app` becomes `ox_tui::app`, together with `slash`, the themes, and the TUI driver, which becomes `ox_tui::run` and `ox_tui::Startup`. `ox` keeps `main.rs` and the REPL and headless drivers, and reaches the TUI only through `run`, `Startup`, `slash::ResumePicker`, the theme resolver, the two stdio glyphs, and `terminal::stdout_width`, which replaces the `--list` width probe so `ox` no longer depends on crossterm. The 58 TUI and slash snapshot baselines take the `ox_tui__` prefix, and the design docs, the module map, and the conventions follow the new paths.
Flattening `tui` into the crate root turned `pub(super)` in its direct children from "within `tui`" into "within the crate", so those files mixed two spellings of the same visibility. Spell it `pub(crate)` there, as `ox-core`'s top-level modules do, keep `pub(super)` for items in nested modules, where it is still narrower, and state the rule in `rust.md`.
Flattening `tui` also made `super::` in its direct children name the crate root, so six of them imported siblings through `super::` while the rest of the crate, and every top-level module in `ox-core`, uses `crate::`. Spell those imports and the one doc link `crate::`, as their own test modules already do.
Only `theme`'s child `loader` uses `for_each_slot` and `SLOT_NAMES`, so both become private. The `slash::testing` fixtures `stamped_id` and `with_isolated_xdg`, the test-only `SlashOutcome::into_*` accessors, and `LineEditor::with_placeholder` serve only modules under their parent, so they become `pub(super)`.
hakula139
force-pushed
the
refactor/ox-tui-crate
branch
from
October 20, 2026 12:16
bcc16b2 to
e1d9198
Compare
This was referenced Oct 20, 2026
hakula139
added a commit
that referenced
this pull request
Oct 22, 2026
#565) ## Summary The architecture doc stated the crate dependency rules but not how they are enforced, so the `cargo deny` wrapper bans that #451 removed came back in #454 as an optional guard before they were dropped again. Both versions banned terminal UI crates outside the frontend crate. - **Dependency Direction:** `docs/design/architecture.md` now says the crate manifests encode the crate direction and the terminal UI rule, review of manifest changes enforces both, and `deny.toml` holds no crate-layering bans. ## Test plan - [x] `pnpm format`, `pnpm lint`, and `pnpm spellcheck` pass, and the pre-commit hooks pass on the commit. - [x] `deny.toml` on `main` has no `[[bans.deny]]` entries. - [x] `cargo tree -p ox-core -e normal -i ratatui` and `-i crossterm` match no package, and `ox` reaches both only through `ox-tui`.
1 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After #451, the terminal UI and slash commands still lived in the
oxbinary crate. As a result,oxdepended onratatui,crossterm, and the other TUI crates, and the ACP frontend planned in #150 would share a crate with the TUI internals. This PR movestui,slash, the themes, and the TUI driver into theox-tuilibrary crate, leavingoxwithmain.rs, the CLI, and the REPL and headless drivers. The binary, its CLI and output, the release asset names, the Homebrew formula, andnix build .#oxide-coderemain unchanged.crates/ox-tui(crateox_tui) holdstui's modules flattened into the crate root, sotui::appbecomesox_tui::app, along withslash, the five built-in themes incrates/ox-tui/themes, and the TUI driver, whoserunandStartupnow sit inlib.rsbeside the module declarations fromtui.rs.oxkeepsmain.rs, the CLI and live tests, and thedrivermodule with the REPL and headless drivers and the exit status and shutdown signals that the TUI shares.ox-tuidepends onox-core, andoxdepends on both.oxusesrun,Startup,slash::ResumePicker::at_startup,theme::{resolve_theme, ResolvedTheme, Theme}, the stdio drivers'glyphs::{task_marker, INTERRUPTED_MARKER}, andterminal::stdout_width. Onlyglyphs,slash,terminal, andthemearepubmodules, and every other item stays crate-private.runkeeps the signature from refactor(oxide-code): narrow the frontends' reach into core internals #438, with the theme as its own parameter. Moving the theme intoStartupwould keepThemecrate-private, but it would rewrite the setup at the start ofrun, which needs a real terminal and runs in no test. The version on the welcome screen and in/statusnow comes fromox-tui'sCARGO_PKG_VERSION, which matchesox's because every crate inherits the workspace version.superalready names the crate root, so the flattened modules spell crate-wide itemspub(crate)and import their siblings throughcrate::, asox-core's top-level modules do, while nested modules keepsuper.rust.mdnow states the visibility rule.for_each_slotandSLOT_NAMES, which onlytheme's childloaderuses, became private, and six helpers that only modules underslashormodalcall becamepub(super).NOTICE_DURATIONandnoware private inlib.rs, since only the crate's own modules use them.oximportsox_tui::items besideox_core::in the workspace crates group.ox-tuitakesratatui,ratatui-textarea,crossterm,arboard,syntect,pulldown-cmark,open,base64,unicode-segmentation,unicode-width, andfuturesfromox.oxkeepsindoconly for its tests and dropsuuidand tokio'stest-utilfeature, which only the TUI tests used. Because the--listwidth probe moved fromox'sdetect_terminal_widthtoox_tui::terminal::stdout_width,oxno longer depends oncrossterm.ox-tuineeds notestingfeature because no other crate uses its fixtures, so they stay in#[cfg(test)]modules.ox__tui__andox__slash__prefixes toox_tui__, and theirsource:headers point to the new paths, while the four headless driver baselines keep their names.package.nixalready takes all ofcrates, the release workflow still generates the notices fromcrates/ox/Cargo.toml, and.cargo/mutants.tomlalready excludes everytestingmodule.ox_tui::...targets in place ofox::tui::...,ox::slash::..., andox::driver::tui.EnvFiltermatches targets by prefix, soRUST_LOG=ox=debugstill selects all three crates andox_tui=debugselects only the TUI, while a module directive such asox::tui::app=debugbecomesox_tui::app=debug. The log format is outside the stability surface.ox-tuimodules andlib.rsand states how the three crates depend on each other, the AGENTS.md layout addscrates/ox-tui,rust.mdaddsox_tui::to the workspace import group,testing.mdfollows the new crate and paths, and 109 source paths in the design docs and the theming guide point tocrates/ox-tui, with their Sources lists re-sorted. Theglyphsandterminalmodule docs now match their map rows.Part of #149
Test plan
cargo fmt --all --check,cargo build(no warnings),cargo clippy --all-targets -- -D warnings,cargo clippy -- -D warnings, andcargo doc --no-depspassed.cargo llvm-covpassed 3,123 unit tests (1,670 inox-core, 1,396 inox-tui, and 57 inox), matching main's count, and 8 CLI tests, with 99.29% line coverage, equal to main. Per file, the uncovered lines match main's, except thatmain.rshas 4 fewer now thatdetect_terminal_widthis gone andterminal.rshas 1 more instdout_width's terminal branch. The cache hit inInputArea::visual_line_countis covered in some runs and not others.cargo test -p ox-tuiandcargo test -p oxon their own passed all 1,396 and 57 + 8 tests, so neither relies on features that another crate's dev-dependencies turn on.cargo insta test --workspace --unreferenced=rejectfound no unreferenced snapshots and left no.snap.newfiles.cargo checkwith-W unused-crate-dependenciesfound no unused dependency in-p ox-tui --libor-p ox --bin ox.cargo tree -p ox -e normal --depth 1lists onlyanyhow,clap,ox-core,ox-tui,serde,serde_json,time,tokio,toml, andtracing.cargo deny check licenses advisories sources banspassed. The lockfile diff only adds theox-tuientry and moves dependencies fromoxto it.nix build .#oxide-codebuiltbin/ox, ran the test suite, and passed its version check. The stripped release binary is 17,875,368 bytes, compared with 17,784,312 for main's build (+0.5%), andox --helpis byte-identical.cargo install --gitfrom this branch with--lockedinstalledox.cargo mutants --workspace --listlists 6,175 mutants, compared with main's 6,176. The only difference is that the 4 mutants ofdetect_terminal_widthbecame the 3 ofstdout_width. A full mutation pass was not run.lattetheme, showed the notice for an unknown theme override, listed a session from a headless run in/resume, listed the commands in/help, and exited 0 on Ctrl+D.ox --listprinted the same output as main's binary in a terminal and through a pipe.pnpm format,pnpm lint, andpnpm spellcheckpassed, and the pre-commit hooks ran on each commit.ox --versionchecks.