From 1a43d1f0e5b844909a275bc6563644f82318137b Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Sat, 4 Jul 2026 15:59:30 +0200 Subject: [PATCH] fix(commands): narrow deferred history policy --- commands/dispatcher.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/dispatcher.ts b/commands/dispatcher.ts index 107afd7..355d09c 100644 --- a/commands/dispatcher.ts +++ b/commands/dispatcher.ts @@ -59,13 +59,15 @@ function applyHistoryPolicy(options: { getDeferredHistory: () => { snapshot: HistorySnapshot; changed: boolean } | undefined; setDeferredHistory: (nextDeferredHistory: { snapshot: HistorySnapshot; changed: boolean } | undefined) => void; }): AppState { - if (options.historyPolicy.mode === "ignore") { + const { historyPolicy } = options; + + if (historyPolicy.mode === "ignore") { options.setDeferredHistory(undefined); return options.nextState; } - if (options.historyPolicy.mode === "deferred") { - return applyDeferredHistoryPolicy(options); + if (historyPolicy.mode === "deferred") { + return applyDeferredHistoryPolicy({ ...options, historyPolicy }); } return shouldRecordHistory(options.currentState, options.nextState) ? recordHistory(snapshot(options.currentState), options.nextState) : options.nextState;