Skip to content

enh/y indexeddb#7621

Open
max-nextcloud wants to merge 43 commits intomainfrom
enh/y-indexeddb
Open

enh/y indexeddb#7621
max-nextcloud wants to merge 43 commits intomainfrom
enh/y-indexeddb

Conversation

@max-nextcloud
Copy link
Copy Markdown
Collaborator

@max-nextcloud max-nextcloud commented Sep 8, 2025

TODOs

  • Think through other file operations.
  • Typing without network, closing the editor, opening it again: no content lost
  • After closing and opening the editor, undo history is empty
  • cleanup yDoc file server-side when file is deleted @mejo-
  • Add base_version_etag as custom property to IndexedDB
    • After loading document from IndexedDB, send baseVersionEtag as part of create request
    • In case of conflict, use existing manual conflict handling
    • After manual conflict handling, reset y-indexeddb provider for document
    • Fix endless reload loop when base version has been cleared:
      • Open file with version in indexed db but on a different baseVersionEtag.
      • Different versions are detected. Reload button is offered.
      • Reload does not change the indexed db content - so conflict persists.
    • migrate change mime type test to playwright
    • debug failing change mime type test.
    • make bc channel depend on base version etag.
    • Test... start editing offline, overwrite file in other tab, see what happens when getting back online @max-nextcloud
  • Handling conflicts when opening file that was changed offline
    • detect conflict
    • handle scenario with no local changes well
    • display conflict when local changes were made
    • adjust conflict dialog wording
    • test conflict resolutions work
  • Reconnecting: saved unsaved changes:
    • indicate dirty state
    • autosave when opening dirty file
    • autosave when reconnecting with editing session open
    • push steps that have not been pushed yet
  • cleanup client side state for deleted files
  • config flag

@max-nextcloud max-nextcloud requested a review from mejo- as a code owner September 8, 2025 09:44
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 8, 2025

@max-nextcloud max-nextcloud force-pushed the enh/y-indexeddb branch 7 times, most recently from 6637691 to e746625 Compare October 27, 2025 20:17
@max-nextcloud max-nextcloud force-pushed the enh/y-indexeddb branch 5 times, most recently from 6d4c06b to 1ade042 Compare November 5, 2025 15:56
@max-nextcloud max-nextcloud force-pushed the enh/y-indexeddb branch 4 times, most recently from 853ca71 to 0a18ad3 Compare November 6, 2025 19:56
@mejo- mejo- self-assigned this Dec 3, 2025
@mejo-
Copy link
Copy Markdown
Member

mejo- commented Dec 3, 2025

  • cleanup yDoc file server-side when file is deleted @mejo-

Turns out this already happens and we don't have to change anything:

$this->documentService->resetDocument($node->getId(), true);

max-nextcloud and others added 25 commits April 21, 2026 15:07
Signed-off-by: Max <max@nextcloud.com>
Otherwise the old session would get mixed with the new content
when people come back with old state in indexed-db.
( Run playwright/e2e/indexed-db.spec.ts for an example. )

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
This could be the basis for automatically merging
changes from an offline editing session
and changes by overwriting the doc.

Signed-off-by: Max <max@nextcloud.com>
Reconnect to a new session but remember the local change.
Show a conflict between the remote session and the local change.

Signed-off-by: Max <max@nextcloud.com>
Conflicts with unsaved changes in indexed db work differently.
When the file is overwritten on the server while editing
the editing session keeps going and the new file version is shown read only.

When opening the file and a conflicting version is found in indexed db
that local version is shown read only allowing to connect to a new session.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Broadcast is disabled right now.
Make sure two editing sessions for the same file to not mix when enabling it.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
The pushing does not happen yet - thus the test is failing.

Signed-off-by: Max <max@nextcloud.com>
Expose the update mechanism inside the websocket provider.
This is normally triggered by updates of the ydoc.
But as the updates happened while offline in a previous session
we need to trigger it explicitely.

The websocket provider holds the remote state of the document.
So it can compute an update based on this and the current ydoc.

Signed-off-by: Max <max@nextcloud.com>
…ode)

Signed-off-by: silver <s.szmajduch@posteo.de>
… (ai code)

Signed-off-by: silver <s.szmajduch@posteo.de>
Signed-off-by: silver <s.szmajduch@posteo.de>
Signed-off-by: silver <s.szmajduch@posteo.de>
Signed-off-by: silver <s.szmajduch@posteo.de>
Signed-off-by: silver <s.szmajduch@posteo.de>
Signed-off-by: silver <s.szmajduch@posteo.de>
Signed-off-by: silver <s.szmajduch@posteo.de>
Signed-off-by: silver <s.szmajduch@posteo.de>
})
})
.catch((err) => {
logger.warn('IndexedDB sync did not complete', { err })
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know in which scenarios this throws? I wonder whether this should be handled gracefully or whether this is a scenario that actually should throw as something is broken afterwards.

@mejo- mejo- force-pushed the enh/y-indexeddb branch from 93635fb to dd5d5c6 Compare April 21, 2026 13:38
mejo- added 2 commits April 21, 2026 16:04
There might still be dangling async functions trying to write to
IndexedDB after `clearIndexedDB()` was called. Guard against these race
conditions.

Generated with the help of AI but verified and implemented manually.

Signed-off-by: Jonas <jonas@freesources.org>
Needed so local changes don't get lost when editor is closed in
case of conflict.

Signed-off-by: Jonas <jonas@freesources.org>
@mejo- mejo- force-pushed the enh/y-indexeddb branch from 91e3f5b to 77c384c Compare April 21, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗️ In progress

Development

Successfully merging this pull request may close these issues.

Persist document state in browser IndexedDB storage

4 participants