Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .agents/skills/tui-previews/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Generate deterministic Maple Mono NF lossless `.webp` snapshots of `ox-tui` thro
2. **Regenerate all WebP previews and SHA-256 checksums** (`docs/assets/themes/*.webp`, `docs/assets/tui/*.webp`, `docs/assets/demo/ox-demo.webp`, `docs/assets/previews.sha256`, and `docs/assets/demo/ox-demo.sha256`):

```bash
./scripts/render-previews.sh
./scripts/render-previews.nu
```

This exports intermediate SVGs with `cargo run -p ox-tui --example render_previews`, rasterizes them at 2x zoom with `resvg` using `nixpkgs#maple-mono.NF` (`--skip-system-fonts --monospace-family "Maple Mono NF"`), encodes lossless `.webp` assets via `cwebp -lossless` / `img2webp -lossless`, and writes the matching SHA-256 manifests only after every `.webp` succeeds. Always regenerate the `.webp` previews, `ox-demo.webp`, and both `.sha256` files together via `./scripts/render-previews.sh`, and never update `.sha256` manifests alone.
This exports intermediate SVGs with `cargo run -p ox-tui --example render_previews`, rasterizes them at 2x zoom with `resvg` using `nixpkgs#maple-mono.NF` (`--skip-system-fonts --monospace-family "Maple Mono NF"`), encodes lossless `.webp` assets via `cwebp -lossless` / `img2webp -lossless`, and writes the matching SHA-256 manifests only after every `.webp` succeeds. Always regenerate the `.webp` previews, `ox-demo.webp`, and both `.sha256` files together via `./scripts/render-previews.nu`, and never update `.sha256` manifests alone.

3. **Visually inspect the rendered `.webp` images** directly with `read_file` (for example `docs/assets/themes/catppuccin-mocha.webp`, `docs/assets/themes/catppuccin-latte.webp`, `docs/assets/tui/resume-picker.webp`, `docs/assets/tui/rewind-picker.webp`, `docs/assets/tui/permission-confirm.webp`, `docs/assets/tui/statusline-styles.webp`) and check:

Expand Down
15 changes: 15 additions & 0 deletions crates/ox-tui/tests/common/demo_frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ fn base_app() -> App {
}

