Skip to content

fix(sync): improve situation around false conflicts - #9542

Merged
mejo- merged 3 commits into
mainfrom
fix/false_409
Nov 4, 2026
Merged

mejo- merged 3 commits into
mainfrom
fix/false_409

Conversation

@mejo-

@mejo- mejo- commented Nov 4, 2026

Copy link
Copy Markdown
Member

📝 Summary

See commit messages for details.

  • fix(sync): avoid false conflicts between overlapping saves
  • fix(sync): store the checksum of the saved content
  • perf(sync): throttle autosaves before checking for conflicts

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI tools
  • The AI-generated content was reviewed, comprehended and tested by a human

@mejo- mejo- self-assigned this Nov 4, 2026
@mejo- mejo- added bug Something isn't working 3. to review labels Nov 4, 2026
@github-project-automation github-project-automation Bot moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity team Nov 4, 2026
@mejo- mejo- moved this from 🧭 Planning evaluation (don't pick) to 👀 In review in 📝 Productivity team Nov 4, 2026
@mejo- mejo- changed the title Fix/false 409 fix(sync): improve situation around false conflicts Nov 4, 2026
@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Nov 4, 2026
Comment thread lib/Service/DocumentService.php Resolved
Comment thread lib/Context/IContext.php Outdated
* @param ?string $content Content just written to the context, to avoid reading it again
*/
public function updateDocument(Document $document): void;
public function updateDocument(Document $document, ?string $content = null): void;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if this breaks the API for deck. It only implements

public function updateDocument(Document $document): void;

I suspect that's not enough for implementing IContext anymore.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

True. So let's not touch the API and instead store savedContent as an instance variable in FileContext.php to be reused. I'll adjust.

mejo- added 3 commits November 4, 2026 16:37
A save request loads the document before checking for outside changes.
If another save by Text finished in between, the file checksum no longer
matched the loaded document and the save was rejected with 409, which
now shows the conflict dialog.

Before reporting a conflict, reload the document and only treat the
change as outside if the stored checksum still differs from the file.
Continue with the reloaded document so the following checks see the
version saved in the meantime.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
After writing the file, the checksum was computed by reading the file
again and stored only after the document state. A lock on the file or
a failure while writing the state left the previous checksum behind,
so every following save was rejected as a conflict. Reading the file
again could also pick up an outside change written right after the
save and hide the conflict.

Compute the checksum from the content Text just wrote and store it
right after writing the file.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
The conflict check reads the whole file to compute its checksum, also
for autosaves that are then dropped because the last save was less
than AUTOSAVE_MINIMUM_DELAY seconds ago.

Return early for those autosaves before checking for conflicts. They
do not write anything, so skipping the check cannot overwrite outside
changes. Manual saves are not throttled and are still checked.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@mejo-
mejo- merged commit a5f36fa into main Nov 4, 2026
74 of 83 checks passed
@mejo-
mejo- deleted the fix/false_409 branch November 4, 2026 20:15
@github-project-automation github-project-automation Bot moved this from 👀 In review to ☑️ Done in 📝 Productivity team Nov 4, 2026
@mejo-

mejo- commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

/backport to stable35

@mejo-

mejo- commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

/backport to stable34

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

Labels

3. to review AI assisted This PR contains AI-assisted commits bug Something isn't working

Projects

Status: ☑️ Done

Development

Successfully merging this pull request may close these issues.

3 participants