Per 10621 thumbnail autorefresh - #1113
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1113 +/- ##
==========================================
+ Coverage 52.30% 52.35% +0.05%
==========================================
Files 355 355
Lines 12108 12132 +24
Branches 2189 2195 +6
==========================================
+ Hits 6333 6352 +19
- Misses 5547 5557 +10
+ Partials 228 223 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d7506a6 to
3249b4a
Compare
|
@aasandei-vsp , can we pair on this? It is a bigger change than I expected when I picked it up! I thought the first commit would do it. |
|
This appears to be working, but a note from Claude for our discussion: "Two threads for later: the id normalization to strings (which retires isSameId), and hideItemsInCurrentFolder carrying the same parentFolder_linkId mismatch — likely swept up by the same work." |
3249b4a to
74a5094
Compare
6b23183 to
51aa47b
Compare
cecilia-donnelly
left a comment
There was a problem hiding this comment.
I went through the manual tests except the profile picture ones (will do those later today). They are working! I was misled by the folder-with-only-subfolders because of some recurrence (possibly?) of the scroll bug -- I had to scroll up to the top manually. Without doing that the screen looked blank. Feel free to use my dev archive to poke around with different cases, @aasandei-vsp , since you found that public behaves differently on local: https://app.dev.permanent.org/p/archive/06ms-0000
51aa47b to
97ee045
Compare
Thank you for the archive! I have managed to test that part too and it all works! |
97ee045 to
3be88f8
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to restore “thumbnail appears shortly after upload without navigation/refresh” behavior by making thumbnail URL mutations observable to Angular consumers and by tightening share-preview thumbnail handling to avoid late-arriving real thumbnails overwriting stock placeholders.
Changes:
- Refactors
DataService.fetchLeanItemssettlement logic (resolver map keyed byfolder_linkId), adds cross-type ID comparison, and introduces athumbnailUpdated$()observable for thumbnail URL mutations. - Updates
FileListItemComponentto initialize thumbnails with share-preview safety and to react tothumbnailUpdated$()for in-place thumbnail URL updates. - Adjusts
FolderPickerComponentandProfileEditComponentbindings to re-read thumbnail URLs from mutated objects (avoiding pure-pipe “reference unchanged” issues), with accompanying tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/shared/services/data/data.service.ts | Adds ID normalization helper, resolver-map settlement, and thumbnailUpdated$() emission when thumbnails arrive. |
| src/app/shared/services/data/data.service.spec.ts | Adds unit coverage for thumbnail announcements, resolver settlement, and type-mismatched folder ID queueing. |
| src/app/file-browser/components/file-list-item/file-list-item.component.ts | Initializes thumbnails with share-preview safety and subscribes to thumbnailUpdated$() for in-place updates. |
| src/app/file-browser/components/file-list-item/file-list-item.component.spec.ts | Adds tests ensuring listed-share placeholders aren’t overwritten and validates late thumbnail update behavior. |
| src/app/core/components/profile-edit/profile-edit.component.ts | Replaces pure-pipe usage with a getter that re-reads thumbnail URL from a mutated ArchiveVO. |
| src/app/core/components/profile-edit/profile-edit.component.spec.ts | Adds a test asserting the profile photo updates when URLs are written onto the existing archive instance. |
| src/app/core/components/profile-edit/profile-edit.component.html | Switches [bgSrc] binding from pipe to profileThumbnail getter. |
| src/app/core/components/folder-picker/folder-picker.component.ts | Adds getThumbnailUrl() to re-read from mutated items instead of relying on a pure pipe. |
| src/app/core/components/folder-picker/folder-picker.component.spec.ts | Adds tests validating thumbnails render after mutation without row rebuild. |
| src/app/core/components/folder-picker/folder-picker.component.html | Switches thumbnail bindings from pipe to getThumbnailUrl(...). |
Suppressed comments (2)
src/app/file-browser/components/file-list-item/file-list-item.component.spec.ts:379
- Using setTimeout() to drain the async ngOnInit started by detectChanges() is brittle and can make tests slower/flaky. Prefer waiting on Angular stability instead of real timers.
await new Promise((resolve) => {
setTimeout(resolve);
});
src/app/file-browser/components/file-list-item/file-list-item.component.spec.ts:415
- Using setTimeout() here to let the previous ngOnInit settle relies on real timers. Prefer fixture.whenStable() (or fakeAsync/tick) so the test only waits for pending microtasks.
await new Promise((resolve) => {
setTimeout(resolve);
});
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
slifty
left a comment
There was a problem hiding this comment.
I believe this code looks good -- I do think that there are too many comments / the LLM is being too verbose in its inline commentary.
Probably worth either taking them out entirely (e.g. "please avoid comments and instead write self-documenting code") or at the very least having it do a pass to remove context-specific narratives.
a5f09a1 to
fedb573
Compare
This only works for the first thumbnail of an uploaded set.
This is a more complex fix that should get in-depth review, since it changes the data service and I am not confident in it. Claude suggests that in the switch to the stela "children" endpoint we missed a couple points. We weren't correctly tracking the responses because of the string/number id mismatch, so there are some workarounds for that in here.
… from BE After upload, the thumbnail is not immediatelly generated, so we keep calling the BE until it is available. So the list item will subscribe to this refresh and populate the thumbnail whenever is available. One important thing to mention is that thumbnails should not be available for restricted shares, so making sure that we only show it after we check if the share is restricted or not is vital, that's why the isUnlistedShare variable is needed. Issue: PER-10580
…ilable This fix just bypasses a big problem we are having accross the app. We are mutating objects in place instead of replacing them, so even if the reference is the same, the object has changed. This makes any object highly unreliable for using it inside an Angular context. In this situation, we were using a pipe for rendering the thumbnails, which is the correct approach. The issue is the pipe would update when the object reference changes, which never happens in our case, even though the thumbnailUrls do. Issue: PER-10580
…review Await it only when we are in a share preview, because that's the only place we need to know if we are actually showing the thumbnails or not. This change also makes ngOnInit synchronous for the other routes, which is an improvement. Issue: PER-10621
…eady explains The removed comments offered context about what is being replaced and that information does not need to live in the codebase. Issue: PER-10580
fedb573 to
bd45e14
Compare
omnignorant
left a comment
There was a problem hiding this comment.
Verified that thumbnails now resolve automatically after upload — single files, batch uploads, and mixed file types — and after leaving/returning to a folder mid-refresh, with no manual reload needed. Share previews behave correctly for a logged-out visitor (unlisted links show the real thumbnail, restricted links show the placeholder), and public archive folder tiles show four correctly distinct icon states (image thumbnail, empty, subfolders-only, mixed non-image).
I did discover what might be a new bug introduced here. I have not validated on prod yet. Basically, if you upload a folder (drag/drop an entire folder) then when you click into the folder during the upload process, the file list does not populate until you refresh. So more than just thumbnails, the entire file list requires a refresh.
- upload folder of items
- while uploading status message is still visible, click into the folder
- observe the file list is frozen
- refresh to see newly uploaded files in the list
|
Verified that the refresh-folder-during-upload is pre-existing (i.e., it's on prod now). Merging. |
We had a couple bugs preventing thumbnails from appearing immediately on upload, as they should. This is adding some perceived slowness to the app.
These changes need careful review, but seem to make thumbnails appear on upload again which is desirable.
Warning
The major issue here is that the fixes need to touch a service
DataServiceand a componentFolderPickerComponentthat are present in a lot of places and the code we introduce cannot be isolated. The fixes will need a lot of testing outside the thumbnails scope.Also, this fix just bypasses a big problem we are having accross the app. We are mutating objects in place instead of replacing them, so even if the reference is the same, the object has changed. This makes any object highly unreliable for using it inside an Angular context.
This would be the behavior for records:
https://www.loom.com/share/b3cbb52bf5bc4c03a0bf2c57d658ad83
Manual test cases
Thumbnail appears after upload
Single image
Several images at once
.zip).Leaving the folder mid-refresh
Share previews
(covered by specs — still verify once by hand, this is the highest-risk behaviour in the branch)
Listed share (preview toggle on)
assets/img/preview/. No real file content is visible anywhere on the page.Unlisted share
Public archive
Record thumbnails on first load
Folder tiles
folder_openicon rather than a broken image.perm_mediafor subfolders-only,descriptionfor mixed non-image files. No blank tiles.Choosing a profile photo or banner
Thumbnails on first open
Selected record preview in picker
The photo updates in place
Cancelling