Skip to content

feat(versions): preview file versions with a diff against the current note - #3474

Open
larena1 wants to merge 1 commit into
nextcloud:mainfrom
larena1:feat/version-diff
Open

larena1 wants to merge 1 commit into
nextcloud:mainfrom
larena1:feat/version-diff

Conversation

@larena1

@larena1 larena1 commented Dec 3, 2026

Copy link
Copy Markdown

Tapping a version in the note details' activities list restored it immediately, without any way to see what it contained. This adds a preview screen for file versions with a line diff against the current note, and asks for confirmation before restoring.

Refs #3272

What changed

  • Version preview: tapping a version opens a new screen with two tabs:
    • Changes: a line diff against the current note. Lines only in this version are marked − on a red background, lines only in the current note + on green. Unchanged runs are collapsed to "⋯ N unchanged lines" with three lines of context.
    • Full text: the content of the version.
  • Restore: "Restore version" is now an extended FAB on the preview and the icon in the list. Both ask for confirmation first; the dialog survives rotation.
  • Version labels like the web versions tab: the newest entry is "Current version" (no restore, opens the local note text), the oldest is "Initial version". Version rows show the absolute date and time instead of only the weekday.
  • List accessibility: the restore icon is a 48dp button with a content description, version rows have a ripple, and activity rows that do nothing on tap are no longer clickable.

Two bugs found on the way

  • FileVersion from android-library only parcels mimeType and fileLength. Passing it through an Intent lost the file id and revision, so requests went to /versions/<user>/versions/0/0. A small serializable VersionReference is passed instead.
  • The server lists the current file as a version, but it has no stored version file, so downloading it returns 404. This entry is now treated as "Current version" and never requested from the server.

Notes for review

  • The line diff is implemented in LineDiff.kt (common prefix/suffix trimming + LCS) instead of adding a library, to avoid touching the Gradle verification metadata. Above 2M table cells it falls back to "all removed, all added" to bound memory.
  • "Current version" is the newest entry of the versions response. Servers before Nextcloud 26 don't include the current file in that list; there the newest real version would be shown as current.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

The code was written with Claude Code and reviewed, built and tested on a device by me.

How to test

  1. Open a note that has several versions on the server, then Details → Activities.
  2. Tap an older version: the diff loads, switch between "Changes" and "Full text".
  3. Tap the newest entry ("Current version"): it shows the current text without tabs and without restore.
  4. Restore a version from the preview and from the list icon; rotate the device while the confirmation dialog is open.
  5. Check light and dark theme and a server with a custom primary color.

🤖 Generated with Claude Code

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 113 complexity · 0 duplication

Metric Results
Complexity 113
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

… note

Tapping a version in the activities list restored it immediately, without
any way to see what it contained. Users now get a preview screen that shows
the changes compared to the current note, or the full text, and restoring
asks for confirmation first.

FileVersion from android-library only parcels mimeType and fileLength, so
passing it through an Intent lost the file id and revision and led to
requests for /versions/0/0. A small serializable VersionReference is passed
instead.

The server also lists the current file as a version, which has no stored
version file and returns 404 on download. The newest entry is therefore
labelled "Current version", shows the local note text and cannot be
restored, matching the Nextcloud web versions tab.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: larena1 <60823161+larena1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant