From e192a496e9264249ff60b625453a3f1227af2221 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 14:14:32 +0200 Subject: Fix reset action flow --- lua/clever_f/action_facade.lua | 10 ++++++++++ lua/clever_f/sequence_coordinator.lua | 13 +++++++++++++ tests/run.lua | 31 +++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/lua/clever_f/action_facade.lua b/lua/clever_f/action_facade.lua index 1dd5052..e8ea356 100644 --- a/lua/clever_f/action_facade.lua +++ b/lua/clever_f/action_facade.lua @@ -54,6 +54,16 @@ end ActionFacade.invoke_primary = ActionFacade.primary ActionFacade.start = ActionFacade.primary +function ActionFacade:reset() + local outcome = self:coordinator():reset() + if not domain.ActionOutcome.is(outcome) then + fail("SequenceCoordinator must return an ActionOutcome", 2) + end + return outcome +end + +ActionFacade.Reset = ActionFacade.reset + local function explicit_outcome(facade, method_name) local coordinator = facade:coordinator() local outcome = coordinator[method_name](coordinator) diff --git a/lua/clever_f/sequence_coordinator.lua b/lua/clever_f/sequence_coordinator.lua index 59dc332..a83c75f 100644 --- a/lua/clever_f/sequence_coordinator.lua +++ b/lua/clever_f/sequence_coordinator.lua @@ -480,6 +480,19 @@ function SequenceCoordinator:last_explicit_resolution() return coordinator_records[self].last_explicit_resolution end +function SequenceCoordinator:reset() + local record = coordinator_records[self] + local position = domain.Position.coerce(record.host:read_cursor()) + local cleanup = record.transitions:PublicReset(record.host:read_window()) + if type(record.feedback.release_transition_cleanup) ~= "function" then + fail("FeedbackService must release reset cleanup", 2) + end + record.feedback:release_transition_cleanup(cleanup) + return domain.ActionOutcome.neutral(position) +end + +SequenceCoordinator.Reset = SequenceCoordinator.reset + function SequenceCoordinator:read_explicit_invocation() local host = coordinator_records[self].host if type(host) ~= "table" diff --git a/tests/run.lua b/tests/run.lua index fb97146..9ccb079 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -7707,6 +7707,37 @@ test("ActionFacade returns typed primary action outcomes", function() end, "clever-f: Invalid mapping 'x'") end) +test("ActionFacade Reset applies public cleanup and returns neutral", function() + local state, transitions = fresh_sequence_state() + local target_value = target("a") + local landing = domain.Position.new(1, 3) + local host = MemoryHost.new({ + buffer_lines = { "aba" }, + cursor = landing, + }) + transitions:BeginAcquisition("n", "f") + transitions:CommitAcquiredTarget("n", target_value, 25) + transitions:CommitCommandSuccess("n", landing, true) + local overlay = host:create_highlight({ + group = "CleverFChar", + window = "window-1", + positions = { landing }, + }) + transitions:AddTargetOverlay(overlay, "window-1", 1) + local timer = host:start_timer(30, function() end) + transitions:SetHighlightTimer(timer) + + local outcome = action_facade.new({ host = host }):reset() + + same(domain.ActionKind.NEUTRAL, outcome.kind) + same(landing, outcome.position) + same(nil, state:get_previous_descriptor("n")) + same(nil, state:get_previous_landing("n")) + same(target_value, state:get_previous_target("n")) + same(nil, host:highlights()[overlay]) + falsy(host:timers()[timer].active) +end) + test("Same-direction explicit coordination reads current-context state", function() local _, transitions = fresh_sequence_state() local normal_target = target("a") -- cgit v1.2.3