Repository navigation
feat: EditorHost warn before leaving unsaved edits (#4962) - #4967
Conversation
Prompt on open folder, another item, Edit/View, and Close when field edits are dirty. Cancel stays. Confirm does not save. A successful save clears the prompt. > Co-Authored by Grok Build 1.0.41 using grok-4.7 with agent night-issue-prs.
Record the host mkd-code-review report. Host gate is request-changes: recycle prompts only after the item is deleted. > Co-Authored by Grok Build 1.0.41 using grok-4.7 with agent night-issue-prs-erlang.
|
request-changes — do not merge. Bug Same late prompt: Machine
|
Ask to discard unsaved edits before deleting, creating, or copying so Cancel keeps the open item. Confirm still does not save. > Co-Authored by Grok Build 1.0.41 using grok-4.7 with agent night-issue-prs-erlang-fix.
Record the post-fix machine report and the remaining pending-file discard bug. > Co-Authored by Grok Build 1.0.41 using grok-4.7 with agent night-issue-prs-erlang.
|
Erlang re-review (head Machine Bug: confirming discard does not clear Clear both maps on the confirmed leave path and add that assertion. Do not merge until that is in. PRs #4965 and #4966 were already MERGED before this pass.
|
Confirming leave still keeps pendingFiles and pendingClears, so a later save can upload a binary the dialog said was discarded. > Co-Authored by Grok Build 1.0.41 using grok-4.6 with agent night-issue-prs-erlang.
|
request-changes (head The Ollama finding that Bug — confirming discard does not drop a pending file or clear.
|
Confirming leave now clears pending files and clears, and reloading an item drops them too, so a later save cannot upload or delete a binary the dialog already discarded. > Co-Authored by Grok Build 1.0.41 using grok-4.6 with agent night-issue-prs-erlang-fix.
Confirming leave now clears pending files and clears. The remaining machine finding still asks to prompt after recycle, copy, and create, which is a false positive. > Co-Authored by Grok Build 1.0.41 using grok-4.6 with agent night-issue-prs-erlang.
Erlang re-reviewHead Machine issue Recommendation: approve. Not merged this pass: the check snapshot on
|
Summary
Parent: #4532. Slice #4962.
EditorHost asks before leaving with unsaved text or file edits: Open folder, opening another item, switching Edit / View, or Close. Cancel stays on the dirty form. Confirm continues and does not PUT. A successful Save clears the prompt. Confirming discard also drops pending file picks and pending binary clears so a later save cannot upload or delete that binary.
Operator: Grok: night-issue-prs (model grok-4.7)
Test plan
EditorHost.leaveDirty.test.tsx(14 tests): cancel keeps values, confirm does not save, save clears the prompt, pending file, switch item, confirm drops a pending upload, confirm drops a pending cleartests/editor-host-leave-unsaved.spec.js(1 passed)rtk mvn clean installBUILD SUCCESSProduct documentation
product-docs/8.2/getting-started/index.mdC3 evidence
cd WebUI && rtk mvn clean install— BUILD SUCCESS. JUnit Tests run: 69, Failures: 0. Vitest Test Files 573 passed, Tests 5263 passed.C5 UI proof
python3 docker/scripts/perc-devctl.py qa-up— TEST_CMS_URL=http://127.0.0.1:9993 QA_CONTAINER=perc-matrix-cms-h2python3 docker/scripts/perc-devctl.py qa-deploy-webuithen qa-health again RESULT:OKnpm run test:surface -- --path tests/editor-host-leave-unsaved.spec.js— 1 passedPre-push local code review
Erlang review — PR 4967
Re-review of head
ac69171f108d82b93f621b9616b2ed0a84e4926a(discarded binary picks cleared before a later save). CLI:mkd-code-review0.1.18,--pack percussion --format markdown --gate advisory --git-base origin/main --models models.ollama-dev-coder.toml.Summary
Machine analysis found 1 finding(s), 1 bug(s).
Scope
Recommendation
request-changes
Gate
Issues
Issue 1 -- Severity: bug
llm.ollama-dev-coderllmallowLeavefunction is called before therecycleItem,copyItem, andcreateItemfunctions, which can lead to unintended behavior if these functions modify the state in a way that affects the unsaved edits check.allowLeavefunction is called after any state modifications made byrecycleItem,copyItem, andcreateItem. This will ensure that the unsaved edits check is accurate.Erlang (re-review)
Machine issue 1 is a false positive.
EditorHost.tsx:1865iscopyErrorKeyFor, not a leave check.allowLeave()beforerecycleItem(handleRecycle),copyItem(handleCopy), andcreateItem(handleCreate) is the correct order: Cancel must not delete, copy, or create. Calling the prompt after those calls would reintroduce the bug fixed in160e939fe9.The prior blocking bug is fixed.
allowLeave(EditorHost.tsx:1938) callsdiscardUnsavedEdits(:1925) only after confirm, which clearspendingFilesandpendingClears, resetsdraftfrom the loaded payload, and bumpsdiscardEpochso file widgets remount. The field-load effect (:818) also clears both maps whencontentIdorreadOnlychanges, so a confirmed mode change or item switch cannot leave a binary for a later save.EditorHost.leaveDirty.test.tsxcovers confirm-on-mode-change for a pending upload and a pending clear; a following save does not calluploadBinaryorclearBinary.Host gate: approve. No in-diff bug remains. Do not merge until required checks on this head are green.
Recommendation: approve.
Fixes #4962