Editor has no beforeunload handler — user can refresh or close tab and lose unsaved path edits silently #161
Labels
No labels
blocked:commit-ready-failed
blocked:gate-fetch
blocked:gate-lint
blocked:gate-plan
blocked:gate-research
blocked:needs-attention
blocked:needs-decision
blocked:needs-human
blocked:no-changes
blocked:verify-failed
bug
deferred
feature-request
in-progress
needs-decompose
needs-triage
quickfix
security/medium
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/Kimi_Agent_Brother_10_Digitizing_App#161
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Finding
The Editor (
src/pages/Editor.tsx) writes its path changes tosessionStorageon every modification (via the useEffect at line 188-210). The user can:/editorfinds stale data (or nothing, depending on timing)Back to Workspacecarries edits, but a navigation to/gallerycarries nothing (the Editor is unmounted, the sessionStorage entry is still there but is consumed by the next /workspace mount via #110)The app has no
beforeunloadhandler. The user can:The
beforeunloadevent in modern browsers is restricted (you can prompt the user to confirm leaving, but you can't prevent navigation; you can only show a "you have unsaved changes" message and let the user decide).Where
beforeunloadhandler:grep -rn 'beforeunload' src/returns no matchessrc/pages/Editor.tsx:188-210src/pages/Editor.tsx:186-200Suggested fix shape
Add a
beforeunloadhandler in the Editor:isDirtystate that flips totrueon any path mutation andfalseafter a save (or after EditorhandleExport).useEffectthat registersbeforeunloadwhenisDirtyis true:isDirtywhen the editor's sessionStorage write succeeds (or when handleExport runs).The user sees the browser's "Leave site? Changes you made may not be saved." dialog and can choose to stay or leave. The current behavior is silent loss.
Severity
Medium. The user can lose work without warning. The fix is small.
Discovered by
Gap analysis (2026-10-02) of editor resilience.
Related