fn record_scene_1_initial(app: &mut App, recorder: &mut FrameRecorder) {
// Scene 1: Initial composer with rounded pill statusline (26% context).
app.apply_agent_event(AgentEvent::TurnUsage(Usage {
input_tokens: 52_000,
output_tokens: 0,
Expand All @@ -130,13 +131,15 @@ fn record_scene_1_initial(app: &mut App, recorder: &mut FrameRecorder) {
}

fn record_scene_2_prompt_and_trigger(app: &mut App, recorder: &mut FrameRecorder) {
// Scene 2: Character-by-character typing with `@` file completion.
type_input(
app,
recorder,
"",
"Fix timeout handling in @crates/ox-core/",
);

// Open the `@` file trigger popup on the first match.
app.set_active_trigger(Some(ActiveTrigger {
prefix: '@',
start_byte: 24,
Expand All @@ -147,6 +150,7 @@ fn record_scene_2_prompt_and_trigger(app: &mut App, recorder: &mut FrameRecorder
}));
recorder.capture(app, 1100);

// Move selection to `crates/ox-core/src/plugin.rs`.
app.set_active_trigger(Some(ActiveTrigger {
prefix: '@',
start_byte: 24,
Expand All @@ -157,6 +161,7 @@ fn record_scene_2_prompt_and_trigger(app: &mut App, recorder: &mut FrameRecorder
}));
recorder.capture(app, 650);

// Accept the file path and type the rest of the prompt.
let completed = "Fix timeout handling in @crates/ox-core/src/plugin.rs";
app.set_active_trigger(None);
app.set_input(completed.to_owned());
Expand All @@ -167,6 +172,7 @@ fn record_scene_2_prompt_and_trigger(app: &mut App, recorder: &mut FrameRecorder
}

fn record_scene_3_skill_and_tools(app: &mut App, recorder: &mut FrameRecorder) {
// Scene 3: Submit prompt, stream thinking, load `rust` skill, edit `plugin.rs`, and test.
app.set_input(String::new());
_ = app.submit_user_message(
"Fix timeout handling in @crates/ox-core/src/plugin.rs and add a test".to_owned(),
Expand All @@ -178,13 +184,15 @@ fn record_scene_3_skill_and_tools(app: &mut App, recorder: &mut FrameRecorder) {
));
recorder.capture(app, 1300);

// Auto-load the `rust` skill before inspecting the Rust source file.
app.apply_agent_event(AgentEvent::ToolCallStart {
id: "call_1".to_owned(),
name: "load_skill".to_owned(),
arguments: json!({ "name": "rust" }),
});
recorder.capture(app, 1500);

// Finish skill load and read `crates/ox-core/src/plugin.rs`.
app.apply_agent_event(AgentEvent::ToolResult {
call_id: "call_1".to_owned(),
name: "load_skill".to_owned(),
Expand All @@ -200,6 +208,7 @@ fn record_scene_3_skill_and_tools(app: &mut App, recorder: &mut FrameRecorder) {
});
recorder.capture(app, 1600);

// Edit `crates/ox-core/src/plugin.rs` to add timeout handling.
app.apply_agent_event(AgentEvent::ToolResult {
call_id: "call_2".to_owned(),
name: "read".to_owned(),
Expand All @@ -213,6 +222,7 @@ fn record_scene_3_skill_and_tools(app: &mut App, recorder: &mut FrameRecorder) {
});
recorder.capture(app, 1500);

// Run the targeted `cargo test` check.
app.apply_agent_event(AgentEvent::ToolResult {
call_id: "call_3".to_owned(),
name: "edit".to_owned(),
Expand All @@ -226,6 +236,7 @@ fn record_scene_3_skill_and_tools(app: &mut App, recorder: &mut FrameRecorder) {
});
recorder.capture(app, 1600);

// Hold on the passing test output.
app.apply_agent_event(AgentEvent::ToolResult {
call_id: "call_4".to_owned(),
name: "bash".to_owned(),
Expand All @@ -238,6 +249,7 @@ fn record_scene_3_skill_and_tools(app: &mut App, recorder: &mut FrameRecorder) {
}

fn record_scene_4_summary_and_command(app: &mut App, recorder: &mut FrameRecorder) {
// Scene 4: Stream Markdown summary and update context usage (26% -> 32%).
app.apply_agent_event(AgentEvent::TextDelta(
"## Timeout Handling Fix\n\n".to_owned(),
));
Expand Down Expand Up @@ -281,6 +293,7 @@ fn record_scene_4_summary_and_command(app: &mut App, recorder: &mut FrameRecorde
});
recorder.capture(app, 2800);

// Type `/s` and open slash-command completion.
app.set_input("/".to_owned());
recorder.capture(app, 80);

Expand All @@ -295,10 +308,12 @@ fn record_scene_4_summary_and_command(app: &mut App, recorder: &mut FrameRecorde
}));
recorder.capture(app, 1400);

// Accept `/stats` from the completion popup.
app.set_active_trigger(None);
app.set_input("/stats".to_owned());
recorder.capture(app, 500);

// Execute `/stats` to render the session usage table.
app.set_input(String::new());
app.push_markdown_message(indoc! {"
## Usage Statistics (All time)
Expand Down
4 changes: 2 additions & 2 deletions crates/ox-tui/tests/common/preview_scenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ fn preview_resume_summaries(now: i64) -> Vec<SessionSummary> {
SessionSummary {
id: "s-thinking-collapse".to_owned(),
title: "Collapse multi-line thinking blocks".to_owned(),
model: "claude-sonnet-4-5".to_owned(),
model: "claude-sonnet-5-5".to_owned(),
working_dir: "oxide-code".to_owned(),
parent_session_id: Some("s-overlay-polish".to_owned()),
created_at: now - 2 * 86_400_000,
Expand All @@ -380,7 +380,7 @@ fn preview_resume_summaries(now: i64) -> Vec<SessionSummary> {
SessionSummary {
id: "s-devkit-flake".to_owned(),
title: "Update Nix flake inputs".to_owned(),
model: "claude-sonnet-4-5".to_owned(),
model: "claude-sonnet-5-5".to_owned(),
working_dir: "/repo/devkit".to_owned(),
parent_session_id: None,
created_at: now - 6 * 86_400_000,
Expand Down
8 changes: 4 additions & 4 deletions crates/ox-tui/tests/tui_previews.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ fn assert_checksum(path: &Path, actual: &str) {
let expected = fs::read_to_string(path).unwrap_or_else(|err| {
panic!(
"missing preview checksum at {path_display} ({err}). Run \
`./scripts/render-previews.sh` to regenerate WebP previews and checksums together"
`./scripts/render-previews.nu` to regenerate WebP previews and checksums together"
)
});
assert_eq!(
actual, expected,
"preview intermediate-SVG checksum out of date at {path_display}. Run \
`./scripts/render-previews.sh` to regenerate WebP previews and checksums together"
`./scripts/render-previews.nu` to regenerate WebP previews and checksums together"
);
}

Expand All @@ -51,7 +51,7 @@ fn static_webp_previews_are_up_to_date() {
let webp_path = assets_dir.join(&rel_webp);
assert!(
webp_path.is_file(),
"missing rendered WebP preview at {}. Run `./scripts/render-previews.sh`",
"missing rendered WebP preview at {}. Run `./scripts/render-previews.nu`",
webp_path.display()
);
}
Expand All @@ -67,7 +67,7 @@ fn demo_webp_frames_are_up_to_date() {
let webp_path = demo_dir.join("ox-demo.webp");
assert!(
webp_path.is_file(),
"missing rendered animated demo at {}. Run `./scripts/render-previews.sh`",
"missing rendered animated demo at {}. Run `./scripts/render-previews.nu`",
webp_path.display()
);
}
2 changes: 1 addition & 1 deletion docs/assets/previews.sha256
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ f2fe32942585fbddc393172b3e066b76208cb2e3798291a3c4119ea720689e64 themes/materia
1ce34332fb107407828b4ccb80f404258ca6709c00ef2b02b73c8071fdce3394 tui/command-palette.svg
0a46ed1f8917a2dbd3060310ec7cfc2403b98bb17da9a71255d5537e4796f26d tui/composer-chrome.svg
92b082338e8596857009f72814ec916d5e1c833fc64298d94cb12b2baafaade5 tui/permission-confirm.svg
f5f40f133d13e1c0035dc731566ed0ef6cb2a1a1356dccaf756a97089321713b tui/resume-picker.svg
1bc193017e7454335f379b0def862679d8c50088d82e0d8b0898752e5b9c6829 tui/resume-picker.svg
0bac452b9fec47d13576548636f345493171a383e964b8a086b6a4948c73297e tui/rewind-picker.svg
9a884eab620cba4f08e3a2b31ad004fa6abe7f56cb8eaac434052490f75045f3 tui/statusline-styles.svg
a91bab18d8ee55fa2ec2c7bbf8f3e53d682e0f873908d807abb828ac79c29c1a tui/trigger-completion.svg
Binary file modified docs/assets/tui/resume-picker.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
taplo.enable = true;

# Shell
nu-check.enable = true;
shellcheck.enable = true;
shfmt.enable = true;
};
Expand Down Expand Up @@ -200,6 +201,7 @@

packages = [
rustToolchain
dk.nushell
]
++ builtins.attrValues dk.nodeToolchain
++ (with pkgs; [
Expand Down
185 changes: 185 additions & 0 deletions scripts/render-previews.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#!/usr/bin/env nu

# Regenerate deterministic Maple Mono NF lossless WebP previews, animated hero demo, and SHA-256
# manifests for `ox-tui`.

const SCRIPT_DIR = path self "."

def resolve-render-path []: nothing -> list<string> {
let required = ["resvg" "cwebp" "img2webp"]
let missing = ($required | where { (which $in | is-empty) })

if ($missing | is-empty) {
$env.PATH
} else {
let tool_bins = (
^nix build "nixpkgs#resvg" "nixpkgs#libwebp"
--no-link
--print-out-paths
| lines
| each { $in | path join "bin" }
)
$tool_bins | append $env.PATH
}
}

def render-static-one [
svg: path
static_svg_dir: path
static_png_dir: path
font_dir: path
]: nothing -> nothing {
let rel = ($svg | path relative-to $static_svg_dir)
let stem = ($rel | str replace --regex '\.svg$' "")
let png = ($static_png_dir | path join $"($stem).png")
let webp = ("docs/assets" | path join $"($stem).webp")

(
^resvg $svg $png
--skip-system-fonts
--use-fonts-dir $font_dir
--monospace-family "Maple Mono NF"
--zoom 2
)

(
^cwebp $png
-lossless
-z 9
-quiet
-o $webp
)
}

def render-demo-one [
svg: path
demo_png_dir: path
font_dir: path
]: nothing -> nothing {
let base = ($svg | path parse | get stem)
let png = ($demo_png_dir | path join $"($base).png")

(
^resvg $svg $png
--skip-system-fonts
--use-fonts-dir $font_dir
--monospace-family "Maple Mono NF"
--zoom 4
)
}

def render-with-tools [
paths: record<
static_svg_dir: path
static_png_dir: path
demo_svg_dir: path
demo_png_dir: path
font_dir: path
>
]: nothing -> nothing {
let static_svg_files = (
glob ($paths.static_svg_dir | path join "**/*.svg")
| sort
)
let _ = (
$static_svg_files
| par-each {|svg|
render-static-one $svg $paths.static_svg_dir $paths.static_png_dir $paths.font_dir
}
)

let demo_svg_files = (
glob ($paths.demo_svg_dir | path join "frame_*.svg")
| sort
)
let _ = (
$demo_svg_files
| par-each {|svg|
render-demo-one $svg $paths.demo_png_dir $paths.font_dir
}
)

let frame_args = (
open --raw ($paths.demo_svg_dir | path join "manifest.txt")
| lines
| where { ($in | str trim | is-not-empty) }
| each {|line|
let parts = ($line | split row --regex '\s+')
let base = ($parts.0 | path parse | get stem)
let duration_ms = $parts.1
["-d" $duration_ms "-lossless" ($paths.demo_png_dir | path join $"($base).png")]
}
| flatten
)

(
^img2webp
-loop 0
...$frame_args
-o "docs/assets/demo/ox-demo.webp"
)
}

# Regenerate static WebP previews, animated hero demo, and SHA-256 parity manifests.
def main []: nothing -> nothing {
let repo_root = ($SCRIPT_DIR | path dirname)
cd $repo_root

let tmp_root = (mktemp --directory --tmpdir "ox-previews.XXXXXX")

try {
let static_svg_dir = ($tmp_root | path join "previews/svg")
let static_png_dir = ($tmp_root | path join "previews/png")
let demo_svg_dir = ($tmp_root | path join "demo/frames")
let demo_png_dir = ($tmp_root | path join "demo/png")

with-env {OX_PREVIEW_TMP_DIR: $tmp_root} {
(
^cargo run
-p ox-tui
--example render_previews
)
}

let maple_out = (
^nix build "nixpkgs#maple-mono.NF"
--no-link
--print-out-paths
| str trim
)
let font_dir = ($maple_out | path join "share/fonts/truetype")

for dir in [
($static_png_dir | path join "themes")
($static_png_dir | path join "tui")
$demo_png_dir
"docs/assets/themes"
"docs/assets/tui"
"docs/assets/demo"
] {
mkdir $dir
}

let render_path = (resolve-render-path)
with-env {PATH: $render_path} {
render-with-tools {
static_svg_dir: $static_svg_dir
static_png_dir: $static_png_dir
demo_svg_dir: $demo_svg_dir
demo_png_dir: $demo_png_dir
font_dir: $font_dir
}
}

^cp ($tmp_root | path join "previews.sha256") "docs/assets/previews.sha256"
^cp ($tmp_root | path join "ox-demo.sha256") "docs/assets/demo/ox-demo.sha256"
} finally {
rm -rf $tmp_root
}

(
^cargo test
-p ox-tui
--test tui_previews
)
}
Loading
Loading