阅读约 5 分钟在 GitHub 上编辑

此页面尚未翻译。以下正文为英文。

Development

Home · Architecture · UI Architecture · Adding a backend · Platform support

This handbook covers building Tessera from source, running crate and isolated-display test suites, debugging live sessions, working with localization catalogs, and preparing pull requests. Before opening a PR, read Architecture, the repository’s AGENTS.md and CONVENTIONS.md, and the AGENTS.md of each crate you touch.

Toolchain & prerequisites

Tessera targets Rust 1.100.0 (edition 2024, Cargo resolver 3), pinned in rust-toolchain.toml.

Platform Required dependencies
Linux (GTK / Adwaita) GTK 4.18+ development headers, libadwaita 1.5+, pkg-config, C toolchain, dbus. For live display tests: xvfb, xfwm4, xdotool, dbus-run-session, ImageMagick import.
Linux (Qt / KDE) Qt 6, Kirigami, KDE Frameworks 6 (KF6), C++ compiler and CMake (for tessera-ui-qt).
macOS Xcode Command Line Tools (arm64).
Windows MSVC build tools (x86_64 or aarch64), Windows App SDK / WinUI 3 runtime.

On Linux, .github/actions/install-distro-packages/install.sh lists the exact packages for Debian, Fedora, and Arch Linux.

Workspace map

The workspace under crates/ contains 23 crates organized into clear layers:

  • Core & settings: tessera-core, tessera-settings, tessera-config, tessera-i18n
  • Backend port & adapters: tessera-backend, tessera-backend-bridge, tessera-backend-x11, tessera-backend-gnome, tessera-backend-kwin, tessera-backend-macos, tessera-backend-windows
  • UI model & providers: tessera-ui, tessera-ui-gtk, tessera-ui-adwaita, tessera-ui-plugin-gtk, tessera-ui-qt, tessera-ui-freedesktop, tessera-ui-macos, tessera-ui-windows
  • Custom layouts & MCP: tessera-protocol, tessera-worker, tessera-mcp
  • Composition root: tessera-app

Building & running locally

# Build the workspace (includes tessera, tessera-layout-worker, and UI plugins)
cargo build --workspace --all-targets --locked

# Run the preferences window / controller from source
cargo run -p tessera-app

# Fast typecheck across the workspace
cargo check --workspace --all-targets --locked

On Linux, tessera links no GUI toolkit at compile time. It loads libtessera_ui_plugin_gtk.so or libtessera_ui_plugin_qt.so at runtime from the build output or installed plugin path.

Testing & validation

scripts/host-gate.sh is the cross-host gate entry point (scripts/test-all.sh handles Linux and macOS):

Host What it runs
Linux scripts/test-all.sh / scripts/host-gate.sh → scripts/test-env.sh gate: fmt, clippy, and workspace tests inside a private Xvfb (1920x1080), a live xfwm4, and a private D-Bus session.
macOS scripts/test-all.sh / scripts/host-gate.sh: fmt, clippy, and cargo test --workspace --all-targets, plus tessera-ui-macos --features native-test-support.
Windows scripts/host-gate.sh: clippy and workspace tests (omits fmt).

macOS Accessibility testing: Do not run live Accessibility integration tests or launch tessera from an Accessibility-granted terminal over unsaved desktop windows. See AGENTS.md (§macOS Accessibility) for the safe testing workflow.

Crate-by-crate focal test commands

When iterating on a specific layer, run its focal test suite before running the full workspace gate. See Architecture for details on LayoutConciliator, FrameConciliation and wiring, and the Runtime loop, WakeState, and DaemonNotifier.

# Pure tiling engine, reconciliation, layouts, backoff
cargo test -p tessera-core
cargo test -p tessera-core --test conciliation

# Settings, YAML config preservation, atomic writes
cargo test -p tessera-settings
cargo test -p tessera-config

# Localization parity across all 10 Fluent catalogs
cargo test -p tessera-i18n --test locale_parity

# Backend port, registry, facets, and semantic contract suite
cargo test -p tessera-backend --all-features

# Neutral UI model, layout solver, plugin ABI, and provider conformance
cargo test -p tessera-ui --all-features
cargo test -p tessera-ui --test provider_conformance --test control_plan --test os_providers_contract_test

# Sandboxed QuickJS worker & wire protocol
cargo test -p tessera-protocol
cargo test -p tessera-worker

# Embedded MCP server (policy, rate limits, IPC)
cargo test -p tessera-mcp

# Composition root & integration tests
cargo test -p tessera-app
cargo test -p tessera-app --test frame_conciliation_and_suppression_invariants

Isolated display profiles (scripts/test-env.sh)

Display-dependent tests never run against your everyday desktop or session bus. scripts/test-env.sh <profile> <cmd...> provisions a private display and bus and refuses to run against :0:

Profile Environment
x11-bare Private Xvfb, no window manager.
x11 Private Xvfb with a live xfwm4.
x11-dummy Xorg dummy server with two RandR outputs (hotplug, resolution, rotation).
wayland Headless Weston session.
kwin-wayland Headless kwin_wayland --virtual with the shipped KWin script.
gnome-wayland Headless GNOME Shell with the shipped extension.
gate Full workspace gate (fmt, clippy, tests).

Session containers can also be invoked directly via scripts/session/run-session-container.sh <xfce|kwin-wayland|gnome> -- <cmd>. Containers have no network, no host display, and no cargo, so compile the test binary on the host first and pass the binary path.

test-env.sh exit codes: 0 success, 2 usage error, 3 UNAVAILABLE (missing prerequisite), 4 refused user’s display, 5 xfwm4 died during a gate run. Tests that cannot run print UNRUN: <reason> and are never counted as passing.

Debugging (RUST_LOG & --debug-info)

Structured tracing with RUST_LOG

Tessera uses tracing and tracing-subscriber with RUST_LOG filtering (tessera_app defaults to a quiet filter when RUST_LOG is unset):

# Detailed reconciliation, frame-conciliation, and backend traces
RUST_LOG=tessera_app=debug,tessera_backend=debug cargo run -p tessera-app

# Trace a single integration test inside an isolated X11 session
scripts/test-env.sh x11 env RUST_LOG=tessera_app=debug cargo test -p tessera-app --test geometry_convergence

Environment & live session inspection

Use the built-in diagnostic commands to inspect what Tessera observes without altering configuration:

# Redacted environment, config diagnostics, capabilities, UI provider, and monitors
tessera --debug-info
tessera --debug-info --include-apps --json

# Live window and app inventory dumps
tessera debug windows
tessera debug apps

Internationalization (i18n) workflow

Every user-facing string—UI labels, CLI help, diagnostic messages, and thiserror failure texts—lives in Fluent (.ftl) catalogs under crates/tessera-i18n/i18n/<locale>/tessera.ftl across all 10 locales:

de, en, es, fr, it, ja, ko, pt-BR, ru, zh-CN

  1. Add new message IDs using lowercase, hyphen-separated names (for example, ui-layouts-gap-label, error-config-invalid).
  2. Add the same key and variables to all 10 tessera.ftl files.
  3. Verify parity before committing:
    cargo test -p tessera-i18n --test locale_parity

Coding standards & PR checklist

Architectural & dependency rules

  • Boundary isolation: Keep tessera-core free of OS, GUI, YAML, and i18n dependencies. Keep #[cfg(target_os = ...)] and std::env reads inside crates/tessera-app/src/platform* and adapter crates (clippy.toml enforces disallowed_methods).
  • Typed errors: Define thiserror::Error enums per port or adapter. Never return Result<_, String> or reference AppError outside tessera-app.
  • Dependencies: New crates must be at their latest stable release and at least 3 days old (.cargo/config.toml sets registry.global-min-publish-age = "3 days"). Run cargo deny check after adding or updating dependencies. Do not add serde_yaml or global-hotkey.
  • No unsafe in neutral crates: Neutral crates forbid unsafe. tessera-ui allows unsafe only in src/plugin/ for the C ABI entry point.

Preflight & signed Conventional Commits checklist

Before opening a pull request:

  1. Format & typecheck:
    cargo fmt --all --check
    cargo check --workspace --all-targets --locked
  2. Lint with warnings denied:
    cargo clippy --workspace --all-targets -- -D warnings
  3. Run workspace tests and builds (or scripts/host-gate.sh on Linux, macOS, and Windows, and scripts/test-all.sh on Linux and macOS):
    cargo test --workspace --all-targets --locked
    cargo build --workspace --all-targets --locked
    cargo test -p tessera-i18n --test locale_parity
  4. Stage explicit paths (git add <path>) and commit using signed Conventional Commits (git commit -S, for example feat(core): ..., fix(backend-x11): ..., docs(wiki): ...). Do not edit CHANGELOG.md manually.

Documentation & website

The project website lives in the homepage repository (tessera-tiling/homepage), which pulls documentation pages from the wiki/ submodule (tessera-tiling/tessera-tiling.wiki). After a fresh clone, run git submodule update --init to populate wiki/.

# Inside the homepage repository
npm ci
npm run dev        # local Astro preview
npm run build      # static build into dist/
npm run check      # build + i18n, link, and wiki checks

Documentation images live under wiki/images/ and are referenced relative to the wiki root (for example, ![Tall layout](images/layouts/tall.svg)). Layout diagrams are generated from tessera-ui:

cargo run -p tessera-ui --example generate_layout_svgs