Skip to content

fix(ui): make a recipe taken from the PLC untitled - #249

Merged
mrcsin merged 1 commit into
masterfrom
take-plc-recipe
Nov 30, 2026
Merged

mrcsin merged 1 commit into
masterfrom
take-plc-recipe

Conversation

@mrcsin

@mrcsin mrcsin commented Nov 30, 2026

Copy link
Copy Markdown
Member

Problem

Taking the PLC recipe (conflict dialog "Загрузить из ПЛК", or reconnect onto an empty screen) kept the previous file name, so the next Ctrl+S overwrote that CSV with the PLC recipe and the title still named the old file (#234). The take also dropped unsaved edits without the "Сохранить изменения?" prompt, with the undo history cleared, and it loaded the PLC recipe read when the conflict was found, which could be outdated after the dialog waited.

What changed

  • One take path for the conflict answer and the reconnect take: PlcRecipeTake.RunAsync, PlcLifecycleManager.TakeConflictRecipe, PlcComparisonAnswers.TakeLocked, RecipeCoordinator.CompleteTake.
  • "Загрузить из ПЛК" with unsaved changes shows the prompt first; "Сохранить" takes only if the save succeeded and the recipe is still clean; "Отмена", X, or a failed or cancelled save return to the conflict dialog.
  • The take reads the PLC recipe again under a busy look (overlay, wait cursor, keys and close blocked, nothing greyed) with the link slot on "ПЛК: чтение рецепта…", bounded at 10 s; checks it; checks again for unsaved changes; and loads it untitled and marked unsaved, with undo and redo cleared and nothing written back. ConfirmInSync then sets the status to Synced, so a red sync error from before clears.
  • Outcomes: a failed or timed-out read shows "Не удалось прочитать рецепт из ПЛК." and the link reconnects; an identical PLC recipe ends the conflict in sync; an empty or uncommitted one writes the screen recipe with "Рецепт в ПЛК отсутствует. Записан рецепт с экрана."; a recipe that fails the check turns sync off. An answer that went stale during the prompt or the read takes nothing.
  • The title reads "SemiStep - Рецепт из ПЛК *"; Save opens "Сохранить как"; the name ends on Save As, New or Open. A save still writing when a take lands no longer restores its file name.
  • docs/readme.md, dialogs-and-interactions.md and error-reporting.md describe the take.

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

Verification

  • Build 0 warnings; full suite 2337 passed, 0 failed, in two runs; dotnet format --verify-no-changes clean.
  • Tests cover rows A2-A7, B1, B2, B4, a key and a close during the take, a read that never returns, a take after a failed write, a save outliving a take, a stale answer, the title and Save As after a take.
  • Live against the PLC emulator: "Загрузить из ПЛК" over an edit showed the save prompt; after "Не сохранять" the title read "SemiStep - Рецепт из ПЛК *", the link slot "подключено", and the cell held the emulator's value; Save opened "Сохранить как".
  • Code review and an independent review; their findings are fixed in this PR.

Closes #234

🤖 Generated with Claude Code

"Загрузить из ПЛК" kept the old file name, so the next Ctrl+S wrote
the PLC recipe over that CSV (#234). The take also dropped unsaved
edits without the "Сохранить изменения?" prompt and loaded the recipe
the comparison had read before the dialog opened, which could be
minutes old.

The conflict answer now runs one take path, PlcRecipeTake. On a dirty
recipe it asks first: Save saves (Save As when untitled) and takes
only when the save succeeded, Don't save takes, Cancel or a failed
save shows the conflict dialog again. Then it reads the PLC recipe
again under a busy look (transparent overlay, wait cursor, keys
blocked, link slot "ПЛК: чтение рецепта…") bounded at 10 s in the UI.
PlcLifecycleManager.TakeConflictRecipe decides on the UI thread: a
failed or timed-out read changes nothing, reports it and declares
link loss; an empty or uncommitted PLC recipe ends the conflict with
a write of the screen recipe; an identical one ends it in sync; a
screen that changed during the read asks again. Both this take and
the reconnect take load through PlcComparisonAnswers.TakeLocked,
which writes nothing back and calls the new ConfirmInSync, so the
status is Synced and a failed write's red latch clears.

RecipeCoordinator raises PlcRecipeTaken after a take, and
RecipeFileViewModel drops the file name: the title reads
"SemiStep - Рецепт из ПЛК *", the recipe is unsaved with empty undo
history, and Save opens Save As until a Save As, New or Open
succeeds. The ResolveConflict answer TakePlc is gone, so nothing else
replaces the session recipe from the PLC.

A save command holds every take until it ends, and a take that lands
during the write keeps the recipe untitled, so a late save cannot put
its file name back on the taken recipe. The take checks before the
read that its conflict is still current: a link drop during the
prompt ends it without a read and without showing a stale dialog
again. The window refuses a close request during the busy look. A
link-loss fault that follows a failed take read is dropped once, and
only when that read declared the link loss.

Closes #234

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mrcsin
mrcsin marked this pull request as ready for review November 30, 2026 17:33
@mrcsin
mrcsin merged commit efaca94 into master Nov 30, 2026
1 check passed
@mrcsin
mrcsin deleted the take-plc-recipe branch November 30, 2026 17:39
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.

Taking the PLC recipe keeps the old file path, so Save overwrites that file

1 participant