Skip to content

[stable33] fix/autosave timer - #8989

Draft
backportbot[bot] wants to merge 17 commits into
stable33from
backport/8928/stable33
Draft

[stable33] fix/autosave timer#8989
backportbot[bot] wants to merge 17 commits into
stable33from
backport/8928/stable33

Conversation

@backportbot

@backportbot backportbot Bot commented Aug 6, 2026

Copy link
Copy Markdown

Backport of #8928

Warning, This backport's changes differ from the original and might be incomplete 鈿狅笍

Todo

  • Review and resolve any conflicts
  • Review and verify the backported changes
  • Remove all the empty commits
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@backportbot
backportbot Bot requested a review from mejo- August 6, 2026 05:13
@backportbot backportbot Bot added this to the Nextcloud 33.0.8 milestone Aug 6, 2026
@max-nextcloud max-nextcloud changed the title [stable33] [stable34] fix/autosave timer [stable33] fix/autosave timer Aug 6, 2026
Debounce will delay the execution of the function every time it is called.
So autosave was waiting until no updates occured for 30 seconds.

That's a long time and does not feel responsive.
Try to autosave every time the user stops typing for at least one second.

Signed-off-by: Max <max@nextcloud.com>
@max-nextcloud max-nextcloud self-assigned this Aug 6, 2026
@github-project-automation github-project-automation Bot moved this to 馃Л Planning evaluation (don't pick) in 馃摑 Productivity team Aug 6, 2026
@max-nextcloud max-nextcloud moved this from 馃Л Planning evaluation (don't pick) to 馃憖 In review in 馃摑 Productivity team Aug 6, 2026
max-nextcloud and others added 16 commits August 6, 2026 10:41
Also removed the document attribute from the `sync` event load.
It is already included in the `change` event load.

Signed-off-by: Max <max@nextcloud.com>
The server will only accept autosaves every 10 seconds.
`document` contains the last saved timestamp.
Compute the time to autosave next.
Add a small random delay (up to 3 seconds)
to avoid all connected clients from saving at the same time.

Signed-off-by: Max <max@nextcloud.com>
Keep track of the version that has our changes
and compare it to the last saved version on the server.

This allows fixing two scenarios:
* Server response happily to save but does not actually save.
  The server will only save new versions every 10 seconds.
  If the latest save just happened it will still respond with 200
  but list the outdated version in the response.
  Comparing the versions shows that our changes have not been saved yet.
* Other user already saved the file.
  our changes.
  So far dirty would stay true until WE save our changes.
  Comparing the versions also shows the file was saved
  when it was saved by someone else.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
* `getSaveData` now prepares the data to send to the server.
* `provideSaveService` now handles all the sync service events
  calling functions on `saveService` where needed.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
The server will only perform one actual save every 10 seconds.

Trigger another autosave if the save attempt was throttled.
`document` is udpated by throttled save attempts.
Rely on its `lastSavedVersionTime` for the retry.

Signed-off-by: Max <max@nextcloud.com>
* If the server claims to have saved the doc in the future
  use the current timestamp instead.
  Autosave happens at least ten seconds after `lastSavedVersionTime`.
  So if that was far into the future it would never happen.

* If the server is living in the past
  delay the autosave retries
  without relying on `lastSavedVersionTime`.

Signed-off-by: Max <max@nextcloud.com>
Adding a random offset makes determenistic testing harder.

Now we also do not depend on in sync clocks.

Signed-off-by: Max <max@nextcloud.com>
Autosave is triggered by the push of the steps.
Saving before that delays the autosave because of server throttling.

Signed-off-by: Max <max@nextcloud.com>
Some of our runners are slow. Give them more time to finish the runs.

Also separate local and CI config in the config file.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Only consider the local clock.
Avoid problems if clocks are out of sync
or if the server is unresponsive and `lastSavedVersionTime` does not get updated

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Allow importing with ts extensions.
This way we can backport changes to the import statements more easily.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Jonas <jonas@freesources.org>
@max-nextcloud
max-nextcloud force-pushed the backport/8928/stable33 branch from a4505f1 to e011a8e Compare August 6, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 馃憖 In review

Development

Successfully merging this pull request may close these issues.

2 participants