Skip to content

fix(comparison): compare the file as the closing editor saved it - #9531

Draft
hweihwang wants to merge 1 commit into
mainfrom
fix/comparison-closing-save
Draft

hweihwang wants to merge 1 commit into
mainfrom
fix/comparison-closing-save

Conversation

@hweihwang

@hweihwang hweihwang commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

📝 Summary

Opening a comparison from the viewer closes the editor, which saves unsaved changes on its way out. The comparison loaded the file at the same time, so it could show the file without those changes.

  • The comparison now waits for that save, up to 15 seconds. When the save fails, takes longer, or the server refuses it (a conflict, or write access lost meanwhile), the comparison shows its error instead of the stored file. Loading again then compares the file as the server has it.
  • Plain-text files, compared side by side in their source view, wait for the save and show the viewer's error the same way, in both panes also when the save fails at once. An older version shown alone does not wait, and files show as text, also JSON files the browser would otherwise parse.
  • Files are served without caching rules, so the browser could also reuse an older copy of a file saved meanwhile. Both files are now fetched with Cache-Control: no-cache, and the requests give up after two minutes.
  • When the viewer shows a newer state of the file during a comparison, as after restoring a version from the sidebar, the comparison loads it again. The state the closing editor just saved is not loaded a second time.

First of five stacked PRs for #8904; it stands on its own.

🏁 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: Vitest for the wait, a failed, refused or late save, loading again afterwards, a newer state of the file, and the plain-text view, including both panes side by side; Playwright "Compare what was typed just before" in versions.spec.ts, which delays the save and fails without this fix
  • Documentation (README or documentation) has been updated or is not required

🤖 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

@hweihwang
hweihwang added this pull request to stack #9536 November 4, 2026 09:06
@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Nov 4, 2026
Opening a comparison from the viewer closes the editor, which saves
unsaved changes on its way out. The comparison loaded the file at the
same time, so it could show the file without those changes. It now waits
for that save, up to 15 seconds, and shows its error when the save fails,
is refused (a conflict or lost write access) or takes longer; loading
again then compares the file as the server has it. Plain-text files,
compared side by side in their source view, wait and fail the same way;
an older version shown there does not wait, and every file shows as
text, also one the browser could read as JSON.

Files are served without caching rules, so the browser could also reuse
an older copy of a file saved meanwhile. The comparison now asks with
Cache-Control: no-cache, gives up after two minutes instead of waiting
forever, and loads again when the viewer shows a newer state of the
file, as after a restore.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Hoang Pham <hoangmaths96@gmail.com>
@hweihwang
hweihwang force-pushed the fix/comparison-closing-save branch from 9ab1765 to b08c327 Compare November 9, 2026 11:36

This branch has not been deployed

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

Labels

AI assisted This PR contains AI-assisted commits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants