Repository navigation
Conversation
|
Thanks, Matt. Showing Edit for photos that only have a preview makes sense. I’d like to address two issues before merging.
Could you add regression coverage for these cases? The current tests verify whether Edit appears in the menu. The regressions above happen after the tap. |
|
Thanks @marinofaggiana, both are addressed in 8ce96c7. Isolated Quick Look sessions: Download tied to the Edit request: Edit from the media viewer now goes through the viewer's loader, which shares a download already running for the same photo ( Regression coverage is in |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues allow stale photo editors to be presented, queued downloads to continue after cancellation, and full-resolution temporary image copies to accumulate without cleanup.
3 open issues
What changed in this PR
This PR addresses #4332 by making photo editing available from the viewer’s overflow menu, including eligible photos whose originals are not yet downloaded.
Changes:
- Uses the Edit label in both viewer and file context menus.
- Adds viewer-aware editing, shared downloads, and isolated Quick Look editing sessions.
- Adds unit tests for menu eligibility, download sharing, and editing-session behavior.
| File | Description |
|---|---|
Tests/NextcloudUnitTests/NCViewerPhotoEditTests.swift |
Tests session isolation, shared downloads, and viewer-validity checks. |
Tests/NextcloudUnitTests/NCContextMenuViewerTests.swift |
Tests Edit availability and side-effect-free menu creation. |
Tests/NextcloudUnitTests/MockViewerPhotoEditSource.swift |
Provides a controllable viewer and download mock. |
Nextcloud.xcodeproj/project.pbxproj |
Registers the new tests and mock in the unit test target. |
iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift |
Isolates editing state and temporary files; centralizes editor presentation. |
iOSClient/Viewer/NCViewerMedia/NCNextcloudMediaViewerLoader.swift |
Shares in-flight original-file downloads. |
iOSClient/Viewer/NCViewerMedia/NCMediaViewerHostingController.swift |
Connects the media viewer to the editing flow. |
iOSClient/Networking/NCNetworking+TransferDelegate.swift |
Uses the shared editor-presentation helper. |
iOSClient/Menu/NCContextMenuViewer.swift |
Adds eligible Edit actions and viewer-aware download handling. |
iOSClient/Menu/NCContextMenuMain.swift |
Renames the file context menu action to Edit. |
Review effort: Balanced
| let current = await NCManageDatabase.shared.getMetadataFromOcIdAsync(metadata.ocId) ?? metadata | ||
| NCViewerQuickLook.presentEditor(metadata: current, from: controller) |
There was a problem hiding this comment.
Confirmed at 8abde67: the present closure in makeModifyPhoto (NCContextMenuViewer.swift) awaits getMetadataFromOcIdAsync after the guard in NCViewerPhotoEdit.edit and then calls NCViewerQuickLook.presentEditor without rechecking. The fix is a !Task.isCancelled and source.isShowingMedia(ocId:) guard right after that database read, before presentEditor, so a viewer closed or swiped during the read opens nothing.
| let directory = temporaryDirectory.appendingPathComponent("QuickLookEdit-" + UUID().uuidString, isDirectory: true) | ||
| do { | ||
| try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) |
There was a problem hiding this comment.
Confirmed at 8abde67: makeEditingFileURL creates a QuickLookEdit- directory per session and nothing in NCViewerQuickLook removes it. The fix for this thread is NCViewerQuickLook owning that directory and deleting it when the editor is dismissed without changes, after the uploadAsync/readFileAsync step in saveModifiedFile completes, and inside presentEditor when writing or copying the image fails.
0923dc8 to
b0a1f4c
Compare
|
Merged current master into this branch in 8abde67 to clear the merge conflicts. Upstream's checks that block editing encrypted files are kept in |
|
Merged current master into this branch in 96b0629 to clear the new conflict. Upstream removed |
marinofaggiana
left a comment
There was a problem hiding this comment.
Thanks for sticking with this, @mvanhorn, and for addressing each round of feedback.
Stepping back, the PR has grown far beyond what the feature needs. Showing Edit for preview-only photos is a small change, but the diff is now +731/−89 and replaces the download cancellation in NCMediaViewerLoader, which we just reworked in #4489, #4491 and #4495. That is more risk and review time than a menu item is worth, so let's reset the scope.
Per our AI Contribution Policy, I'm converting this to a draft and asking for a focused rewrite:
Scope
- Leave
NCMediaViewerLoaderas it is onmaster, and dropNCInFlightTaskRegistry. - Menu: show Edit when the image is modifiable with Quick Look and the device is online or the file is stored locally.
- Action: if the file is local, keep today's path. Otherwise await the viewer model's existing
downloadOriginalImage(for:), then present the editor only if the viewer still shows that photo. - If a duplicate download is really a concern, a small
[ocId: Task]map on the@MainActormodel is enough. - Quick Look: keep the per-instance
hasChangesQuickLook. For the temporary copy, use a stable per-photo path such astmp/QuickLookEdit/<ocId>/<fileName>, so copies never pile up and no cleanup logic is needed. Right now every Edit leaves a full-resolution JPEG behind. - One type per file (see
AGENTS.md):NCViewerPhotoEditSourceandNCViewerPhotoEditshouldn't live inNCContextMenuViewer.swift. - The fallback branch in
makeModifyPhotofor non-media viewers looks unreachable for images. Please drop it unless there's a case for it.
Process
- Rebase on
masterwith a few clean commits, no merge commits. - Add an
Assisted-by: AGENT_NAME:MODEL_VERSIONtrailer to every AI-assisted commit (not justAssisted-by: AI), and tick the AI checkbox in the description. - Test the change on a live Nextcloud instance yourself, and add short steps to verify it to the description. Please leave out raw tool output.
A small, focused version of this would be very welcome. If it's easier, open a fresh PR and close this one. If there's no update within a month, we'll close it.
Assisted by ClaudeCode:claude-opus-5-5
|
One more thought, just to be clear on expectations: using AI is totally fine with us. What matters is that you own the result. Before the next push, please make sure you understand each change, could explain the design in your own words, and have tried it yourself on a device against a live instance. That makes the review much smoother for both of us. Thanks! |
Keep hasChangesQuickLook per NCViewerQuickLook instance, so opening another editor no longer resets the save prompt of an earlier one. Copy the photo to edit to a stable per-photo path, tmp/QuickLookEdit/<ocId>/<fileName>, so photos with the same name never share a temporary file and repeated edits replace the copy instead of leaving new ones behind. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
The viewer menu showed Modify only when the original was already on the device. Show Edit for images Quick Look can modify when the device is online or the file is stored locally, and use the Edit title in the file context menu too. When the original is missing, the action awaits the media viewer model's existing downloadOriginalImage(for:), which joins a download already in progress for that photo, and opens the editor only if the viewer is still on screen and showing the same photo. Local files keep the existing path. Fixes nextcloud#4332 Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
96b0629 to
705a13d
Compare
|
Thanks for the reset, it was the right call. I've rewritten this as two commits on current master, +30/-11. NCMediaViewerLoader is untouched and NCInFlightTaskRegistry is gone. The viewer menu now shows Edit when Quick Look can modify the image and the device is online or the file is local. If the original is already local, Edit takes the same path as before. Otherwise it awaits the model's existing downloadOriginalImage(for:) through a small method on the hosting controller, and opens the editor only if the viewer is still on screen and showing the same photo. I didn't add an [ocId: Task] map because downloadOriginalImage goes through loadPageIfNeeded, which already joins a load in progress for that photo. In Quick Look, hasChangesQuickLook is per instance, and the temporary copy goes to tmp/QuickLookEdit//, so edits reuse one file per photo. The unreachable fallback branch and the extra types are gone. I tested it in the iOS Simulator against a live local Nextcloud server (35.0.3 in Docker), not on a physical device. I throttled the server so the original was still downloading when I opened the menu. Edit was there, the editor opened as soon as the download finished, the server saw a single GET, and saving uploaded the rotated image. Verification steps are in the description now. |
|
Thanks Matt, this is exactly the kind of change we were hoping for. It's small and focused, and it builds on what's already there. A few notes from reading it:
One thing we need before merging: visible feedback while the original downloads. Right now, when the original isn't on the device and the user taps Edit, nothing happens until the download finishes. On a slow connection it looks like the tap didn't work, and if the download fails the user is never told. Please:
Please keep it as small as the rest of the change. Once that's in, mark the PR as ready for review so CI can run, and if it's green I'll approve. |
|
One more note on Please add a short comment at the call site stating this dependency, so it doesn't stay implicit. It also ties in with the error feedback above: if the download didn't happen for any reason, the user should be told. While you're on the progress indicator: with the current policy, the viewer usually starts downloading the original as soon as the photo is shown, and the page already carries a |
Opening Edit from a photo preview can take time or fail before the editor appears. Show that the original is downloading and explain failures while the requested photo is still selected. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
|
Added in f46eae1. The viewer had no visible indicator for the original download, so the selected photo now shows a small spinner over its preview while the page is in its existing |

While viewing a photo, the overflow menu offered Edit only when the original was already on the device. A photo that was only previewed, or still downloading, had no way to edit it from the viewer, and the file context menu labeled the action Modify.
The viewer menu now shows Edit when Quick Look can modify the image and the device is online or the file is stored locally. Both menus use the Edit title. If the original is local, Edit takes the existing path unchanged. Otherwise
NCMediaViewerHostingController.downloadOriginalForEditingawaits the model's existingdownloadOriginalImage(for:)and opens the editor only if the viewer is still on screen and showing the same photo. That call goes throughloadPageIfNeeded, which already joins a load in progress for the photo, so no second download starts. In Quick Look,hasChangesQuickLookis per instance and the temporary copy goes totmp/QuickLookEdit/<ocId>/<fileName>, so repeat edits reuse one file.NCMediaViewerLoaderis unchanged.How to verify
Tested in the iOS 27 Simulator against a local Nextcloud 35.0.3 server in Docker, with the server throttled so the original was still downloading when the menu opened. Not yet tested on a physical device.
🤖 AI (if applicable)
AI coding tools helped write and test this change under my direction. Commits carry the Assisted-by trailer.
Fixes #4332