Each recipe is a task, start to finish. For what each part is, see the Technical reference; for why, see Understanding the architecture.
A change is done when the code is written, its tests cover the paths that fail as well as the one that works, its cost is measured where a budget applies, and the documentation says so — in English and in French.
Add a setting
- Add the field to
Settingsincrates/kve-config/src/settings.rs, with a doc comment that says what it is for. - Give it its value in
resources/settings/defaults.toml, with a comment above it: that file is what a user reads. Without a value, the tests fail. - Give it a fixed value in
resources/settings/for-tests.toml; a test holds the two files to the same keys. - Write it out in
Settings::annotated— onesetting(&mut out, "name", …)line in the order of the file. - Explain it in both catalogues,
settings.<name>incrates/kve-config/locales/en-US.ymlandfr-FR.yml. A test refuses a setting with no explanation. - Read it where it is used. In
kve-ui, a view that is not the window asks the window through an accessor rather than holding a copy. - Say so in the README’s example settings and on the user page that describes
the feature. The settings reference page is generated;
make sitewrites it.
Add a command
- Declare its action with the others at the top of
crates/kve-ui/src/window.rs. - Add it to the registry in
crates/kve-config/src/command.rs: anid(file.my_command), a scope,label_key: "command.file.my_command", a default binding orNone, and a group if it belongs in a submenu. - Name it in both catalogues under
command.<id>. - Map the id to the action in
crates/kve-ui/src/menu.rs, and, when it has a key, inbindings()inwindow.rs. - Handle it: a method on
EditorWindow, wired with.on_action(cx.listener(Self::my_command))in the window’s render. - Test the method, and the key with
cx.simulate_keystrokes(…)when it has one. The shortcut reference page is generated from the registry.
Add a string the user sees
- Add a key to
en-US.ymland the same key tofr-FR.yml, each written in its own language rather than translated word for word. - Use it with
kve_config::tr("key"), or add a helper incrates/kve-config/src/lib.rswhen it takes arguments (rust_i18n::t!("key", name = name)). - Never write a sentence in Rust. A test fails when the catalogues’ keys differ.
Measure something new
- Add a
Measurement::of(name, why, budget, iterations, setup)tocrates/kve-bench/src/main.rs.whysays where the budget comes from: a frame (16 ms), input handling (4 ms), or what is asked for once. - Build what is measured at the size that matters — 2,000 cards, 10,000 files, a 480 KB document — in the setup, and measure only the operation.
- Run
cargo run --release --locked -p kve-bench. A budget missed is a result, not a nuisance: find why before changing the budget. - Record the numbers in
docs/perf/, with what changed them. - For a cost inside a window, add a line with
crate::timing::timed(…): it prints only whenKVE_TIMINGS=1is set.
Test a window
- In
kve-ui, write a#[gpui::test]that opens a window witha_window_with(path, settings, cx)— onediting_alone()or another fixed set of settings, never the real defaults. - Act through the window’s own methods inside
handle.update(cx, …), or withcx.simulate_keystrokes(handle.into(), "ctrl-s")andsimulate_input. - Wait:
cx.run_until_parked(), andcx.executor().advance_clock(…)first for anything debounced. - To check where something is drawn, give the element a
.debug_selector(|| "name".into()), draw withVisualTestContext::from_window, and readdebug_bounds("name"). - Make the test fail with the fix taken out, once, before keeping it.
Look at the real window
-
make build, andcargo build -p kve-drive. -
tools/drive.sh start path/to/file— undercage, invisible; add--nestedto watch it on your desktop. PointXDG_CONFIG_HOMEandXDG_DATA_HOMEat a scratch folder to leave your own settings alone. -
Drive it with a script on standard input —
move,click,drag,key,type,scroll,sleep:tools/drive.sh run <<'EOF' move 640 400 sleep 200 click key ctrl+s EOFMove first and pause before a bare
click: a click where the pointer has not been yet is lost. -
tools/drive.sh shot out.png, thentools/drive.sh stop.
Retake a screenshot of the website
python3 tools/doc-shots.py en whiteboard retakes one scene in one language;
with no arguments, every scene in both. Each runs on a demo project the script
builds, so a scene changes by changing the script, never the picture.
Change a dependency
- Change the version in the workspace
Cargo.toml, then update that crate only:cargo update -p name. Never a barecargo update. - Run
make check, andkve-benchon its own if the crate is on a measured path. - Record the numbers in
docs/perf/and commitCargo.lockwith the change. The toolchain inrust-toolchain.tomlis changed the same way.
Change an address, a name or the maintainer
- Edit
project.toml, at the root — the only place any of them is written. make sync, forCargo.tomland the metainfo; the website, the release script and the package read the file as they run.cargo test -p kve-config --test projectconfirms every copy agrees.
Make a release
tools/release.sh check 1.0.0— changes nothing, says what is not ready.tools/release.sh prepare 1.0.0— sets the version everywhere and leaves a skeleton of the release notes; write them.tools/release.sh finish 1.0.0— the checks, the commit, the tag, the tarball, the.deband the site, indist/. Then push, upload and deploy yourself: the script prints the commands and runs none of them.