You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by wy...@apache.org on 2026/10/20 10:44:11 UTC
(maka) 06/10: test(terminal): export native cells with optional UI evidence
This is an automated email from the ASF dual-hosted git repository.
M4n5ter pushed a commit to branch feat/nsh-tui-shell
in repository https://gitbox.apache.org/repos/asf/maka.git
commit 0aebe32dfab2e86636516e1e3232d4fbbf0296b2
Author: M4n5ter <m4...@gmail.com>
AuthorDate: Tue Oct 20 17:01:25 2026 +0800
test(terminal): export native cells with optional UI evidence
Capture real AppView render cells at existing workbench checkpoints only when evidence is requested. Select the narrow viewport before mounting the app so recorded layouts cannot come from a stale resize frame.
Generated-by: OpenAI Codex
---
products/maka/terminal-shell/tests/real_host.rs | 3 ++
products/maka/terminal-shell/tests/support/mod.rs | 38 ++++++++++++++++++++++-
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/products/maka/terminal-shell/tests/real_host.rs b/products/maka/terminal-shell/tests/real_host.rs
index e99e62745d..72245d7b0e 100644
--- a/products/maka/terminal-shell/tests/real_host.rs
+++ b/products/maka/terminal-shell/tests/real_host.rs
@@ -68,6 +68,7 @@ async fn the_home_palette_creates_switches_models_and_stops_a_real_session_witho
let (mut view, bindings) = fixture.view(client.clone(), None);
let home = wait_view(&mut view, |screen| screen.contains("Make something remarkable.")).await;
evidence("workbench-home", &home);
+ support::evidence_cells("workbench-home", &view);
shortcut(&mut view, 'p');
select_palette(&mut view, "Search commands…", "Sess", "Sessions").await;
@@ -100,6 +101,7 @@ async fn the_home_palette_creates_switches_models_and_stops_a_real_session_witho
let restored = wait_view(&mut view, |screen| screen.contains("NSH real Agent") && screen.contains("Draft A stays in its own conversation") && screen.contains("Enter sends")).await;
assert!(!restored.contains("Message B uses the selected model"));
evidence("workbench-draft-after-switch", &restored);
+ support::evidence_cells("workbench-draft-after-switch", &view);
shortcut(&mut view, 'o');
select_palette(&mut view, "Search sessions…", &created_id, "New conversation").await;
wait_view(&mut view, |screen| screen.contains("New conversation") && screen.contains("Message B uses the selected model") && screen.contains("Enter sends")).await;
@@ -110,6 +112,7 @@ async fn the_home_palette_creates_switches_models_and_stops_a_real_session_witho
assert!(!request.body.to_string().contains("Draft A stays in its own conversation"));
request.delta("REAL_WORKBENCH_RUN_TO_STOP").await;
wait_view(&mut view, |screen| screen.contains("REAL_WORKBENCH_RUN_TO_STOP")).await;
+ support::evidence_cells("workbench-streaming", &view);
let observed = client.query("agent", "observe", json!({"sessionId":created_id})).await.unwrap();
let invocation = observed["run"]["invocationId"].as_str().filter(|id| !id.is_empty()).unwrap();
shortcut(&mut view, 'p');
diff --git a/products/maka/terminal-shell/tests/support/mod.rs b/products/maka/terminal-shell/tests/support/mod.rs
index 5eb4b6f1e3..0c69e3ae6f 100644
--- a/products/maka/terminal-shell/tests/support/mod.rs
+++ b/products/maka/terminal-shell/tests/support/mod.rs
@@ -355,7 +355,7 @@ impl Fixture {
let bindings =
maka_terminal_shell::bindings::Bindings::new(client, tokio::runtime::Handle::current());
let mut view = AppView::new(AppOptions {
- size: (120, 36),
+ size: evidence_size(),
data_dir: Some(self.directory.path().join("nsh")),
ui_sets: Some(vec![
nsh_ui_mobile::registry(),
@@ -543,6 +543,42 @@ pub async fn wait_draft(client: &Client, session: &str, text: &str) {
.expect("the editor did not persist its exact draft");
}
+fn evidence_size() -> (u16, u16) {
+ if std::env::var_os("MAKA_NSH_EVIDENCE").is_none() {
+ return (120, 36);
+ }
+ match std::env::var("MAKA_NSH_EVIDENCE_SIZE").as_deref() {
+ Ok("80x24") => (80, 24),
+ Ok("120x36") | Err(_) => (120, 36),
+ Ok(size) => panic!("unsupported evidence size: {size}"),
+ }
+}
+
+pub fn evidence_cells(name: &str, view: &AppView) {
+ use ratatui::{buffer::CellWidth, layout::Rect, style::Color};
+ let Some(directory) = std::env::var_os("MAKA_NSH_EVIDENCE") else {
+ return;
+ };
+ let (columns, rows) = evidence_size();
+ let area = Rect::new(0, 0, columns, rows);
+ let mut buffer = ratatui::buffer::Buffer::empty(area);
+ view.render(area, &mut buffer);
+ let color = |value| match value {
+ Color::Rgb(r, g, b) => json!({"rgb":[r,g,b]}),
+ Color::Indexed(index) => json!({"indexed":index}),
+ value => json!({"named":format!("{value:?}")}),
+ };
+ let cells: Vec<Vec<_>> = (0..rows).map(|y| (0..columns).map(|x| {
+ let cell = &buffer[(x, y)];
+ json!({"symbol":cell.symbol(),"width":cell.cell_width(),"fg":color(cell.fg),"bg":color(cell.bg),"modifier":cell.modifier.bits()})
+ }).collect()).collect();
+ let directory = PathBuf::from(directory);
+ std::fs::create_dir_all(&directory).unwrap();
+ std::fs::write(directory.join(format!("{name}-{columns}x{rows}.cells.json")), serde_json::to_vec(&json!({
+ "source":"NSH AppView::render / Ratatui Buffer","columns":columns,"rows":rows,"cellWidth":8,"cellHeight":16,"cells":cells
+ })).unwrap()).unwrap();
+}
+
pub fn evidence(name: &str, snapshot: &str) {
if let Some(directory) = std::env::var_os("MAKA_NSH_EVIDENCE") {
let directory = PathBuf::from(directory);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org