Skip to content

fix(core): leave the session unchanged on a failed load - #243

Merged
mrcsin merged 2 commits into
masterfrom
failed-load-atomic
Nov 30, 2026
Merged

mrcsin merged 2 commits into
masterfrom
failed-load-atomic

Conversation

@mrcsin

@mrcsin mrcsin commented Nov 30, 2026

Copy link
Copy Markdown
Member

Problem

A CSV that passed the file check but failed analysis, for example loops nested deeper than 3, still changed the session: RecipeSession.LoadAsCurrent cleared the undo history, stored the failed snapshot, set the unsaved mark and notified sync before it checked the analysis result. The session recipe became empty while the grid still showed the old steps, so a later Save could write an empty file. The PLC conflict take (ResolveConflict(false)) also loaded the PLC recipe without the import check the reconnect path runs.

What changed

  • LoadAsCurrent analyzes first and changes the snapshot, history, unsaved mark and sync state only on success. On failure the session, grid, undo, file name and title stay as they were, and the error reaches the notification panel.
  • The conflict take goes through ApplyRecipeFromPlc, so it checks the PLC recipe like reconnect does.
  • RecipeSession.LastValidRecipe is deleted: it had no production reader and now always equals Current.
  • The plan for the whole save/load safety series is added: docs/plans/20261130-recipe-replace-save-exit-safety.md and its UI spec. This PR is its Task 1.

After a failed take, sync still stays on until Task 3 of the plan turns it off; that is better than before, when the take wiped the local recipe.

Verification

  • Build 0 warnings; full suite 2203 passed, 0 failed; dotnet format --verify-no-changes clean.
  • New tests, failing on master: a failed Open leaves recipe, grid, undo, unsaved mark, file name and title unchanged; failed conflict takes (analysis failure, import check failure) leave the session unchanged; a failed take through the coordinator raises no mutation.
  • Code review and an independent review: no blocking findings.

Refs #234

🤖 Generated with Claude Code

mrcsin and others added 2 commits November 30, 2026 13:38
Opening a CSV that passes the file check but fails analysis, for
example loops nested deeper than 3, emptied the session: the undo
history was cleared, the recipe was replaced by the failed snapshot,
the unsaved mark was set and sync was notified, while the grid still
showed the old steps. RecipeSession.LoadAsCurrent cleared history and
replaced the snapshot before it checked the analysis result. Taking
the PLC recipe from the conflict dialog used the same method and
skipped the import check that the reconnect path runs.

LoadAsCurrent now analyzes first and changes the snapshot, history,
unsaved mark and sync notification only on success, so a failed load
leaves the session, the file name and the title as they were, and the
error reaches the notification panel. The conflict take goes through
ApplyRecipeFromPlc, the check the reconnect path uses.

Refs #234

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The plan and its UI spec cover #181, #234 and the save/load audit gaps; later PRs implement it task by task.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mrcsin
mrcsin marked this pull request as ready for review November 30, 2026 10:41
@mrcsin
mrcsin merged commit 8943092 into master Nov 30, 2026
1 check passed
@mrcsin
mrcsin deleted the failed-load-atomic branch November 30, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant