Skip to content

Conversation

@max-nextcloud
Copy link
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
  • 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
  • Opening editor: steps from IndexedDB that didn't get sent to server yet need to get pushed
  • Opening editor: when steps from IndexedDB didn't get sent to server yet, unsaved changes should be indicated and saved
  • cleanup yDoc file server-side when file is deleted @mejo-
  • 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

codecov bot commented Sep 8, 2025

Codecov Report

❌ Patch coverage is 31.25000% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.86%. Comparing base (9d98aab) to head (d1d57d9).

Files with missing lines Patch % Lines
src/services/WebSocketPolyfill.ts 30.76% 9 Missing ⚠️
src/services/SyncService.ts 12.50% 6 Missing and 1 partial ⚠️
src/helpers/yjs.ts 0.00% 3 Missing and 1 partial ⚠️
src/composables/useConnection.ts 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7621      +/-   ##
==========================================
- Coverage   45.96%   45.86%   -0.10%     
==========================================
  Files         141      141              
  Lines        3964     3977      +13     
  Branches      747      750       +3     
==========================================
+ Hits         1822     1824       +2     
- Misses       1838     1847       +9     
- Partials      304      306       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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
For now text is sometimes duplicated

Signed-off-by: Max <[email protected]>
Keep the baseVersionEtag and the editing session around
in case people who are offline connect again later.

Signed-off-by: Max <[email protected]>
... and use it to check if the server is still on the same session.

Signed-off-by: Max <[email protected]>
When reopening a document that was edited offline
it will also be considered dirty now.

Autosave will not kick in yet... As no steps are pushed.
But when closing the file it will be saved.

Signed-off-by: Max <[email protected]>
If no changes have been made offline
clear the indexedDb cache
and reload Editor.vue
to load the latest editing session from the server.

Signed-off-by: Max <[email protected]>
Use a setter function that remains functional
even if the component has already been destroyed
and reactivity does not work anymore.

Signed-off-by: Max <[email protected]>
yjs and editor update logging can be very verbose.
Uncomment it but keep it disabled by default.

Can be enabled by setting the corresponding key in OCA.Text - i.e.
`window.OCA.Text.logWebSocketPolyfill = true`
in the browser console.

Signed-off-by: Max <[email protected]>
It was still enabled as we mistyped the `disableBc` option.

We cannot use it right now as the y-websocket room name
does not include the base version etag.

Therefore different tabs may be in different sessions
and would risk syncing never the less.

Observed this when reloading the editor on an outdated session:
* Cleaning up the old yjs document took a while in the beforeDestroy callback.
* The new document was already created.
* The new y-websocket provider issued a sync step 1 via browser broadcast.
* The old y-websocket provider responded and send its full state.

Signed-off-by: Max <[email protected]>
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 <[email protected]>
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.

Persist document state in browser IndexedDB storage

2 participants