mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-12-05 11:15:01 +03:00
Add 15 verified desktop sidebar, outline, trash, journal, and resize snapshot prefixes to ZERO_IN_PRODUCTION. Check uniqueness and non-redundancy across the added prefixes in unit tests. Update packages/frontend/AGENTS.md to list desktop source liveness alongside BlockSuite crates.
5.4 KiB
5.4 KiB
Working in packages/frontend/ (for agents)
packages/frontend/ holds the client Rust Cargo workspace (Cargo.toml and Cargo.lock) alongside legacy TypeScript frontend packages.
It uses resolver = "3", edition 2024, and its own rust-toolchain.toml (1.98.1 with wasm32-unknown-unknown) and rustfmt.toml.
Workspace boundaries and four-domain guards
packages/frontend/Cargo.tomllists every client member crate explicitly (../ui/tokens,../ui/ui,../ui/kit,../common/store,legacy-import,client,mobile,desktop,../../blocksuite/crates/doc,../../blocksuite/crates/editor,../../blocksuite/crates/playground,../../blocksuite/crates/preview,hosts/android, andhosts/ios). Never use directory wildcards that can scan asset directories.packages/frontend/Cargo.tomlexcludesnativeandmobile-native. Those legacy crates remain members of the rootCargo.tomlworkspace.- Legacy directories (
native/,mobile-native/, andapps/) carry a1.97.1rust-toolchain.tomlfile that matches the repository root byte-for-byte.native/andmobile-native/also carry arustfmt.tomlfile that matches the repository root byte-for-byte. - Client trees (
packages/frontend/,packages/ui/,blocksuite/crates/, andpackages/common/store/) share byte-identical1.98.1rust-toolchain.tomland clientrustfmt.tomlfiles. scripts/check-invariants.shdiscovers client workspace members fromcargo metadata --locked --no-deps, enforces four-domain acyclic dependencies (zero reverse edges), checks domain isolation, wall-clock isolation, zero tester branches, module structure, LOC ceilings, toolchain/rustfmt alignment,workspace_rootresolution,rustup show active-toolchainfor legacy (1.97.1) and client (1.98.1) directories, workflow YAML validity,CARGO_ENCODED_RUSTFLAGS=""link-flag isolation, and that every harness snapshot ID prefix inscripts/check-snapshot-prefixes.mjsstill occurs in non-test Rust sources underblocksuite/crates/*/srcandpackages/frontend/desktop/src.- See
packages/ui/AGENTS.md,blocksuite/crates/AGENTS.md, andpackages/common/store/AGENTS.mdfor domain-specific invariants.
Performance guardrail and theme/style oracle
perf/(schema.json,accepted.json,compare-n3.mjs,compare-n3.test.mjs): Zero-dependency rollingN-3CI comparator with strict schema validation and rerun history anchoring (--run-idcreated_atcutoff + pagination). Deterministic byte sizes (artifacts_bytes.*), work counters (non-_msbenchmarks.*), and unacknowledgedDROPPED/--require-n3BOOTSTRAPmetrics are hard-gated (--fail-on-regressionexits1); shared-runner wall-clock timings (benchmarks.*_msat> 10%,ci_wall_ms.*at> 10%and> 15_000 ms) are report-onlyADVISORY_SLOWDOWN. Intentional changes are acknowledged inpackages/frontend/perf/accepted.jsonviaaction: "ceiling"({ metric, accepted_value, reason }),action: "bootstrap"(newly added metrics under--require-n3), oraction: "drop"(retired metrics), with report-onlystale_acceptancesonce the rollingN-3baseline catches up. Unmeasured sub-keys are omitted ornull(never padded with synthetic0s).
Build & verification commands
Always clear inherited root rustflags:
CARGO_ENCODED_RUSTFLAGS="" cargo fmt --all -- --check
CARGO_ENCODED_RUSTFLAGS="" cargo clippy --locked --workspace --all-targets --features harness -- -D warnings
CARGO_ENCODED_RUSTFLAGS="" cargo check --locked -p ui-tokens -p ui -p ui-kit -p blocksuite-editor -p playground --target wasm32-unknown-unknown
CARGO_ENCODED_RUSTFLAGS="" cargo check --locked -p blocksuite-playground-doc --no-default-features --target wasm32-unknown-unknown
CARGO_ENCODED_RUSTFLAGS="" cargo check --locked -p affine-store --no-default-features --target wasm32-unknown-unknown
CARGO_ENCODED_RUSTFLAGS="" cargo test --locked --workspace
CARGO_ENCODED_RUSTFLAGS="" cargo test --locked --workspace --features harness
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- render --theme dark --mode page --out frame.png --snapshot frame.json
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- probes
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- bench --json perf-metrics.json
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- render-surface-sample --theme light --out surface-light.png --snapshot surface-light.json
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- render-editor artifacts/editor
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- render --state slash_menu_open --out slash.png --snapshot slash.json
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- audit-states
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- fps-check
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- record-demo artifacts/demo
./scripts/check-invariants.sh
node --test perf/compare-n3.test.mjs
node ../ui/tokens/extract-tokens.mjs --check
rustc --edition 2024 --test -D warnings ../ui/tokens/tokens.rs -o /tmp/tokens_test && /tmp/tokens_test
rustc --edition 2024 --test -D warnings ../ui/tokens/icons.rs -o /tmp/icons_test && /tmp/icons_test
rm -f /tmp/tokens_test /tmp/icons_test