Skip to content

[stable34] fix/autosave timer - #8928

Draft
backportbot[bot] wants to merge 15 commits into
stable34from
backport/8917/stable34
Draft

[stable34] fix/autosave timer#8928
backportbot[bot] wants to merge 15 commits into
stable34from
backport/8917/stable34

Conversation

@backportbot

@backportbot backportbot Bot commented Jul 30, 2026

Copy link
Copy Markdown

Backport of #8917

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
  • 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.

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>
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>
chore(tests): fix autosave test with new timing

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

[skip ci]
@backportbot
backportbot Bot requested review from max-nextcloud and mejo- July 30, 2026 07:29
@backportbot backportbot Bot added this to the Nextcloud 34.0.1 milestone Jul 30, 2026
@max-nextcloud

Copy link
Copy Markdown
Collaborator

Will test this on daily first and then look into the backport next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant