Skip to content

Refactor version comparison - #2878

Merged
mejo- merged 9 commits into
mainfrom
refactor/version-comparison
Oct 22, 2026
Merged

mejo- merged 9 commits into
mainfrom
refactor/version-comparison

Conversation

@mejo-

@mejo- mejo- commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

📝 Summary

Follow-up to #2699 and #2700.

This replaces the version comparison added in #2699 and #2700 with a much smaller implementation, similar to what nextcloud/text#9293 did for Text. Text now shows the differences between two Markdown versions in the viewer itself, so Collectives no longer needs a comparison dialog of its own.

  • Comparing a version with the current one opens the viewer again. With a recent Text, it shows Text's comparison: both documents side by side with the changes highlighted, synced scrolling and navigation between changes. Older Text versions show the plain side-by-side view.
  • A new "Compare versions…" button in the versions tab opens a small dialog for picking any two versions.
  • Members without edit permissions keep the versions tab and can compare versions.

Removed, as Text and the viewer handle it now or it isn't needed:

  • the comparison dialog with its own snapshot loading, caching, size limits and error handling
  • shareable comparison links (compareFrom / compareTo).
  • the separate CI setup for the comparison tests (semantic-e2e matrix entries, extra Playwright projects, Cypress flags)

Fixed along the way:

  • On Nextcloud 36, comparing failed for pages whose names need URL encoding, e.g. with a space: the viewer requested a double-encoded URL.
  • Comparing again while a comparison was open showed an endless spinner. Text loads the compared versions only once, so the viewer is closed before comparing other versions. This should be fixed in Text as well.
  • Opening a comparison from the versions tab switched the page sidebar to the attachments tab.
  • Versions loaded for a page that was no longer open replaced the versions list of the current page.

🚧 TODO

  • Allow to switch versions in viewer without having to reload it?
  • Set better titles for versions in viewer?

🏁 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 Oct 19, 2026
@github-project-automation github-project-automation Bot moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity team Oct 19, 2026
@mejo- mejo- moved this from 🧭 Planning evaluation (don't pick) to 🏗️ In progress in 📝 Productivity team Oct 19, 2026
@mejo-
mejo- force-pushed the refactor/version-comparison branch from 06e7b8f to 8b59a44 Compare October 20, 2026 07:45
@mejo-
mejo- marked this pull request as ready for review October 20, 2026 09:24
@mejo- mejo- moved this from 🏗️ In progress to 👀 In review in 📝 Productivity team Oct 20, 2026
@mejo- mejo- changed the title Refactor/version comparison Refactor version comparison Oct 20, 2026
@mejo-
mejo- requested a review from hweihwang October 20, 2026 09:25

@hweihwang hweihwang left a comment

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.

Thanks Jonas, much less code to carry, and on 36 it works well for me. Two things, not blocking:

  1. Comparing with the current version no longer saves the editor first, so the last seconds of typing can be missing from "Current version". Keeping the save before comparing would cover it.
  2. On 35, attachments may not load in the comparison: Collectives passes fileId, while Text stable35 reads OCA.Viewer.fileInfo.fileid. I only checked this in the code, not on a 35 instance.

mejo- added 7 commits October 22, 2026 10:18
Text shows the differences between two Markdown versions in the viewer
now, so the comparison dialog of its own is no longer needed. Comparing
a version with the current one opens the viewer again.

This removes the comparison dialog with its snapshot loading, caching
and size limits, as well as the shareable comparison links. Links with
`compareFrom` and `compareTo` open the page without a comparison now.

Kept from the previous implementation:
* the versions tab for members without edit permissions
* reloading the versions when the page timestamp changes
* ignoring outdated versions responses

The tests for the removed code and the separate CI setup for them are
removed as well. The Cypress page versions tests are back to the lean
version from before.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
The versions tab gets a "Compare versions…" button that opens a dialog
to pick any two versions of the page. The viewer then shows their
differences, using the earlier version as base.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Also covers comparing two selected versions.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org>
Nodes of `@nextcloud/files` take decoded sources and encode them for
requests. The versions store has encoded sources, so comparing versions
of pages with special characters in the name requested a double encoded
URL and failed to load the current version.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
…o it

The viewer asks for the sidebar whenever it shows a file while an app
sidebar is visible, e.g. when comparing versions from the versions tab.
Only switch to the attachments tab when the sidebar wasn't open yet.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
The Text comparison in the viewer loads the two versions only once.
Comparing other versions while a comparison is still open replaced the
files in the open viewer, but Text kept waiting for them to load and the
viewer showed its spinner forever. Closing the viewer first makes Text
load the newly compared versions.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
The viewer titled a comparison with the file names: the page's Markdown
file and the numeric id of the version. The compared versions carry the
names the versions tab shows now: current version, the version's label,
initial version or the date.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@mejo-
mejo- force-pushed the refactor/version-comparison branch from 8b59a44 to 150444d Compare October 22, 2026 09:28
The editor autosave might have a delay of up to 10 seconds, so comparing
the current version could miss the latest changes. The versions tab asks
the editor to save first, through an event like the one the
attachments tab uses to reach it. If saving fails, an error says so and
the comparison shows the last saved version.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@mejo-
mejo- force-pushed the refactor/version-comparison branch from 150444d to d801b06 Compare October 22, 2026 09:57
@mejo-

mejo- commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

Thanks Hoang!

Comparing with the current version no longer saves the editor first, so the last seconds of typing can be missing from "Current version". Keeping the save before comparing would cover it.

I first thought that we can leave this out as the new autosave logic in text is pretty good. But then I thought about it again and agree that now that we're on it, it's worth to fix this also straight away. There's the possibility of a delay of up to 10 seconds in autosave, so it's worth to save manually before comparing with current version. Fixed now.

On 35, attachments may not load in the comparison.

Indeed, good catch. Also fixed and a test added now.

On Nextcloud 35 and older, Text takes the file to resolve attachments of
the compared versions from the Viewer app's file info, by `fileid` and
`filename`. The versions passed have neither, so images in the compared
versions did not load. Pass the page's id and path along.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@mejo-
mejo- force-pushed the refactor/version-comparison branch from d801b06 to ead8273 Compare October 22, 2026 10:39
@mejo-
mejo- merged commit 59991e6 into main Oct 22, 2026
65 of 67 checks passed
@mejo-
mejo- deleted the refactor/version-comparison branch October 22, 2026 11:30
@github-project-automation github-project-automation Bot moved this from 👀 In review to ☑️ Done in 📝 Productivity team Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ☑️ Done

Development

Successfully merging this pull request may close these issues.

2 participants