Skip to content

Feature/wiki prevent ancestor reversion milkdown - #9

Open
NishikawaKoharu wants to merge 6 commits into
RCOSDP:developfrom
NishikawaKoharu:feature/wiki-prevent-ancestor-reversion-milkdown
Open

Feature/wiki prevent ancestor reversion milkdown#9
NishikawaKoharu wants to merge 6 commits into
RCOSDP:developfrom
NishikawaKoharu:feature/wiki-prevent-ancestor-reversion-milkdown

Conversation

@NishikawaKoharu

Copy link
Copy Markdown
Contributor

Purpose

Prevent wiki "ancestor reversion": closing the editor left IndexedDB drafts that could overwrite newer content when reopening and saving. Improve close / re-edit behavior for both single-user and collaborative editing, while preserving expected Preview and collaborator-name behavior.

Changes

  • Show an unsaved-changes confirmation only when closing with local unsaved edits (single editor)
  • On Close / Discard / Save and Close, clear the local IndexedDB draft cache
  • Keep the y-websocket connection and Y.Doc alive on Close (do not tear down the shared collaborative session)
  • On re-edit, recreate the tab's local session when needed and use awareness to decide live collab state vs. latest DB content
  • During collaborative editing, skip the close confirmation (showing "Discard" would be misleading)
  • During collaborative Close, keep Wiki version on Preview and keep the editor instance (leaveCollaborativeEditMode)
  • Clear awareness on collaborative Close, and restore the local user name on re-edit via setLocalAwarenessUser (works after setLocalState(null))
  • Use disableBc: true to avoid BroadcastChannel-related issues across tabs
  • Suppress the beforeunload warning after intentional Save and Close navigation
  • Fix focus when entering edit mode on a newly created wiki page

Companion UI/i18n PR: RDM-osf.io (edit.mako, messages.po).

QA Notes

  • Does this change require a data migration? If so, what data will we migrate?
    • No
  • What is the level of risk?
    • Medium (editor close/re-edit and collaborative awareness paths)
  • Any permissions code touched?
    • No
  • Is this an additive or subtractive change, other?
    • Behavioral change to wiki editor close / re-edit / draft-cache handling
  • How can QA verify? (Through UI, API, AdminApp or AdminAdminApp?)
    • Through UI (with the RDM-osf.io companion PR deployed):
      1. Single editor, unsaved changes: Close → confirmation modal → Discard or Save and Close
      2. Single editor, no changes: Close → no modal, editor closes
      3. Stale draft prevention: Edit → Close (Discard) → another user/session updates and saves → reopen edit → content should reflect the latest saved version, not the discarded draft
      4. Collaborative editing Close: Two users/tabs editing the same page → Close on one side → no confirmation modal; Wiki version stays Preview; the other editor continues
      5. Collaborative re-edit: After Close, re-enter Edit → the other side shows this user's name again
      6. Re-edit after Close: Content / collab state are correct
      7. Save and Close: No unexpected beforeunload browser warning
  • If verifying through API, what's the new version? Please include the endpoints in PR notes or Dev docs.
    • N/A
  • What features or workflows might this change impact?
    • Wiki Milkdown editor: Close, Discard, Save and Close, re-edit, collaborative editing, collaborator name display
  • How will this impact performance?
    • Minimal; short awareness settle wait on editor load / re-edit only

Documentation

  • No documentation updates required

Side Effects

  • IndexedDB drafts are cleared on Close / Discard / Save and Close (intentional)
  • Close no longer destroys the shared y-websocket / Y.Doc session for other collaborators
  • During collaborative editing, Close skips the unsaved-changes dialog and keeps Preview
  • During collaborative Close, the local user disappears from awareness until they re-enter Edit

Ticket

https://redmine.devops.rcos.nii.ac.jp/issues/61563

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.

2 participants