Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

feat(mobile): show S3-backed image attachment thumbnails (port #3707) - #3751

Merged
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/mobile-s3-attachment-thumbnails
Jul 23, 2026
Merged

feat(mobile): show S3-backed image attachment thumbnails (port #3707)#3751
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/mobile-s3-attachment-thumbnails

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Problem

Why: Image attachments on cloud task messages only appeared as file-name chips in the mobile app, making similar screenshots impossible to tell apart. This ports the desktop fix (#3707) to React Native.

Attachments also used to vanish after the task screen unmounted: the mobile app persisted a local echo of locally-sent attachments to AsyncStorage because the cloud log doesn't surface attachment data on user_message_chunk events. That cache never covered re-entry on a device that didn't send the message.

Changes

Image attachments on cloud task messages now render as real thumbnails, with the existing file chip as the fallback.

  • Resolve from the log, not a cache. The session/prompt entries already in the S3-backed log carry the attachment URIs (file://…/.posthog/attachments/<runId>/<artifactId>/<file>). On snapshot load we parse those and reattach them to the historical user_message_chunk events, so thumbnails appear on re-entry and on any device — not just the one that sent them.
  • Single source of truth. The local attachmentEchoStore (AsyncStorage) workaround is removed. In-flight optimistic rendering still works from the in-memory message the composer already pushes; the persisted cache it provided is now covered by log resolution.
  • Presigned previews. Added presignTaskRunArtifact to the mobile HTTP layer and a useCloudAttachmentPreview react-query hook. The run's artifact manifest is fetched once per run through the shared query cache (a message with several images does one manifest request), and presigned URLs are cached with a stale time well under their expiry (50 min).
  • Non-image attachments, and images whose preview fails to resolve, keep rendering as the file chip.
  • HumanMessage stays a generic chat primitive: it exposes a renderAttachment seam so the tasks feature supplies cloud resolution, avoiding a chat → tasks import cycle.

Note: the artifact-URI parsing mirrors @posthog/core/sessions/promptContent; mobile deliberately does not depend on @posthog/core, so the two are kept in sync by hand (same pattern as the existing iconDomain mirror). A possible follow-up is to host the parsing in @posthog/shared, which both already depend on.

How did you test this?

  • pnpm --filter @posthog/mobile test — 473 passing, including new unit tests for the artifact-URI parsing / reinjection (promptAttachments.test.ts, parameterised) and the presign API call (api.test.ts). The parsing tests cover the fallback-to-chip cases (ordinary file URIs, missing segments, non-image kinds).
  • pnpm lint (Biome) clean on all changed files.
  • tsc clean on the changed source files.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

Ports the desktop thumbnail feature (#3707) to the React Native app. Image
attachments on cloud task messages now render as real thumbnails resolved from
the artifact manifest — including on re-entry and on devices that did not send
the message — instead of plain file-name chips.

Resolves attachments from the `session/prompt` entries already in the S3-backed
log (a real fix) rather than the local AsyncStorage echo cache, which is
removed. Non-image attachments and images whose preview fails to resolve keep
rendering as the existing file chip.

Generated-By: PostHog Code
Task-Id: 45cd9bec-4cfc-4982-bde6-fd84d7ebf00d
@Gilbert09
Gilbert09 requested a review from a team July 23, 2026 10:58
@trunk-io

trunk-io Bot commented Jul 23, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

Copy link
Copy Markdown

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

src/features/tasks/components/TaskSessionView.tsx

Reviewed by React Doctor for commit ee37418.

@Gilbert09 Gilbert09 added the Stamphog This will request an autostamp by stamphog on small changes label Jul 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contained mobile-only UI/data-resolution feature (image thumbnails from S3 artifacts) with no auth, billing, migration, dependency, or CI changes — it only calls an existing backend endpoint pattern via the established authedFetch client. Diff matches the description, includes solid new unit test coverage, and no reviews, holds, or unresolved comments block it.

  • Author wrote 1% of the modified lines and has 26 merged PRs in these paths (familiarity MODERATE).
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 452L, 11F substantive, 710L/14F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (710L, 14F, single-area, feat)
stamphog 2.0.0b3 .stamphog/policy.yml @ f057f43 · reviewed head ee37418

@trunk-io
trunk-io Bot merged commit 49dbaf6 into main Jul 23, 2026
34 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/mobile-s3-attachment-thumbnails branch July 23, 2026 13:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant