Skip to content

how to contribute patterns and conventions

Douwe de Vries edited this page Jul 1, 2026 · 1 revision

Patterns and conventions

Load Rift keeps the frontend and backend contract explicit. React hooks call a typed API, the Tauri adapter maps that API to command names, and Rust commands return serde models in camelCase.

Contract mirroring

TypeScript Rust Notes
src/lib/loadrift/types.ts src-tauri/src/models.rs Shared payload shapes and status enums
src/lib/loadrift/api.ts src-tauri/src/lib.rs Frontend API methods and registered commands
src/lib/loadrift/api.ts src-tauri/src/events.rs Event names and event payloads

Rust models in src-tauri/src/models.rs use #[serde(rename_all = "camelCase")], which matches the TypeScript fields in src/lib/loadrift/types.ts.

State ownership

The backend stores process state in AppState in src-tauri/src/state.rs. test_is_busy treats both an active process and an in-progress launch as busy, so imports, starts, validation, and smoke tests can reject unsafe transitions.

Defensive UI persistence

src/app/persistence.ts catches storage failures and normalizes stored values before using them. Runner preferences persist common non-secret settings such as VUs, duration, thresholds, traffic mode, and request weights. Auth token, base URL, advanced JSON, and variable overrides are not part of persisted runner preferences.

Artifact safety

src-tauri/src/k6/process/runtime.rs writes private per-run temp directories and uses marker files before cleanup. Startup cleanup only removes stale marker-owned artifact directories after conservative shape and liveness checks.

For how these patterns appear in API calls, see Tauri commands.

Clone this wiki locally