evidence · 10.2 KiB

optimistic-apply-2026-09-25.md

Committed at docs/evidence/omarchy-themes/instant-theme-swap/optimistic-apply-2026-09-25.md. This is what grounds the requirements that cite it.

Open raw source

Optimistic Apply: show an already-prepared theme ahead of the durable commit

Implements OpenSpec task 7 from openspec/changes/archive/2026-10-12-the-shell-swaps-themes-without-a-python-stall/tasks.md, against the user’s explicit approval (2026-09-25 coordinator message: “The user has explicitly approved the optimistic theme apply”) of the design the change’s design.md records in full. This is a host-only result: no board, glass, or real-finger observation. Worktree perf/optimistic-theme-apply, base master 600171bc.

Starting point

Board re-check after skipping the redundant prepare (docs/evidence/omarchy-themes/instant-theme-swap/board-chooser-2026-09-25.md’s own “Re-check after skip-redundant-prepare” section, system v84gna5s1qnabg5mqhwa55anml2q8amh..., master bc0cf82f): tap Apply -> Rust appearance-commit-accepted 397 ms, helper parse=2.2ms prepare_entry= 63.0ms activate_generation=226.2ms. Still short of the user’s original ~100 ms target (“theme swaps should be instant”); the remaining cost is activate_generation’s own durable pointer-swap/preference/app-sync work, none of which can be skipped without risking the transaction’s own correctness.

What changed

Why this is safe (see design.md’s own “Optimistic Apply” section for the full reasoning)

A receiver only ever holds a prepared candidate after it has already validated that candidate byte-for-byte via the same checks a real prepare exchange runs. Rendering it early therefore risks nothing a real prepare ack would not already have accepted. The optimistic render is stateless with respect to the durable transaction — it reads prepared, renders, and is done — so there is nothing to reconcile if the two ever disagree: the real commit/rollback event, unaware optimism ever ran, always wins and settles the receiver’s actual state and the visible appearance correctly, including on a durable failure.

What was deliberately not done

Test-suite proof

Board commands for the coordinator (task 7.4)

journalctl -u shell-ui -u shell -o json --since "-2min" \
  | grep -E "optimistic-apply|appearance-(prepare|commit)-accepted|appearance-commit-rejected"

Steps: Settings, Themes, dwell on (or swipe to a neighbour-warmed) a non-active theme long enough for its own prepare-ahead to land, then tap Apply. Expected on a warm Apply: an optimistic-apply shown ms=<N> line appears before (or very close to) the durable activate’s own reply, and <N> is the number to compare against the ~100 ms target. Expected on a cold Apply (a theme the chooser never had time to prepare ahead): no optimistic-apply shown line at all, and the pre-existing busy-state behaviour. For the failure/rollback scenario, the coordinator’s own existing failure-injection approach (see docs/evidence/omarchy-themes/instant-theme-swap/board-diagnosis-2026-09-24.md/ tests/test_theme_commit_under_occlusion_runtime.py for the shape of a reproducible commit failure) should show a subsequent appearance-commit- rejected and the wallpaper/chooser visibly reverting to the previous theme with an error message, never settling on the optimistically-shown one.