fix(provenance): scope attachments to originating post + scroll-cap the list
CI / lint (push) Successful in 2s
CI / frontend-build (push) Successful in 18s
CI / backend-lint-and-test (push) Successful in 26s
CI / integration (push) Successful in 3m19s

The Attachments section aggregated PostAttachment rows across EVERY post an
image was pHash-linked to. When one of those was a 'High Resolution Files'
mega-bundle (dozens of unrelated archives), the list ballooned past the
viewport and overwhelmed the modal's right rail.

- for_image() now scopes attachments to ImageRecord.primary_post_id (the post
  the file was actually captured from), falling back to all linked posts only
  when primary_post_id is unset (older rows / filesystem imports).
- ProvenancePanel wraps the list in a max-height scroll container with a count
  in the heading, mirroring the cards' independent-scroll treatment.

Note: FC stores archives as opaque blobs and never records which archive an
extracted image came from, so attachments can't yet be scoped tighter than the
post. Capturing image->archive containment is tracked as separate work.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-21 21:27:36 -04:00
parent 311fe0ee9c
commit 068def2f24
3 changed files with 99 additions and 9 deletions
+16 -1
View File
@@ -85,7 +85,22 @@ class ProvenanceService:
)
rows = (await self.session.execute(stmt)).all()
post_ids = [ip.post_id for ip, _p, _s, _a in rows]
attachments = await self._attachments_for_posts(post_ids)
# Scope attachments to the image's ORIGINATING post only, not every
# post it's pHash-linked to. An image dupe gets a provenance row per
# post it reappears in (enrich-on-duplicate), and one of those is
# often a "High Resolution Files" mega-bundle carrying dozens of
# unrelated archives — aggregating across all linked posts ballooned
# the panel with files that have nothing to do with this image.
# primary_post_id is the post this file was actually captured from;
# fall back to all linked posts only when it's unset (older rows /
# filesystem imports). NB: FC stores archives as opaque blobs and
# never records which archive an extracted image came from, so we
# cannot scope tighter than the post — see milestone for the
# image->archive capture work.
attach_post_ids = (
[rec.primary_post_id] if rec.primary_post_id is not None else post_ids
)
attachments = await self._attachments_for_posts(attach_post_ids)
return {
"image_id": image_id,
"provenance": [