From 011ee7857a09c596501f1a4db09d8dc33081c2d0 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 25 Nov 2026 12:00:05 +0000 Subject: [PATCH 1/4] next: design-lint findings and the components index - ui-panels iconic trial: the two literal 0.5 tolerances are relations (`first` above the gripped first icon; the rule `near` the middle of the room). - ui-shell Column start page: the bottom page margin is `add_space` of the token, not `allocate_space`. - ui-widgets Tile: `PAPER` (a blank page, data) and `Tile::page`'s width and height (a proportion in any one unit) are marked and listed as exceptions. - docs/components-index.md regenerated (Link's `LinkLook::Plain`). Co-Authored-By: Claude Opus 5.5 --- crates/ui-panels/src/docking/iconic/trials.rs | 4 ++-- crates/ui-shell/src/shell/start.rs | 2 +- crates/ui-widgets/src/tile_grid/tile.rs | 3 ++- .../exceptions/craft-ui-widgets/tile_grid.toml | 16 ++++++++++++++++ docs/components-index.md | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/crates/ui-panels/src/docking/iconic/trials.rs b/crates/ui-panels/src/docking/iconic/trials.rs index aaa36e197..3e1ce73cd 100644 --- a/crates/ui-panels/src/docking/iconic/trials.rs +++ b/crates/ui-panels/src/docking/iconic/trials.rs @@ -717,7 +717,7 @@ fn icon_groups_apart_by_a_rule_show_one_level_rule_between_them() { let band = |group: u64| fixture.part_rect(id, GRIP.at(group)).expect("each group keeps a grip band"); let (first, last, next) = (cell(0), cell(1), cell(2)); let (top, lower) = (band(0), band(1)); - assert!(first.top() < gripped_first.top() - 0.5, "the first icon {first:?} stands higher than under a grip strip {gripped_first:?}"); + assert!(first.top() < gripped_first.top(), "the first icon {first:?} stands higher than under a grip strip {gripped_first:?}"); for (group, band) in [top, lower].into_iter().enumerate() { assert!(grip_ticks(&shapes, band).is_none(), "group {group}: the band shows no marks"); } @@ -733,7 +733,7 @@ fn icon_groups_apart_by_a_rule_show_one_level_rule_between_them() { let between: Vec<_> = level.iter().filter(|(a, _, _)| a.y > last.bottom() && a.y < next.top()).collect(); let [(a, b, ink)] = between.as_slice() else { panic!("one rule between the groups: {level:?}") }; let middle = (last.bottom() + next.top()) / 2.0; - assert!((a.y - middle).abs() <= 0.5, "the rule {a:?} lies in the middle of the room from {last:?} to {next:?}"); + assert!(near(a.y, middle), "the rule {a:?} lies in the middle of the room from {last:?} to {next:?}"); let (left, right) = (a.x.min(b.x), a.x.max(b.x)); let span = right - left; assert!(left > 0.0 && right < RAIL && span > RAIL - span, "the rule reaches across the column, short of its sides: {a:?} to {b:?}"); diff --git a/crates/ui-shell/src/shell/start.rs b/crates/ui-shell/src/shell/start.rs index 4f9e776ba..4f0e53ff2 100644 --- a/crates/ui-shell/src/shell/start.rs +++ b/crates/ui-shell/src/shell/start.rs @@ -878,7 +878,7 @@ impl StartScreen<'_> { column_links(&page, ui, links_title.as_ref(), links); }); }); - ui.allocate_space(vec2(0.0, margin)); + ui.add_space(env.tokens.size.page.margin); }); return StartOutput { response: shown.output, actions: actions.into_inner() }; } diff --git a/crates/ui-widgets/src/tile_grid/tile.rs b/crates/ui-widgets/src/tile_grid/tile.rs index 202fd4b8a..1cadb97c0 100644 --- a/crates/ui-widgets/src/tile_grid/tile.rs +++ b/crates/ui-widgets/src/tile_grid/tile.rs @@ -305,7 +305,7 @@ pub struct TileStyle { } /// The paper of a page picture (`Tile::page`): a document's blank page, which is data, not a theme surface. -const PAPER: DataColor = DataColor::new(Color32::WHITE); +const PAPER: DataColor = DataColor::new(Color32::WHITE); // design: allow[raw-colour/const](a document's blank page is data, not a theme surface) /// A `width` by `height` page centred in `picture` on the knob's shadow, the theme's short hard shadow of a part lifted /// just off the surface under it. The page's longer side spans the largest square the picture holds with the shadow, @@ -554,6 +554,7 @@ impl<'a> Tile<'a> { /// that stands for a document size shows it this way (New Document's presets in `PresetCardLook::Page`, a start /// page's page templates). #[must_use] + // design: allow[props/point-size](only the page's shape counts: `width` and `height` are a proportion in any one unit) pub fn page(self, width: f64, height: f64) -> Self { self.flat_thumbnail().thumb(ThumbAspect::new(2, 1), move |cx: &ContentPainterCx<'_>, picture: Rect| paint_page(cx, picture, width, height)) } diff --git a/design/exceptions/craft-ui-widgets/tile_grid.toml b/design/exceptions/craft-ui-widgets/tile_grid.toml index 88f56e78b..6d44c5ef4 100644 --- a/design/exceptions/craft-ui-widgets/tile_grid.toml +++ b/design/exceptions/craft-ui-widgets/tile_grid.toml @@ -1 +1,17 @@ config_version = 1 + +[[exception]] +name = "tile-page-paper-white" +kind = "marker" +rule = "raw-colour/const" +path = "crates/ui-widgets/src/tile_grid/tile.rs" +reason = "A page picture's paper is a document's blank page, which is data (`DataColor`), not a theme surface." +count = 1 + +[[exception]] +name = "tile-page-proportion" +kind = "marker" +rule = "props/point-size" +path = "crates/ui-widgets/src/tile_grid/tile.rs" +reason = "`Tile::page` takes a page's width and height in any one unit: only their proportion counts, never a size in points." +count = 1 diff --git a/docs/components-index.md b/docs/components-index.md index a0bbf32a2..a5fef53b3 100644 --- a/docs/components-index.md +++ b/docs/components-index.md @@ -64,7 +64,7 @@ Grouped by gallery level, then shape, then name. | `Disclosure` | Leaf | `craft_ui_widgets::controls::disclosure` | A button bound to an open state, with the expanded state | | `IconButton` | Leaf | `craft_ui_widgets::buttons::icon_button` | A square button showing only an icon | | `Kbd` | Leaf | `craft_ui_widgets::display::kbd` | A key chord | -| `Link` | Leaf | `craft_ui_widgets::buttons::link` | A link: drawn in the accent colour in a type role (body by default) and underlined, so colour is not its only cue | +| `Link` | Leaf | `craft_ui_widgets::buttons::link` | A link: drawn in the accent colour in a type role (body by default) and underlined, so colour is not its only cue (`LinkLook::Plain` drops the underline of a link standing alone) | | `LinkedFields` | Leaf | `craft_ui_widgets::text::linked` | `N` number fields joined by a link toggle | | `NumberField` | Leaf | `craft_ui_widgets::text::number` | A number field: a text part over [`NumberCodec`]; empty text is `None` | | `PointPicker` | Leaf | `craft_ui_widgets::value_drag::point_picker` | A point `[x, y]` picked on a well: x grows to the right and y downwards, as image coordinates do, in either reading direction | From d4af1f2485e1f7c5c2214bf981abed409c7cd400 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 02:35:46 +0000 Subject: [PATCH 2/4] cl: pass the dev profile settings after the cargo subcommand cargo lets a --config given after the subcommand replace every --config given before it, so `cl test --config .config/cargo-ci.toml` built every crate, dependencies included, at opt-level 0. External subcommands (fmt) keep them before the subcommand. --- tools/cl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/cl b/tools/cl index fc3b8fc3e..9bcc5292a 100755 --- a/tools/cl +++ b/tools/cl @@ -94,6 +94,8 @@ APP_KEYS = { "test_threads": (int, None), } APP_BUILDING = {"test", "check", "build", "run", "bench", "clippy", "doc", "rustc"} +# cargo's own subcommands that resolve a profile; `cargo()` passes the dev settings after them. +CARGO_BUILDING = {"test", "check", "build", "run", "bench", "doc", "rustc", "metadata", "tree"} APP_FEATURE_FLAGS = ("--features", "-F", "--no-default-features") # Set by main() from the workspace's `[workspace.metadata.cl]` in an app workspace; None in craft-libs. APP = None @@ -379,9 +381,13 @@ def cargo(top, cargo_args, json_out=False, timings=True): RECORD["target"] = target if timings: cargo_args = cargo_args[:1] + ["--timings"] + cargo_args[1:] - # An app workspace keeps its own profile settings. + # An app workspace keeps its own profile settings. For cargo's own build commands they go after the subcommand: + # cargo lets a `--config` given there replace every `--config` given before it, so a caller's own `--config` + # (.config/cargo-ci.toml) would otherwise drop the dev settings and build every crate, dependencies included, at + # opt-level 0. An external subcommand (fmt) would read them as its own options, so they stay before it. config = [] if APP else [x for c in dev_profile_config() for x in ("--config", c)] - cmd = shlex.split(env.get("CL_LAUNCHER", "")) + ["cargo"] + config + cargo_args + split = 1 if cargo_args[:1] and cargo_args[0] in CARGO_BUILDING else 0 + cmd = shlex.split(env.get("CL_LAUNCHER", "")) + ["cargo"] + cargo_args[:split] + config + cargo_args[split:] print("cl: " + " ".join(cmd) + f" (target {target})", file=sys.stderr) sys.stdout.flush() if DRY_RUN: From 7d1a54d71b34e1299de610cd9a7a07a932f88c2d Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 02:35:46 +0000 Subject: [PATCH 3/4] Workspace gate: craft-ui-contract at opt-level 2 Every screen-test frame runs the runtime. Table activation runs 40 percent fewer instructions (19.8 G to 11.9 G on the CI profile); the build chain pays about a minute for ui-contract's compile. Changes the CI cache key. --- .config/cargo-ci.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.config/cargo-ci.toml b/.config/cargo-ci.toml index 956491323..93a48332f 100644 --- a/.config/cargo-ci.toml +++ b/.config/cargo-ci.toml @@ -29,3 +29,9 @@ opt-level = 1 [profile.dev.package.craft-cms] opt-level = 1 + +# The runtime under every screen test: each frame of a fixture runs its pass, layout, focus and access tree. At +# opt-level 2 a suite trial runs about 40 percent fewer instructions than at 0 (Table activation 19.8 G to 11.9 G); +# opt-level 1 gives about 30 percent. Every UI crate waits for its compile, which grows by about a minute. +[profile.dev.package.craft-ui-contract] +opt-level = 2 From 6387c9ec92c6ae6830345d97d3460b399186bd47 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 02:35:47 +0000 Subject: [PATCH 4/4] Workspace gate: shard 2 also runs craft-draw's tests With craft-ui-contract optimised, shard 2 (the audit crates, plain and audited) ends well before shard 1. craft-draw's tests (about 280 test-s in CI, most of them suite trials) move to shard 2 and run plainly; the audited pass keeps to the audit crates. --- .github/workflows/workspace.yml | 4 ++-- scripts/ci-workspace-tests.sh | 25 +++++++++++++++---------- scripts/test-workspace-tests.py | 10 ++++++---- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index 63170f121..33106085a 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -167,8 +167,8 @@ jobs: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings # A selection that reaches a replay-audit crate builds once in a `build` job, which writes # three nextest archives and then runs the doctests; three shard legs run them in parallel: - # every selected test outside the replay audit's crates, those crates (run plainly, then with the - # audit), and craft-image-codecs with default features. Any other selection + # every selected test outside the replay audit's crates and craft-draw, those crates (run plainly, + # then the audit crates with the audit), and craft-image-codecs with default features. Any other selection # (and every macOS and Windows leg) builds and runs in one leg. scripts/ci-workspace-tests.sh # holds every step. test-shards: ${{ needs.platforms.outputs.audit == 'true' && 3 || 0 }} diff --git a/scripts/ci-workspace-tests.sh b/scripts/ci-workspace-tests.sh index 8585667d0..ee67e0c24 100755 --- a/scripts/ci-workspace-tests.sh +++ b/scripts/ci-workspace-tests.sh @@ -4,10 +4,10 @@ # run one leg builds and runs every test: each macOS and Windows leg, and the Linux leg when # the selection reaches no replay-audit crate # archive the Linux build job (gate.yml `archive-command`) builds once and writes one nextest -# archive per shard: 1 every selected test outside the replay audit's crates, 2 those -# crates, 3 the default-feature crate -# shard a Linux shard leg runs its archive ($GATE_SHARD); shard 2 runs it plainly, then with -# the audit on +# archive per shard: 1 every selected test outside the replay audit's crates and the +# crates shard 2 also takes, 2 those crates, 3 the default-feature crate +# shard a Linux shard leg runs its archive ($GATE_SHARD); shard 2 runs it plainly, then the +# audit crates' tests again with the audit on # doctest the doctests, in the build job after the archives (`after-archive-command`) # audit prints whether the selection reaches a replay-audit crate (`true` or `false`) # full the nightly run: every test, at the full sweep and proptest counts nightly.yml leaves set @@ -34,10 +34,15 @@ default_features=(-p craft-image-codecs --locked --profile ci "${config[@]}") audit_packages=(craft-ui-contract craft-ui-widgets craft-ui-panels craft-ui-patterns craft-ui-shell craft-ui-gallery craft-menu) audit_crates=$(printf ' | package(%s)' "${audit_packages[@]}") audit_crates=${audit_crates:3} +# Crates outside the audit whose tests shard 2 runs too (plainly only), so that shards 1 and 2 end +# together: shard 1 holds the other UI crates and every non-UI test. +shard_2_packages=(craft-draw) +shard_2_crates=$audit_crates$(printf ' | package(%s)' "${shard_2_packages[@]}") filter=${CRAFT_TEST_FILTER:-all()} -# Shard 1 leaves the audit crates to shard 2, which runs them plainly and with the audit on. -plain_filter="($filter) & !($audit_crates)" -audit_filter="($filter) & ($audit_crates)" +# Shard 1 leaves the audit crates and shard 2's own to shard 2, which runs them plainly and then +# the audit crates with the audit on. +plain_filter="($filter) & !($shard_2_crates)" +shard_2_filter="($filter) & ($shard_2_crates)" doctests() { # Whole-workspace: `cargo test -p ` would resolve features over the selected crates @@ -65,9 +70,9 @@ case "${1:-}" in # The examples' two packages join the one build here, so their tests are in shard 1's archive. cargo nextest archive "${all_features[@]}" "${targets[@]}" --example stubicc --example h264_h264enc_bench \ -E "$plain_filter" --archive-file "$NEXTEST_ARCHIVE_DIR/1/$NEXTEST_ARCHIVE_NAME" - # The same build, so nothing compiles again; only the audit crates' binaries. + # The same build, so nothing compiles again; only shard 2's crates' binaries. cargo nextest archive "${all_features[@]}" "${targets[@]}" --example stubicc --example h264_h264enc_bench \ - -E "$audit_filter" --archive-file "$NEXTEST_ARCHIVE_DIR/2/$NEXTEST_ARCHIVE_NAME" + -E "$shard_2_filter" --archive-file "$NEXTEST_ARCHIVE_DIR/2/$NEXTEST_ARCHIVE_NAME" cargo nextest archive "${default_features[@]}" "${targets[@]}" \ -E "$filter" --archive-file "$NEXTEST_ARCHIVE_DIR/3/$NEXTEST_ARCHIVE_NAME" ;; @@ -75,7 +80,7 @@ case "${1:-}" in run=(cargo nextest run --archive-file "$NEXTEST_ARCHIVE_FILE" --workspace-remap . --profile ci --no-tests=warn) case "${GATE_SHARD:-}" in 1 | 3) "${run[@]}" ;; - 2) "${run[@]}"; CRAFT_UI_AUDIT_REPLAY=1 "${run[@]}" ;; + 2) "${run[@]}"; CRAFT_UI_AUDIT_REPLAY=1 "${run[@]}" -E "$audit_crates" ;; *) echo "unknown shard: '${GATE_SHARD:-}'" >&2; exit 2 ;; esac ;; diff --git a/scripts/test-workspace-tests.py b/scripts/test-workspace-tests.py index 3356d414f..5cceeddc1 100644 --- a/scripts/test-workspace-tests.py +++ b/scripts/test-workspace-tests.py @@ -114,6 +114,7 @@ EXAMPLES = "--example stubicc --example h264_h264enc_bench" AUDIT_PACKAGES = ("craft-ui-contract", "craft-ui-widgets", "craft-ui-panels", "craft-ui-patterns", "craft-ui-shell", "craft-ui-gallery", "craft-menu") AUDIT = " | ".join(f"package({name})" for name in AUDIT_PACKAGES) +SHARD_2 = AUDIT + " | package(craft-draw)" DOCTESTS = f"test --workspace --doc --all-features --locked {CONFIG}" @@ -129,9 +130,9 @@ def run_commands(test_filter="all()"): def archive_commands(directory, test_filter="all()"): return [ - f"nextest archive {ALL} {TARGETS} {EXAMPLES} -E ({test_filter}) & !({AUDIT}) " + f"nextest archive {ALL} {TARGETS} {EXAMPLES} -E ({test_filter}) & !({SHARD_2}) " f"--archive-file {directory}/1/a.tar.zst", - f"nextest archive {ALL} {TARGETS} {EXAMPLES} -E ({test_filter}) & ({AUDIT}) " + f"nextest archive {ALL} {TARGETS} {EXAMPLES} -E ({test_filter}) & ({SHARD_2}) " f"--archive-file {directory}/2/a.tar.zst", f"nextest archive {DEFAULT} {TARGETS} -E {test_filter} --archive-file {directory}/3/a.tar.zst", ] @@ -196,11 +197,12 @@ class WorkspaceTests(unittest.TestCase): def test_each_shard_runs_its_archive_and_shard_2_also_audits(self): expected = "nextest run --archive-file /a/b.tar.zst --workspace-remap . --profile ci --no-tests=warn" - for shard, prefixes in (("1", [""]), ("2", ["", "AUDIT "]), ("3", [""])): + # Shard 2 audits only the audit crates of its archive. + for shard, lines in (("1", [expected]), ("2", [expected, f"AUDIT {expected} -E {AUDIT}"]), ("3", [expected])): with self.subTest(shard=shard): result, _ = step("shard", GATE_SHARD=shard, NEXTEST_ARCHIVE_FILE="/a/b.tar.zst") self.assertEqual(result.returncode, 0, result.stderr) - self.assertEqual(result.stdout.splitlines(), [prefix + expected for prefix in prefixes]) + self.assertEqual(result.stdout.splitlines(), lines) result, _ = step("shard", GATE_SHARD="4", NEXTEST_ARCHIVE_FILE="/a/b.tar.zst") self.assertEqual(result.returncode, 2) self.assertEqual(result.stdout, "")