Collapse a Design View mode switch and its background FX parking to ONE undo point

applyMode now returns with its undo block open; the reclaimer closes it when the drain
settles. A transport deferral or a tab switch ends it early -- two points, never a leak.
This commit is contained in:
2026-08-07 12:53:42 -04:00
parent 2173263bb9
commit 86aa8dabba
7 changed files with 449 additions and 50 deletions
+4 -3
View File
@@ -32,9 +32,6 @@ bool transportBlocksModeSwitch(ReaProject* proj);
//
// A real switch mints regardless, fail-safe: it is an explicitly fired action and has
// to stay undoable even in the degenerate case where the plan found nothing to write.
// Note what applyMode CANNOT see when it decides — the `view_state` ext-state write
// lands in persistViewState, after this block has closed (src/shell/view/CLAUDE.md's
// Gotchas).
inline bool applyMintsUndoPoint(bool realSwitch, bool wroteAnything) {
return realSwitch || wroteAnything;
}
@@ -54,6 +51,10 @@ bool modeApplyInProgress();
// path: TrackFX_SetOffline was 1897ms of a measured 1942ms switch, against 0.02ms for
// all the flag work below. Do not reintroduce a synchronous FX write.
//
// A REAL switch therefore RETURNS WITH ITS UNDO BLOCK STILL OPEN (fx_reclaim's
// UndoSpan): the reclaimer closes it once the parking has drained, which is what keeps
// the switch and its FX writes ONE point rather than two. A reapply closes its own.
//
// Returns false (no mutation) if `targetModeId` isn't registered, if this is a real
// switch (target != active) while the transport is running, if it is re-entered
// (modeApplyInProgress), or if the project does not validate. A reapply (target ==