Skip to content

fix(ui): keep the unsaved mark true to the file - #245

Merged
mrcsin merged 1 commit into
masterfrom
save-load-minor
Nov 30, 2026
Merged

mrcsin merged 1 commit into
masterfrom
save-load-minor

Conversation

@mrcsin

@mrcsin mrcsin commented Nov 30, 2026

Copy link
Copy Markdown
Member

Problem

The unsaved mark and the file it describes could disagree:

  • Undo or redo back to the saved state still showed the recipe as unsaved.
  • An edit made while a save was writing lost its unsaved mark, because the mark was cleared after the awaited write.
  • "Сохранить" in the exit, New or Open prompt counted as done even when an edit landed during that save, so the edit was dropped without a second prompt.
  • A save still in flight could finish after New or Open and point the file name at a different recipe.
  • New and Open did nothing, with no message, when a recipe run started while their prompt or picker was open.
  • The CSV temporary file was not flushed to disk before it replaced the target, and an unused PLC load path was left over.

What changed

  • The session keeps the saved recipe instance; the unsaved mark is "current differs from the saved one", so undo and redo back to it clear the mark, and the save marks the version it wrote.
  • The prompt's "Сохранить" means saved and still clean. New and Open wait while a save runs.
  • A run that starts during the New or Open dialog shows "Идёт выполнение рецепта: открыть или создать рецепт нельзя."
  • CsvFileIo flushes the temporary file to disk off the UI thread before the move.
  • LoadRecipeFromPlcAsync and PlcLifecycleManager.ReadRecipeFromPlcAsync are deleted; they had no production caller.
  • docs/readme.md describes the unsaved mark and undo.

This is Task 8 of docs/plans/20261130-recipe-replace-save-exit-safety.md.

Verification

  • Build 0 warnings; full suite 2211 passed, 0 failed; dotnet format --verify-no-changes clean.
  • New tests, failing on master: undo and redo back to the saved state, an edit during a held save, an edit during the prompt's save at exit and at New, New and Open blocked while a save runs, a run starting during the Open picker and the New prompt.
  • Code review and an independent review; their findings are fixed in this PR.

🤖 Generated with Claude Code

The unsaved mark did not always match the file on disk. Undo back to
the saved state kept the mark. An edit made while a save was writing
lost its mark, because the save marked whatever was current after the
write, and a prompt "Save" then let exit, New or Open drop that edit.
A run that started during the New or Open prompt or the Open picker
stopped the action silently.

- RecipeSession keeps the saved recipe instance and computes IsDirty
  from it, so undo or redo back to that state clears the mark and the
  next step away sets it again.
- SaveRecipeAsync marks saved the recipe it wrote, not the current one,
  so an edit during the write stays unsaved.
- The prompt answer Save lets the caller drop the recipe only when the
  save succeeded and the recipe is still clean.
- New and Open are disabled while a save runs, so a late save cannot
  point the file name at a different recipe.
- New and Open report the RunBlocksOpenOrNew warning when a run started
  during their dialog. Open also checks after the prompt, before the
  picker.
- LoadRecipeFromPlcAsync and PlcLifecycleManager.ReadRecipeFromPlcAsync
  had no production caller and are deleted. Their test duplicated
  ConflictResolvedWithThePlcRecipe_StartsWithoutMarks and is removed.
- CsvFileIo flushes the temporary file to disk before it replaces the
  target, off the UI thread, so a power loss cannot leave an empty
  recipe file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mrcsin
mrcsin marked this pull request as ready for review November 30, 2026 12:01
@mrcsin
mrcsin merged commit e47d88c into master Nov 30, 2026
1 check passed
@mrcsin
mrcsin deleted the save-load-minor branch November 30, 2026 12:08
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