From fbdda2193fbff4adbd87236b68078e912f387b80 Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 01:05:34 -0600 Subject: [PATCH 1/2] test(id): share screen-cell parity corpus --- .../crates/id-core/src/world_presentation.rs | 52 +++++++++++++++ .../src/test-fixtures/screen-cell-parity.json | 64 +++++++++++++++++++ pkgs/id/web/src/world-surface.test.ts | 17 +++++ 3 files changed, 133 insertions(+) create mode 100644 pkgs/id/web/src/test-fixtures/screen-cell-parity.json diff --git a/pkgs/id/crates/id-core/src/world_presentation.rs b/pkgs/id/crates/id-core/src/world_presentation.rs index 26021ebc01..72f4da3da2 100644 --- a/pkgs/id/crates/id-core/src/world_presentation.rs +++ b/pkgs/id/crates/id-core/src/world_presentation.rs @@ -781,8 +781,23 @@ fn style_sequence(fg: u8, bg: u8, bold: bool) -> String { #[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] mod tests { use super::*; + use serde::Deserialize; use serde_json::json; + #[derive(Deserialize)] + struct ScreenCellParityCorpus { + cases: Vec, + } + + #[derive(Deserialize)] + struct ScreenCellParityCase { + name: String, + width: u16, + height: u16, + expected_valid: bool, + cells: Vec, + } + fn screen(value: Value) -> Result> { parse_surface(&value.to_string()) } @@ -808,6 +823,43 @@ mod tests { ScreenSurface::from_cells(width, height, vec![cell(fill); width * height]).unwrap() } + #[test] + fn rust_screen_presenter_matches_the_shared_web_parity_corpus() { + let corpus: ScreenCellParityCorpus = serde_json::from_str(include_str!( + "../../../web/src/test-fixtures/screen-cell-parity.json" + )) + .unwrap(); + + let case_names: Vec<_> = corpus.cases.iter().map(|case| case.name.as_str()).collect(); + for required_case in [ + "CJK wide character", + "astral-plane emoji", + "ZWJ emoji sequence", + "warning sign with emoji variation selector", + "non-empty continuation cell", + "wide character declared with the wrong width", + ] { + assert!( + case_names.contains(&required_case), + "missing {required_case:?}" + ); + } + for case in corpus.cases { + let surface = ScreenSurface { + version: 1, + width: case.width, + height: case.height, + cells: case.cells, + }; + assert_eq!( + surface.render_ansi().is_some(), + case.expected_valid, + "Rust screen presenter verdict for {:?}", + case.name + ); + } + } + #[test] fn patch_parity_patched_client_equals_full_frame_client() { let prev = grid(4, 2, " "); diff --git a/pkgs/id/web/src/test-fixtures/screen-cell-parity.json b/pkgs/id/web/src/test-fixtures/screen-cell-parity.json new file mode 100644 index 0000000000..be70b7a45d --- /dev/null +++ b/pkgs/id/web/src/test-fixtures/screen-cell-parity.json @@ -0,0 +1,64 @@ +{ + "cases": [ + { + "name": "CJK wide character", + "width": 2, + "height": 1, + "expected_valid": true, + "cells": [ + { "symbol": "界", "fg": 0, "bg": 0, "bold": false, "columns": 2 }, + { "symbol": "", "fg": 0, "bg": 0, "bold": false, "columns": 0 } + ] + }, + { + "name": "astral-plane emoji", + "width": 2, + "height": 1, + "expected_valid": true, + "cells": [ + { "symbol": "😀", "fg": 0, "bg": 0, "bold": false, "columns": 2 }, + { "symbol": "", "fg": 0, "bg": 0, "bold": false, "columns": 0 } + ] + }, + { + "name": "ZWJ emoji sequence", + "width": 2, + "height": 1, + "expected_valid": true, + "cells": [ + { "symbol": "👩‍💻", "fg": 0, "bg": 0, "bold": false, "columns": 2 }, + { "symbol": "", "fg": 0, "bg": 0, "bold": false, "columns": 0 } + ] + }, + { + "name": "warning sign with emoji variation selector", + "width": 2, + "height": 1, + "expected_valid": true, + "cells": [ + { "symbol": "⚠️", "fg": 0, "bg": 0, "bold": false, "columns": 2 }, + { "symbol": "", "fg": 0, "bg": 0, "bold": false, "columns": 0 } + ] + }, + { + "name": "non-empty continuation cell", + "width": 2, + "height": 1, + "expected_valid": false, + "cells": [ + { "symbol": "界", "fg": 0, "bg": 0, "bold": false, "columns": 2 }, + { "symbol": "x", "fg": 0, "bg": 0, "bold": false, "columns": 0 } + ] + }, + { + "name": "wide character declared with the wrong width", + "width": 2, + "height": 1, + "expected_valid": false, + "cells": [ + { "symbol": "界", "fg": 0, "bg": 0, "bold": false, "columns": 1 }, + { "symbol": "x", "fg": 0, "bg": 0, "bold": false, "columns": 1 } + ] + } + ] +} diff --git a/pkgs/id/web/src/world-surface.test.ts b/pkgs/id/web/src/world-surface.test.ts index a2b0a44991..3cace264e9 100644 --- a/pkgs/id/web/src/world-surface.test.ts +++ b/pkgs/id/web/src/world-surface.test.ts @@ -1,11 +1,28 @@ import { describe, expect, it } from "vitest"; import { applyScreenPatch, renderWorldSurface, type ScreenSurface } from "./world-surface"; +import screenCellParityCorpus from "./test-fixtures/screen-cell-parity.json"; function makeScreen(cells: ScreenSurface["cells"]): ScreenSurface { return { kind: "screen", version: 1, width: cells.length, height: 1, cells }; } describe("world screen presenter", () => { + it("matches the recorded Rust verdicts for the shared screen-cell corpus", () => { + for (const testCase of screenCellParityCorpus.cases) { + const surface: ScreenSurface = { + kind: "screen", + version: 1, + width: testCase.width, + height: testCase.height, + cells: testCase.cells, + }; + expect( + renderWorldSurface(document.createElement("div"), surface), + `web screen presenter verdict for ${testCase.name}`, + ).toBe(testCase.expected_valid); + } + }); + it("applies revision-independent cell runs to the same validated surface as a full frame", () => { const previous: ScreenSurface = { kind: "screen", From 38cda9bb18fd9410d0b6525e06d048be1f2a6a3a Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Sun, 8 Nov 2026 23:19:13 -0600 Subject: [PATCH 2/2] test(id): prefix screen-cell parity test with test_ Codex review on #6110: pkgs/id/AGENTS.md requires the test_ prefix on test functions. Renames the new Rust test only; no behaviour change. --- pkgs/id/crates/id-core/src/world_presentation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/id/crates/id-core/src/world_presentation.rs b/pkgs/id/crates/id-core/src/world_presentation.rs index 72f4da3da2..f2d58ef916 100644 --- a/pkgs/id/crates/id-core/src/world_presentation.rs +++ b/pkgs/id/crates/id-core/src/world_presentation.rs @@ -824,7 +824,7 @@ mod tests { } #[test] - fn rust_screen_presenter_matches_the_shared_web_parity_corpus() { + fn test_rust_screen_presenter_matches_the_shared_web_parity_corpus() { let corpus: ScreenCellParityCorpus = serde_json::from_str(include_str!( "../../../web/src/test-fixtures/screen-cell-parity.json" ))